GroupsController.cs 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Humanizer;
  7. using Microsoft.AspNetCore.SignalR;
  8. using Npgsql.Replication.PgOutput.Messages;
  9. using NPOI.SS.UserModel;
  10. using NPOI.SS.Util;
  11. using NPOI.XSSF.UserModel;
  12. using OASystem.API.Middlewares;
  13. using OASystem.API.OAMethodLib;
  14. using OASystem.API.OAMethodLib.APNs;
  15. using OASystem.API.OAMethodLib.File;
  16. using OASystem.API.OAMethodLib.Hub.HubClients;
  17. using OASystem.API.OAMethodLib.Hub.Hubs;
  18. using OASystem.API.OAMethodLib.JuHeAPI;
  19. using OASystem.API.OAMethodLib.KiMiApi;
  20. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  21. using OASystem.Domain.AesEncryption;
  22. using OASystem.Domain.Attributes;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels.CRM;
  31. using OASystem.Domain.ViewModels.Financial;
  32. using OASystem.Domain.ViewModels.Groups;
  33. using OASystem.Domain.ViewModels.OCR;
  34. using OASystem.Infrastructure.Repositories.CRM;
  35. using OASystem.Infrastructure.Repositories.Financial;
  36. using OASystem.Infrastructure.Repositories.Groups;
  37. using Quartz.Util;
  38. using SqlSugar.Extensions;
  39. using System.Collections;
  40. using System.ComponentModel.DataAnnotations;
  41. using System.Data;
  42. using System.Diagnostics;
  43. using System.Globalization;
  44. using System.IO.Compression;
  45. using System.Text.Json;
  46. using System.Web;
  47. using static OASystem.API.OAMethodLib.JWTHelper;
  48. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  49. using Bookmark = Aspose.Words.Bookmark;
  50. using Cell = Aspose.Words.Tables.Cell;
  51. using Table = Aspose.Words.Tables.Table;
  52. namespace OASystem.API.Controllers
  53. {
  54. /// <summary>
  55. /// 团组相关
  56. /// </summary>
  57. //[Authorize]
  58. [Route("api/[controller]/[action]")]
  59. public class GroupsController : ControllerBase
  60. {
  61. private readonly ILogger<GroupsController> _logger;
  62. private readonly GrpScheduleRepository _grpScheduleRep;
  63. private readonly IMapper _mapper;
  64. private readonly DelegationInfoRepository _groupRepository;
  65. private readonly TaskAssignmentRepository _taskAssignmentRep;
  66. private readonly AirTicketResRepository _airTicketResRep;
  67. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  68. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  69. private readonly DelegationEnDataRepository _delegationEnDataRep;
  70. private readonly DelegationVisaRepository _delegationVisaRep;
  71. private readonly VisaPriceRepository _visaPriceRep;
  72. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  73. private readonly HotelPriceRepository _hotelPriceRep;
  74. private readonly CustomersRepository _customersRep;
  75. private readonly MessageRepository _message;
  76. private readonly SqlSugarClient _sqlSugar;
  77. private readonly TourClientListRepository _tourClientListRep;
  78. private readonly TeamRateRepository _teamRateRep;
  79. #region 成本相关
  80. private readonly CheckBoxsRepository _checkBoxs;
  81. private readonly GroupCostRepository _GroupCostRepository;
  82. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  83. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  84. #endregion
  85. private readonly SetDataRepository _setDataRep;
  86. private string url;
  87. private string path;
  88. private readonly EnterExitCostRepository _enterExitCostRep;
  89. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  90. private readonly UsersRepository _usersRep;
  91. private readonly IJuHeApiService _juHeApi;
  92. private readonly InvertedListRepository _invertedListRep;
  93. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  94. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  95. private readonly ThreeCodeRepository _threeCodeRepository;
  96. private readonly HotelInquiryRepository _hotelInquiryRep;
  97. private readonly FeeAuditRepository _feeAuditRep;
  98. private readonly VisaCommissionRepository _visaCommissionRep;
  99. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  100. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  101. private readonly List<CurrencyInfo> _currencyInit;
  102. private readonly List<int> _portTypeData;
  103. private readonly TableOperationRecordRepository _tableorRep;
  104. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  105. private readonly RestaurantRepository _restaurantRep;
  106. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  107. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  108. /// <summary>
  109. /// 构造函数
  110. /// </summary>
  111. /// <param name="logger"></param>
  112. /// <param name="mapper"></param>
  113. /// <param name="hubContext"></param>
  114. /// <param name="sqlSugar"></param>
  115. /// <param name="grpScheduleRep"></param>
  116. /// <param name="groupRepository"></param>
  117. /// <param name="taskAssignmentRep"></param>
  118. /// <param name="airTicketResRep"></param>
  119. /// <param name="decreasePaymentsRep"></param>
  120. /// <param name="InvitationOfficialActivitiesRep"></param>
  121. /// <param name="delegationEnDataRep"></param>
  122. /// <param name="enterExitCostRep"></param>
  123. /// <param name="delegationVisaRep"></param>
  124. /// <param name="message"></param>
  125. /// <param name="visaPriceRep"></param>
  126. /// <param name="carTouristGuideGroundRep"></param>
  127. /// <param name="checkBoxs"></param>
  128. /// <param name="GroupCostRepository"></param>
  129. /// <param name="CostTypeHotelNumberRepository"></param>
  130. /// <param name="GroupCostParameterRepository"></param>
  131. /// <param name="hotelPriceRep"></param>
  132. /// <param name="customersRep"></param>
  133. /// <param name="setDataRep"></param>
  134. /// <param name="tourClientListRep"></param>
  135. /// <param name="teamRateRep"></param>
  136. /// <param name="usersRep"></param>
  137. /// <param name="juHeApi"></param>
  138. /// <param name="invertedListRep"></param>
  139. /// <param name="visaFeeInfoRep"></param>
  140. /// <param name="ticketBlackCodeRep"></param>
  141. /// <param name="hotelInquiryRep"></param>
  142. /// <param name="threeCodeRepository"></param>
  143. /// <param name="feeAuditRep"></param>
  144. /// <param name="visaCommissionRep"></param>
  145. /// <param name="ffrRep"></param>
  146. /// <param name="opinionaireRep"></param>
  147. /// <param name="tableorRep"></param>
  148. /// <param name="enterExitCostDraftRep"></param>
  149. /// <param name="restaurantRep"></param>
  150. /// <param name="enterExitCostQuoteRep"></param>
  151. /// <param name="grpOrderPreInfoRep"></param>
  152. public GroupsController(
  153. ILogger<GroupsController> logger,
  154. IMapper mapper,
  155. IHubContext<ChatHub, IChatClient> hubContext,
  156. SqlSugarClient sqlSugar,
  157. GrpScheduleRepository grpScheduleRep,
  158. DelegationInfoRepository groupRepository,
  159. TaskAssignmentRepository taskAssignmentRep,
  160. AirTicketResRepository airTicketResRep,
  161. DecreasePaymentsRepository decreasePaymentsRep,
  162. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  163. DelegationEnDataRepository delegationEnDataRep,
  164. EnterExitCostRepository enterExitCostRep,
  165. DelegationVisaRepository delegationVisaRep,
  166. MessageRepository message,
  167. VisaPriceRepository visaPriceRep,
  168. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  169. CheckBoxsRepository checkBoxs,
  170. GroupCostRepository GroupCostRepository,
  171. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  172. GroupCostParameterRepository GroupCostParameterRepository,
  173. HotelPriceRepository hotelPriceRep,
  174. CustomersRepository customersRep,
  175. SetDataRepository setDataRep,
  176. TourClientListRepository tourClientListRep,
  177. TeamRateRepository teamRateRep,
  178. UsersRepository usersRep,
  179. IJuHeApiService juHeApi,
  180. InvertedListRepository invertedListRep,
  181. VisaFeeInfoRepository visaFeeInfoRep,
  182. TicketBlackCodeRepository ticketBlackCodeRep,
  183. HotelInquiryRepository hotelInquiryRep,
  184. ThreeCodeRepository threeCodeRepository,
  185. FeeAuditRepository feeAuditRep,
  186. VisaCommissionRepository visaCommissionRep,
  187. ForeignReceivablesRepository ffrRep,
  188. OpinionaireRepository opinionaireRep,
  189. TableOperationRecordRepository tableorRep,
  190. EnterExitCostDraftRepository enterExitCostDraftRep,
  191. RestaurantRepository restaurantRep,
  192. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  193. GroupOrderPreInfoRepository grpOrderPreInfoRep
  194. )
  195. {
  196. _logger = logger;
  197. _mapper = mapper;
  198. _grpScheduleRep = grpScheduleRep;
  199. _groupRepository = groupRepository;
  200. _taskAssignmentRep = taskAssignmentRep;
  201. _airTicketResRep = airTicketResRep;
  202. _sqlSugar = sqlSugar;
  203. url = AppSettingsHelper.Get("ExcelBaseUrl");
  204. path = AppSettingsHelper.Get("ExcelBasePath");
  205. if (!System.IO.Directory.Exists(path))
  206. {
  207. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  208. }
  209. _decreasePaymentsRep = decreasePaymentsRep;
  210. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  211. _delegationEnDataRep = delegationEnDataRep;
  212. _enterExitCostRep = enterExitCostRep;
  213. _delegationVisaRep = delegationVisaRep;
  214. _message = message;
  215. _visaPriceRep = visaPriceRep;
  216. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  217. _checkBoxs = checkBoxs;
  218. _GroupCostRepository = GroupCostRepository;
  219. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  220. _GroupCostParameterRepository = GroupCostParameterRepository;
  221. _hotelPriceRep = hotelPriceRep;
  222. _customersRep = customersRep;
  223. _setDataRep = setDataRep;
  224. _tourClientListRep = tourClientListRep;
  225. _teamRateRep = teamRateRep;
  226. _hubContext = hubContext;
  227. _usersRep = usersRep;
  228. _juHeApi = juHeApi;
  229. _invertedListRep = invertedListRep;
  230. _visaFeeInfoRep = visaFeeInfoRep;
  231. _ticketBlackCodeRep = ticketBlackCodeRep;
  232. _hotelInquiryRep = hotelInquiryRep;
  233. _threeCodeRepository = threeCodeRepository;
  234. _feeAuditRep = feeAuditRep;
  235. _visaCommissionRep = visaCommissionRep;
  236. _ffrRep = ffrRep;
  237. _opinionaireRep = opinionaireRep;
  238. _currencyInit = new List<CurrencyInfo>()
  239. {
  240. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  241. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  242. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  243. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  244. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  245. };
  246. _portTypeData = new List<int>() { 2, 3 };
  247. _tableorRep = tableorRep;
  248. _enterExitCostDraftRep = enterExitCostDraftRep;
  249. _restaurantRep = restaurantRep;
  250. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  251. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  252. }
  253. #region 流程管控
  254. /// <summary>
  255. /// 获取团组流程管控信息
  256. /// </summary>
  257. /// <param name="_jsonDto">查询参数</param>
  258. /// <returns></returns>
  259. [HttpPost]
  260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  261. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  262. {
  263. if (string.IsNullOrEmpty(_jsonDto.Paras))
  264. {
  265. return Ok(JsonView(false, "参数为空"));
  266. }
  267. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  268. if (_ScheduleDto != null)
  269. {
  270. if (_ScheduleDto.SearchType == 2)//获取列表
  271. {
  272. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  273. return Ok(JsonView(_grpScheduleViewList));
  274. }
  275. else//获取对象
  276. {
  277. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  278. if (_grpScheduleView != null)
  279. {
  280. return Ok(JsonView(_grpScheduleView));
  281. }
  282. }
  283. }
  284. else
  285. {
  286. return Ok(JsonView(false, "参数反序列化失败"));
  287. }
  288. return Ok(JsonView(false, "暂无数据!"));
  289. }
  290. /// <summary>
  291. /// 修改团组流程管控详细表数据
  292. /// </summary>
  293. /// <param name="dto"></param>
  294. /// <returns></returns>
  295. [HttpPost]
  296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  297. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  298. {
  299. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  300. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  301. .SetColumns(it => it.Duty == _detail.Duty)
  302. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  303. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  304. .SetColumns(it => it.JobContent == _detail.JobContent)
  305. .SetColumns(it => it.Remark == _detail.Remark)
  306. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  307. .Where(s => s.Id == dto.Id)
  308. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  309. .ExecuteCommandAsync();
  310. if (result > 0)
  311. {
  312. return Ok(JsonView(true, "保存成功!"));
  313. }
  314. return Ok(JsonView(false, "保存失败!"));
  315. }
  316. /// <summary>
  317. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  318. /// </summary>
  319. /// <param name="dto"></param>
  320. /// <returns></returns>
  321. [HttpPost]
  322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  323. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  324. {
  325. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  326. _detail.IsDel = 1;
  327. _detail.DeleteUserId = dto.Duty;
  328. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  329. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  330. .SetColumns(it => it.IsDel == _detail.IsDel)
  331. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  332. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  333. .Where(it => it.Id == dto.Id)
  334. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  335. //.WhereColumns(s => s.Id == dto.Id)
  336. .ExecuteCommandAsync();
  337. if (result > 0)
  338. {
  339. return Ok(JsonView(true, "删除成功!"));
  340. }
  341. return Ok(JsonView(false, "删除失败!"));
  342. }
  343. /// <summary>
  344. /// 增加团组流程管控详细表数据
  345. /// </summary>
  346. /// <param name="dto"></param>
  347. /// <returns></returns>
  348. [HttpPost]
  349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  350. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  351. {
  352. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  353. if (DateTime.Now < _detail.ExpectBeginDt)
  354. {
  355. _detail.StepStatus = 0;
  356. }
  357. else
  358. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  359. _detail.StepStatus = 1;
  360. }
  361. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  362. if (result > 0)
  363. {
  364. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  365. return Ok(JsonView(true, "添加成功!", _result));
  366. }
  367. return Ok(JsonView(false, "添加失败!"));
  368. }
  369. #endregion
  370. #region 团组前期信息
  371. /// <summary>
  372. /// 团组前期信息H5-URL(员工对应地址)
  373. /// </summary>
  374. /// <param name="name">用户名称</param>
  375. /// <returns></returns>
  376. [HttpGet]
  377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  378. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  379. {
  380. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  381. .Where(x => x.IsDel == 0)
  382. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  383. .OrderBy(x => x.Id)
  384. .Select(x => new
  385. {
  386. name = x.CnName,
  387. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  388. })
  389. .ToListAsync();
  390. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  391. }
  392. /// <summary>
  393. /// 团组前期信息 List
  394. /// </summary>
  395. /// <returns></returns>
  396. [HttpPost]
  397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  398. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  399. {
  400. var search = dto.Search;
  401. int[] nameTempIds = new int[] { 1, 12, 28 },
  402. countryTempIds = new int[] { 2, 13, 29 },
  403. daysTempIds = new int[] { 4, 15, 31 },
  404. ppNumTempIds = new int[] { 6 };
  405. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  406. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  407. .Where((opi, u) => opi.IsDel == 0)
  408. .OrderByDescending((opi, u) => opi.CreateTime)
  409. .Select((opi, u) => new GroupOrderPreInfoListView()
  410. {
  411. Id = opi.Id,
  412. Name = opi.Name,
  413. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  414. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  415. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  416. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  417. Operator = u.CnName,
  418. OperationTime = opi.CreateTime
  419. })
  420. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  421. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  422. .ToListAsync();
  423. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  424. int total = list.Count;
  425. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  426. var listPageData1 = listPageData
  427. .Skip((dto.PageIndex - 1) * dto.PageSize)
  428. .Take(dto.PageSize)
  429. .ToList();
  430. var infoIds = listPageData1.Select(x => x.Id).ToList();
  431. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  432. .Where(x => x.IsDel == 0 && x.STid == 109)
  433. .ToArrayAsync();
  434. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  435. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  436. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  437. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  438. .ToListAsync();
  439. foreach (var item in listPageData1)
  440. {
  441. var typeDatas1 = typeDatas.Select(x => new
  442. {
  443. x.Id,
  444. x.Name,
  445. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  446. }).ToArray();
  447. item.VersionDetails = typeDatas1;
  448. }
  449. return Ok(JsonView(listPageData1, listPageData1.Count));
  450. }
  451. /// <summary>
  452. /// 团组前期信息 Init
  453. /// </summary>
  454. /// <returns></returns>
  455. [HttpGet("{userId}")]
  456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  457. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  458. {
  459. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  460. }
  461. /// <summary>
  462. /// 国家数据源
  463. /// </summary>
  464. /// <param name="pageIndex">当前页码</param>
  465. /// <param name="pageSize">每页条数</param>
  466. /// <param name="search">查询条件</param>
  467. /// <returns></returns>
  468. [HttpGet]
  469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  470. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  471. {
  472. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  473. if (pageIndex == 0 && pageSize == 0)
  474. {
  475. //所有数据
  476. return Ok(JsonView(countrys, countrys.Count));
  477. }
  478. //分页
  479. int skip = (pageIndex - 1) * pageSize;
  480. int take = pageSize;
  481. if (!string.IsNullOrEmpty(search))
  482. {
  483. IEnumerable<char> charSequence = search.Select(c => c);
  484. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  485. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  486. return Ok(JsonView(pageData, pageResult1.Count));
  487. }
  488. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  489. return Ok(JsonView(pageResult2, countrys.Count));
  490. }
  491. /// <summary>
  492. /// 城市数据源
  493. /// </summary>
  494. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  495. /// <param name="pageIndex">当前页码</param>
  496. /// <param name="pageSize">每页条数</param>
  497. /// <param name="search">查询条件</param>
  498. /// <returns></returns>
  499. [HttpGet("{countryLabel}")]
  500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  501. public async Task<IActionResult> CityByCountry(
  502. string countryLabel,
  503. [FromQuery] int pageIndex,
  504. [FromQuery] int pageSize,
  505. [FromQuery] string search)
  506. {
  507. countryLabel = HttpUtility.UrlDecode(countryLabel);
  508. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  509. var citys = Array.Empty<string?>();
  510. if (countryList.Any())
  511. {
  512. var cityDatas = await _sqlSugar
  513. .Queryable<Grp_NationalTravelFee>()
  514. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  515. .ToArrayAsync();
  516. foreach (var item in cityDatas)
  517. {
  518. if (item.City.Contains("城市"))
  519. {
  520. item.City = item.Country + "-所有城市";
  521. }
  522. }
  523. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  524. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  525. }
  526. if (pageIndex == 0 && pageSize == 0)
  527. {
  528. //所有数据
  529. return Ok(JsonView(citys, citys?.Length ?? 0));
  530. }
  531. //分页
  532. int skip = (pageIndex - 1) * pageSize;
  533. int take = pageSize;
  534. if (!string.IsNullOrEmpty(search))
  535. {
  536. IEnumerable<char> charSequence = search.Select(c => c);
  537. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  538. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  539. return Ok(JsonView(pageData, pageResult1.Count));
  540. }
  541. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  542. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  543. }
  544. /// <summary>
  545. /// 团组前期信息 Info
  546. /// </summary>
  547. /// <param name="dto">Id</param>
  548. /// <returns></returns>
  549. [HttpGet("{Id}/{TempId}")]
  550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  551. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  552. {
  553. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  554. }
  555. /// <summary>
  556. /// 团组前期信息 移动端 Info
  557. /// </summary>
  558. /// <param name="dto">Id</param>
  559. /// <returns></returns>
  560. [HttpGet("{Id}/{TempId}")]
  561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  562. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  563. {
  564. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  565. }
  566. /// <summary>
  567. /// 团组前期信息 Save
  568. /// </summary>
  569. /// <param name="dto">Id</param>
  570. /// <returns></returns>
  571. [HttpPost]
  572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  573. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  574. {
  575. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  576. }
  577. /// <summary>
  578. /// 团组前期信息 Del
  579. /// </summary>
  580. /// <param name="dto">Id</param>
  581. /// <returns></returns>
  582. [HttpPost]
  583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  584. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  585. {
  586. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  587. }
  588. /// <summary>
  589. /// 团组前期信息 文件下载
  590. /// </summary>
  591. /// <param name="dto">Id</param>
  592. /// <returns></returns>
  593. [HttpGet("{Id}/{TempId}")]
  594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  595. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  596. {
  597. int id = dto.Id, tempId = dto.TempId;
  598. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  599. var data = view.Data as GrpOrderPreInfoView;
  600. #region Excel
  601. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  602. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  603. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  604. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  605. var fileNamePrefix = string.Empty;
  606. if (tempId == 1405)
  607. {
  608. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  609. fileNamePrefix = $"{data.Name}_无商邀版";
  610. }
  611. else if (tempId == 1406)
  612. {
  613. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  614. fileNamePrefix = $"{data.Name}_有商邀版";
  615. }
  616. else
  617. {
  618. //tempId == 1404 默认下载
  619. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  620. fileNamePrefix = $"{data.Name}_单接送机";
  621. }
  622. foreach (var item in data.Items)
  623. {
  624. var obj = item.NewValue;
  625. if (obj == null) item.OriginVal = "";
  626. else if (obj.Equals("有") || obj.Equals("无"))
  627. {
  628. item.OriginVal = obj.ToString();
  629. }
  630. else if (obj is object[] objArray)
  631. {
  632. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  633. item.OriginVal = string.Join("、", stringArray);
  634. }
  635. else if (obj is string[] stringArray)
  636. {
  637. item.OriginVal = string.Join("、", stringArray);
  638. }
  639. else if (obj.Equals("-"))
  640. {
  641. item.OriginVal = "";
  642. }
  643. }
  644. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  645. fileName = CommonFun.ValidFileName(fileName);
  646. //载入模板
  647. var designer = new WorkbookDesigner
  648. {
  649. Workbook = new Workbook(tempPath)
  650. };
  651. if (tempId == 1406)
  652. {
  653. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  654. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  655. for (int i = 1; i <= view2.Length; i++)
  656. {
  657. view2[i - 1].Index = i;
  658. }
  659. designer.SetDataSource("View1", view1);
  660. designer.SetDataSource("View2", view2);
  661. }
  662. else
  663. {
  664. designer.SetDataSource("View", data.Items);
  665. }
  666. designer.Process();
  667. if (!Directory.Exists(savePath))
  668. {
  669. Directory.CreateDirectory(savePath);
  670. }
  671. string serverPath = $"{savePath}{fileName}";
  672. designer.Workbook.Save(serverPath);
  673. string rst = $"{servicePath}{ftpPath}{fileName}";
  674. #endregion
  675. return Ok(JsonView(new { url = rst }));
  676. }
  677. #endregion
  678. #region 团组基本信息
  679. /// <summary>
  680. /// 接团信息列表
  681. /// </summary>
  682. /// <param name="dto">团组列表请求dto</param>
  683. /// <returns></returns>
  684. [HttpPost]
  685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  686. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  687. {
  688. var groupData = await _groupRepository.GetGroupList(dto);
  689. if (groupData.Code != 0)
  690. {
  691. return Ok(JsonView(false, groupData.Msg));
  692. }
  693. return Ok(JsonView(groupData.Data));
  694. }
  695. /// <summary>
  696. /// 分页查询团组列表
  697. /// </summary>
  698. /// <param name="dto"></param>
  699. /// <returns></returns>
  700. [HttpPost]
  701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  702. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  703. {
  704. var watch = new Stopwatch();
  705. watch.Start();
  706. RefAsync<int> total = 0;
  707. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  708. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  709. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  710. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  711. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  712. .Distinct()
  713. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  714. watch.Stop();
  715. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  716. }
  717. /// <summary>
  718. /// 接团信息列表 Page Init
  719. /// </summary>
  720. /// <returns></returns>
  721. [HttpPost]
  722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  723. public async Task<IActionResult> PostGroupPageListInit()
  724. {
  725. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  726. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  727. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  728. var _view = new
  729. {
  730. depData = depDatas,
  731. rankData = rankDatas
  732. };
  733. return Ok(JsonView(true, "查询成功!", _view));
  734. }
  735. /// <summary>
  736. /// 接团信息列表 Page
  737. /// </summary>
  738. /// <param name="dto">团组列表请求dto</param>
  739. /// <returns></returns>
  740. [HttpPost]
  741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  742. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  743. {
  744. #region 参数验证
  745. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  746. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  747. #region 页面操作权限验证
  748. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  749. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  750. #endregion
  751. #endregion
  752. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  753. {
  754. string sqlWhere = string.Empty;
  755. if (dto.IsSure == 0) //未完成
  756. {
  757. sqlWhere += string.Format(@" And IsSure = 0");
  758. }
  759. else if (dto.IsSure == 1) //已完成
  760. {
  761. sqlWhere += string.Format(@" And IsSure = 1");
  762. }
  763. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  764. {
  765. string tj = dto.SearchCriteria;
  766. 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}%')",
  767. tj, tj, tj, tj, tj);
  768. }
  769. if (int.TryParse(dto.Rank, out int rankId))
  770. {
  771. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  772. }
  773. string sqlWhere1 = string.Empty;
  774. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  775. {
  776. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  777. }
  778. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  779. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  780. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  781. JietuanOperator,IsSure,CreateTime,IsBid
  782. From (
  783. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  784. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  785. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  786. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  787. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  788. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  789. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  790. From Grp_DelegationInfo gdi
  791. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  792. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  793. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  794. Where gdi.IsDel = 0 {0}
  795. ) temp {1}", sqlWhere, sqlWhere1);
  796. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  797. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  798. //处理 团组模块实际操作人
  799. _DelegationList.ForEach(async x =>
  800. {
  801. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  802. var operatorNames = new StringBuilder();
  803. //operatorNames.AppendLine("各模块实际操作人:");
  804. if (operators.Any())
  805. {
  806. operators.ForEach(y =>
  807. {
  808. string label = string.Empty;
  809. if (y.OperationUsers.Any())
  810. {
  811. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  812. label = string.Join('、', users);
  813. }
  814. else label = "暂未指定";
  815. operatorNames.AppendLine($"{y.CTableName}:{label}");
  816. operatorNames.AppendLine();
  817. });
  818. }
  819. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  820. });
  821. var _view = new
  822. {
  823. PageFuncAuth = pageFunAuthView,
  824. Data = _DelegationList
  825. };
  826. return Ok(JsonView(true, "查询成功!", _view, total));
  827. }
  828. else
  829. {
  830. return Ok(JsonView(false, "查询失败"));
  831. }
  832. }
  833. /// <summary>
  834. /// 团组列表
  835. /// </summary>
  836. /// <returns></returns>
  837. [HttpPost]
  838. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  839. {
  840. #region 参数验证
  841. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  842. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  843. #region 页面操作权限验证
  844. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  845. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  846. #endregion
  847. #endregion
  848. if (dto.PortType != 1 && dto.PortType != 2)
  849. {
  850. return Ok(JsonView(false, "查询失败!"));
  851. }
  852. string orderbyStr = "order by gdi.CreateTime Desc";
  853. string sqlWhere = string.Empty;
  854. if (dto.IsSure == 0) //未完成
  855. {
  856. sqlWhere += string.Format(@" And IsSure = 0");
  857. }
  858. else if (dto.IsSure == 1) //已完成
  859. {
  860. sqlWhere += string.Format(@" And IsSure = 1");
  861. }
  862. //团组类型
  863. if (dto.TeamDid > 0)
  864. {
  865. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  866. }
  867. //团组名称
  868. if (!string.IsNullOrEmpty(dto.TeamName))
  869. {
  870. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  871. }
  872. //客户名称
  873. if (!string.IsNullOrEmpty(dto.ClientName))
  874. {
  875. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  876. }
  877. //客户单位
  878. if (!string.IsNullOrEmpty(dto.ClientUnit))
  879. {
  880. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  881. }
  882. //出访时间
  883. if (!string.IsNullOrEmpty(dto.visitDataTime))
  884. {
  885. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  886. orderbyStr = "order by gdi.VisitDate";
  887. }
  888. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  889. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  890. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  891. JietuanOperator,IsSure,CreateTime
  892. From (
  893. Select row_number() over({0}) as Row_Number,
  894. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  895. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  896. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  897. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  898. From Grp_DelegationInfo gdi
  899. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  900. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  901. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  902. Where gdi.IsDel = 0 {1}
  903. ) temp ", orderbyStr, sqlWhere);
  904. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  905. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  906. #region 处理所属部门
  907. /*
  908. * 1.sq 和 gyy 等显示 市场部
  909. * 2.王鸽和主管及张总还有管理员号统一国交部
  910. * 2-1. 4 管理员 ,21 张海麟
  911. */
  912. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  913. var userIds1 = new List<int>() { 4, 21 };
  914. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  915. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  916. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  917. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  918. .ToList();
  919. foreach (var item in _DelegationList)
  920. {
  921. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  922. }
  923. #endregion
  924. var _view = new
  925. {
  926. PageFuncAuth = pageFunAuthView,
  927. Data = _DelegationList
  928. };
  929. return Ok(JsonView(true, "查询成功!", _view, total));
  930. }
  931. /// <summary>
  932. /// 接团信息详情
  933. /// </summary>
  934. /// <param name="dto">团组info请求dto</param>
  935. /// <returns></returns>
  936. [HttpPost]
  937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  938. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  939. {
  940. var groupData = await _groupRepository.GetGroupInfo(dto);
  941. if (groupData.Code != 0)
  942. {
  943. return Ok(JsonView(false, groupData.Msg));
  944. }
  945. return Ok(JsonView(groupData.Data));
  946. }
  947. /// <summary>
  948. /// 接团信息 编辑添加
  949. /// 基础信息数据源
  950. /// </summary>
  951. /// <param name="dto"></param>
  952. /// <returns></returns>
  953. [HttpPost]
  954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  955. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  956. {
  957. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  958. if (groupData.Code != 0)
  959. {
  960. return Ok(JsonView(false, groupData.Msg));
  961. }
  962. return Ok(JsonView(groupData.Data));
  963. }
  964. /// <summary>
  965. /// 成本修改团组信息
  966. /// </summary>
  967. /// <param name="dto"></param>
  968. /// <returns></returns>
  969. [HttpPost]
  970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  971. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  972. {
  973. var jw = JsonView(false, "操作失败");
  974. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  975. if (di == null)
  976. {
  977. jw.Msg = "参数有误!";
  978. return Ok(jw);
  979. }
  980. #region 添加出访起止时间
  981. var startTime = new DateTime();
  982. var endTime = new DateTime();
  983. if (DateTime.TryParse(dto.VisitDate, out startTime))
  984. {
  985. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  986. }
  987. else
  988. {
  989. jw.Msg = "参数有误!";
  990. return Ok(jw);
  991. }
  992. #endregion
  993. di.VisitDate = startTime;
  994. di.VisitPNumber = dto.VisitPNumber;
  995. di.VisitDays = dto.VisitDays;
  996. di.VisitStartDate = startTime;
  997. di.VisitEndDate = endTime;
  998. var count = _sqlSugar.Updateable(di)
  999. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1000. .ExecuteCommand();
  1001. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1002. }
  1003. /// <summary>
  1004. /// 接团信息 编辑添加
  1005. /// 省份-城市 基础信息数据源
  1006. /// </summary>
  1007. /// <param name="dto"></param>
  1008. /// <returns></returns>
  1009. [HttpPost]
  1010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1011. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1012. {
  1013. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1014. string search = dto.Search;
  1015. var data = await _groupRepository.CityBasicSource();
  1016. int total = data.Length;
  1017. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1018. .Skip((pageIndex - 1) * pageSize)
  1019. .Take(pageSize)
  1020. .ToArray();
  1021. return Ok(JsonView(data, total));
  1022. }
  1023. /// <summary>
  1024. /// 接团信息 操作(增改)
  1025. /// </summary>
  1026. /// <param name="dto"></param>
  1027. /// <returns></returns>
  1028. [HttpPost]
  1029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1030. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1031. {
  1032. // 创建 Stopwatch 实例
  1033. Stopwatch stopwatch = Stopwatch.StartNew();
  1034. decimal ffrPrice = 0.00M;
  1035. DateTime? visitDt = null;
  1036. if (dto.Status == 2)
  1037. {
  1038. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1039. if (groupInfo != null)
  1040. {
  1041. ffrPrice = groupInfo.PaymentMoney;
  1042. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1043. }
  1044. }
  1045. var groupData = await _groupRepository.GroupOperation(dto);
  1046. if (groupData.Code != 0)
  1047. {
  1048. return Ok(JsonView(false, groupData.Msg));
  1049. }
  1050. int diId = 0;
  1051. try
  1052. {
  1053. //添加时 默认加入团组汇率
  1054. if (dto.Status == 1) //添加
  1055. {
  1056. diId = groupData.Data;
  1057. //添加默认币种
  1058. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1059. //默认分配权限
  1060. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1061. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1062. var _managerIds = new List<int>() { 22, 32, 21 };
  1063. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1064. if (userIds.Count > 0)
  1065. {
  1066. userIds.Add(208);
  1067. //创建团组管控
  1068. GroupStepForDelegation.CreateWorkStep(diId);
  1069. //发送消息
  1070. string groupName = dto.TeamName;
  1071. string createGroupUser = string.Empty;
  1072. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1073. if (userInfo != null) createGroupUser = userInfo.CnName;
  1074. string title = $"系统通知";
  1075. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1076. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1077. }
  1078. //默认创建倒推表
  1079. await _invertedListRep._Create(dto.UserId, diId);
  1080. }
  1081. else if (dto.Status == 2)
  1082. {
  1083. diId = dto.Id;
  1084. }
  1085. #region 签证人员团组时间通知
  1086. #region 计算出访起止时间
  1087. var startTime = new DateTime();
  1088. var endTime = new DateTime();
  1089. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1090. {
  1091. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1092. }
  1093. #endregion
  1094. #endregion
  1095. #region 团组操作默认添加/修改收款账单
  1096. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1097. {
  1098. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1099. .Where(x => x.IsDel == 0 &&
  1100. x.Diid == diId &&
  1101. x.Remark.Equals("预付款")
  1102. )
  1103. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1104. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1105. .FirstAsync();
  1106. ffrInfo = new Fin_ForeignReceivables()
  1107. {
  1108. Diid = diId,
  1109. PriceName = dto.ClientUnit,
  1110. Price = dto.PaymentMoney,
  1111. Count = 1,
  1112. Unit = $"元",
  1113. ItemSumPrice = dto.PaymentMoney,
  1114. Rate = 1.0000M,
  1115. Currency = 836,
  1116. AddingWay = 0,
  1117. CreateUserId = dto.UserId,
  1118. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1119. Remark = $"预付款"
  1120. };
  1121. if (ffrInfo == null) //Add
  1122. {
  1123. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1124. }
  1125. else //修改
  1126. {
  1127. await _sqlSugar.Updateable(ffrInfo)
  1128. .UpdateColumns(x => new
  1129. {
  1130. x.PriceName,
  1131. x.Price,
  1132. x.ItemSumPrice,
  1133. x.CreateTime,
  1134. x.CreateUserId
  1135. })
  1136. .WhereColumns(x => x.Id)
  1137. .ExecuteCommandAsync();
  1138. }
  1139. }
  1140. #endregion
  1141. if (diId > 0)
  1142. {
  1143. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1144. }
  1145. // 停止计时
  1146. stopwatch.Stop();
  1147. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1148. }
  1149. catch (Exception ex)
  1150. {
  1151. // 停止计时
  1152. stopwatch.Stop();
  1153. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1154. Logs(ex.Message);
  1155. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1156. }
  1157. // 停止计时
  1158. stopwatch.Stop();
  1159. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1160. }
  1161. /// <summary>
  1162. /// 接团流程操作(增改)
  1163. /// 安卓端使用 建团时添加客户名单
  1164. /// </summary>
  1165. /// <param name="dto"></param>
  1166. /// <returns></returns>
  1167. [HttpPost]
  1168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1169. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1170. {
  1171. #region 参数验证
  1172. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1173. #region 页面操作权限验证
  1174. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1175. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1176. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1177. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1178. #endregion
  1179. #endregion
  1180. try
  1181. {
  1182. //_sqlSugar.BeginTran();
  1183. decimal ffrPrice = 0.00M;
  1184. DateTime? visitDt = null;
  1185. if (dto.Status == 2)
  1186. {
  1187. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1188. if (groupInfo != null)
  1189. {
  1190. ffrPrice = groupInfo.PaymentMoney;
  1191. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1192. }
  1193. }
  1194. var _dto = new GroupOperationDto();
  1195. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1196. var groupData = await _groupRepository.GroupOperation(_dto);
  1197. if (groupData.Code != 0)
  1198. {
  1199. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1200. }
  1201. int diId = 0;
  1202. //添加时 默认加入团组汇率
  1203. if (dto.Status == 1) //添加
  1204. {
  1205. diId = groupData.Data;
  1206. //添加默认币种
  1207. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1208. //默认分配权限
  1209. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1210. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1211. var _managerIds = new List<int>() { 21, 22, 32 };
  1212. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1213. if (userIds.Count > 0)
  1214. {
  1215. userIds.Add(208);
  1216. //创建团组管控
  1217. GroupStepForDelegation.CreateWorkStep(diId);
  1218. //发送消息
  1219. string groupName = dto.TeamName;
  1220. string createGroupUser = string.Empty;
  1221. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1222. if (userInfo != null) createGroupUser = userInfo.CnName;
  1223. string title = $"系统通知";
  1224. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1225. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1226. }
  1227. #region 应用推送
  1228. try
  1229. {
  1230. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1231. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1232. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1233. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1234. {
  1235. var userList = new List<string>() { users.QiyeChatUserId };
  1236. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1237. }
  1238. }
  1239. catch (Exception ex)
  1240. {
  1241. }
  1242. #endregion
  1243. //默认创建倒推表
  1244. await _invertedListRep._Create(dto.UserId, diId);
  1245. }
  1246. if (dto.Status == 2)
  1247. {
  1248. diId = dto.Id;
  1249. if (diId == 0)
  1250. {
  1251. //_sqlSugar.RollbackTran();
  1252. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1253. }
  1254. }
  1255. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1256. if (viewData.Code != 0)
  1257. {
  1258. //_sqlSugar.RollbackTran();
  1259. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1260. }
  1261. #region 团组操作默认添加/修改收款账单
  1262. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1263. {
  1264. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1265. .Where(x => x.IsDel == 0 &&
  1266. x.Diid == diId &&
  1267. x.Remark.Equals("预付款")
  1268. )
  1269. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1270. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1271. .FirstAsync();
  1272. ffrInfo = new Fin_ForeignReceivables()
  1273. {
  1274. Diid = diId,
  1275. PriceName = dto.ClientUnit,
  1276. Price = dto.PaymentMoney,
  1277. Count = 1,
  1278. Unit = $"元",
  1279. ItemSumPrice = dto.PaymentMoney,
  1280. Rate = 1.0000M,
  1281. Currency = 836,
  1282. AddingWay = 0,
  1283. CreateUserId = dto.UserId,
  1284. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1285. Remark = $"预付款"
  1286. };
  1287. if (ffrInfo == null) //Add
  1288. {
  1289. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1290. }
  1291. else //修改
  1292. {
  1293. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1294. .UpdateColumns(x => new
  1295. {
  1296. x.PriceName,
  1297. x.Price,
  1298. x.ItemSumPrice,
  1299. x.CreateTime,
  1300. x.CreateUserId
  1301. })
  1302. .WhereColumns(x => x.Id)
  1303. .ExecuteCommandAsync();
  1304. }
  1305. }
  1306. #endregion
  1307. #region 签证人员团组时间通知
  1308. #region 计算出访起止时间
  1309. var startTime = new DateTime();
  1310. var endTime = new DateTime();
  1311. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1312. {
  1313. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1314. }
  1315. #endregion
  1316. if (diId > 0)
  1317. {
  1318. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1319. }
  1320. #endregion
  1321. //_sqlSugar.CommitTran();
  1322. return Ok(JsonView(true, "添加成功"));
  1323. }
  1324. catch (Exception ex)
  1325. {
  1326. _sqlSugar.RollbackTran();
  1327. return Ok(JsonView(false, ex.Message));
  1328. }
  1329. }
  1330. /// <summary>
  1331. /// 接团流程操作(增改)
  1332. /// 安卓端使用 建团时添加客户名单
  1333. /// </summary>
  1334. /// <param name="dto"></param>
  1335. /// <returns></returns>
  1336. [HttpPost]
  1337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1338. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1339. {
  1340. #region 参数验证
  1341. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1342. #region 页面操作权限验证
  1343. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1344. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1345. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1346. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1347. #endregion
  1348. #endregion
  1349. _sqlSugar.BeginTran();
  1350. decimal ffrPrice = 0.00M;
  1351. DateTime? visitDt = null;
  1352. if (dto.Status == 2)
  1353. {
  1354. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1355. if (groupInfo != null)
  1356. {
  1357. ffrPrice = groupInfo.PaymentMoney;
  1358. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1359. }
  1360. }
  1361. var _dto = new GroupOperationDto();
  1362. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1363. var groupData = await _groupRepository.GroupOperation(_dto);
  1364. if (groupData.Code != 0)
  1365. {
  1366. _sqlSugar.RollbackTran();
  1367. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1368. }
  1369. try
  1370. {
  1371. int diId = 0;
  1372. //添加时 默认加入团组汇率
  1373. if (dto.Status == 1) //添加
  1374. {
  1375. diId = groupData.Data;
  1376. //添加默认币种
  1377. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1378. //默认分配权限
  1379. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1380. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1381. var _managerIds = new List<int>() { 21, 22, 32 };
  1382. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1383. if (userIds.Count > 0)
  1384. {
  1385. userIds.Add(208);
  1386. //创建团组管控
  1387. GroupStepForDelegation.CreateWorkStep(diId);
  1388. //发送消息
  1389. string groupName = dto.TeamName;
  1390. string createGroupUser = string.Empty;
  1391. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1392. if (userInfo != null) createGroupUser = userInfo.CnName;
  1393. string title = $"系统通知";
  1394. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1395. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1396. }
  1397. #region 应用推送
  1398. try
  1399. {
  1400. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1401. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1402. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1403. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1404. {
  1405. var userList = new List<string>() { users.QiyeChatUserId };
  1406. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1407. }
  1408. }
  1409. catch (Exception ex)
  1410. {
  1411. _sqlSugar.CommitTran();
  1412. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1413. }
  1414. #endregion
  1415. //默认创建倒推表
  1416. await _invertedListRep._Create(dto.UserId, diId);
  1417. }
  1418. else if (dto.Status == 2)
  1419. {
  1420. diId = dto.Id;
  1421. if (diId == 0)
  1422. {
  1423. _sqlSugar.RollbackTran();
  1424. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1425. }
  1426. }
  1427. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1428. if (viewData.Code != 0)
  1429. {
  1430. _sqlSugar.RollbackTran();
  1431. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1432. }
  1433. #region 团组操作默认添加/修改收款账单
  1434. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1435. {
  1436. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1437. .Where(x => x.IsDel == 0 &&
  1438. x.Diid == diId &&
  1439. x.Remark.Equals("预付款")
  1440. )
  1441. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1442. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1443. .FirstAsync();
  1444. ffrInfo = new Fin_ForeignReceivables()
  1445. {
  1446. Diid = diId,
  1447. PriceName = dto.ClientUnit,
  1448. Price = dto.PaymentMoney,
  1449. Count = 1,
  1450. Unit = $"元",
  1451. ItemSumPrice = dto.PaymentMoney,
  1452. Rate = 1.0000M,
  1453. Currency = 836,
  1454. AddingWay = 0,
  1455. CreateUserId = dto.UserId,
  1456. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1457. Remark = $"预付款"
  1458. };
  1459. if (ffrInfo == null) //Add
  1460. {
  1461. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1462. }
  1463. else //修改
  1464. {
  1465. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1466. .UpdateColumns(x => new
  1467. {
  1468. x.PriceName,
  1469. x.Price,
  1470. x.ItemSumPrice,
  1471. x.CreateTime,
  1472. x.CreateUserId
  1473. })
  1474. .WhereColumns(x => x.Id)
  1475. .ExecuteCommandAsync();
  1476. }
  1477. }
  1478. #endregion
  1479. #region 签证人员团组时间通知
  1480. #region 计算出访起止时间
  1481. var startTime = new DateTime();
  1482. var endTime = new DateTime();
  1483. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1484. {
  1485. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1486. }
  1487. #endregion
  1488. if (diId > 0)
  1489. {
  1490. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1491. }
  1492. #endregion
  1493. _sqlSugar.CommitTran();
  1494. return Ok(JsonView(true));
  1495. }
  1496. catch (Exception ex)
  1497. {
  1498. _sqlSugar.RollbackTran();
  1499. return Ok(JsonView(false, ex.Message));
  1500. }
  1501. }
  1502. /// <summary>
  1503. /// 接团信息 操作(删除)
  1504. /// </summary>
  1505. /// <param name="dto"></param>
  1506. /// <returns></returns>
  1507. [HttpPost]
  1508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1509. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1510. {
  1511. var diId = dto.Id;
  1512. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1513. #region 删除 验证
  1514. /*
  1515. * 1、收款账单数据:0 条
  1516. * 2、收款退还数据:0 条
  1517. * 3、机票费用数据:0 条
  1518. * 4、签证费用数据:0 条
  1519. * 5、保险费用数据:0 条
  1520. * 6、酒店费用数据:0 条
  1521. * 7、公务出访数据:1 条
  1522. * 8、邀请公务活动费用数据:1 条
  1523. * 9、OP费用数据:5 条
  1524. * 10、其他费用数据:0 条
  1525. * 11、团组日付报销费用数据:0 条
  1526. *
  1527. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1528. */
  1529. //收款账单
  1530. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1531. //收款退还
  1532. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1533. //机票费用
  1534. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1535. //签证费用
  1536. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1537. //保险费用
  1538. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1539. //酒店费用
  1540. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1541. //公务出访
  1542. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1543. //邀请公务活动费用
  1544. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1545. //OP费用
  1546. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1547. //其他费用
  1548. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1549. //团组日付报销费用
  1550. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1551. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1552. if (feeCount > 0)
  1553. {
  1554. var delMsgTips = new StringBuilder();
  1555. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1556. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1557. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1558. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1559. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1560. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1561. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1562. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1563. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1564. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1565. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1566. delMsgTips.AppendLine($"");
  1567. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1568. return Ok(JsonView(false, delMsgTips.ToString()));
  1569. }
  1570. #endregion
  1571. var groupData = await _groupRepository.GroupDel(dto);
  1572. if (groupData.Code != 0)
  1573. {
  1574. return Ok(JsonView(false, groupData.Msg));
  1575. }
  1576. return Ok(JsonView(true));
  1577. }
  1578. /// <summary>
  1579. /// 获取团组销售报价号
  1580. /// 团组添加时 使用
  1581. /// </summary>
  1582. /// <returns></returns>
  1583. [HttpPost]
  1584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1585. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1586. {
  1587. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1588. if (groupData.Code != 0)
  1589. {
  1590. return Ok(JsonView(false, groupData.Msg));
  1591. }
  1592. object salesQuoteNo = new
  1593. {
  1594. SalesQuoteNo = groupData.Data
  1595. };
  1596. return Ok(JsonView(salesQuoteNo));
  1597. }
  1598. /// <summary>
  1599. /// 设置确认出团
  1600. /// </summary>
  1601. /// <param name="dto"></param>
  1602. /// <returns></returns>
  1603. [HttpPost]
  1604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1605. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1606. {
  1607. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1608. if (groupData.Code != 0)
  1609. {
  1610. return Ok(JsonView(false, groupData.Msg));
  1611. }
  1612. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1613. #region OA消息推送
  1614. try
  1615. {
  1616. string groupName = groupInfo.TeamName;
  1617. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1618. string title = $"系统通知";
  1619. string content = $"团组[{groupName}]已确认出团!";
  1620. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1621. }
  1622. catch (Exception ex)
  1623. {
  1624. }
  1625. #endregion
  1626. #region 应用推送
  1627. try
  1628. {
  1629. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1630. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1631. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1632. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1633. {
  1634. var userList = new List<string>() { users.QiyeChatUserId };
  1635. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1636. }
  1637. }
  1638. catch (Exception ex)
  1639. {
  1640. }
  1641. #endregion
  1642. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1643. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1644. }
  1645. /// <summary>
  1646. /// 获取团组名称data And 签证国别Data
  1647. /// </summary>
  1648. /// <param name="dto"></param>
  1649. /// <returns></returns>
  1650. [HttpPost]
  1651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1652. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1653. {
  1654. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1655. if (groupData.Code != 0)
  1656. {
  1657. return Ok(JsonView(false, groupData.Msg));
  1658. }
  1659. return Ok(JsonView(groupData.Data));
  1660. }
  1661. /// <summary>
  1662. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1663. /// </summary>
  1664. /// <returns></returns>
  1665. [HttpPost]
  1666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1667. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1668. {
  1669. try
  1670. {
  1671. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1672. if (groupData.Code != 0)
  1673. {
  1674. return Ok(JsonView(false, groupData.Msg));
  1675. }
  1676. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1677. }
  1678. catch (Exception ex)
  1679. {
  1680. return Ok(JsonView(false, ex.Message));
  1681. throw;
  1682. }
  1683. }
  1684. /// <summary>
  1685. /// 团组清单 Excel
  1686. /// </summary>
  1687. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1688. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1689. /// <returns></returns>
  1690. [HttpGet]
  1691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1692. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1693. {
  1694. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1695. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1696. if (!beginBool && !endBool)
  1697. {
  1698. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1699. }
  1700. string sql = string.Format(@"
  1701. SELECT
  1702. ROW_NUMBER,
  1703. Id,
  1704. SalesQuoteNo,
  1705. TourCode,
  1706. TeamTypeId,
  1707. TeamType,
  1708. TeamLevId,
  1709. TeamLev,
  1710. TeamName,
  1711. ClientName,
  1712. ClientUnit,
  1713. VisitDate,
  1714. VisitDays,
  1715. VisitPNumber,
  1716. JietuanOperatorId,
  1717. JietuanOperator,
  1718. IsSure,
  1719. CreateUserName,
  1720. IsBid
  1721. FROM
  1722. (
  1723. SELECT
  1724. ROW_NUMBER() OVER(
  1725. ORDER BY
  1726. gdi.VisitDate Desc
  1727. ) AS ROW_NUMBER,
  1728. gdi.Id,
  1729. SalesQuoteNo,
  1730. TourCode,
  1731. ssd.Id TeamTypeId,
  1732. ssd.Name TeamType,
  1733. ssd1.Id TeamLevId,
  1734. ssd1.Name TeamLev,
  1735. TeamName,
  1736. ClientName,
  1737. ClientUnit,
  1738. VisitDate,
  1739. VisitDays,
  1740. VisitPNumber,
  1741. JietuanOperator JietuanOperatorId,
  1742. su.CnName JietuanOperator,
  1743. IsSure,
  1744. gdi.CreateTime,
  1745. su1.CnName As CreateUserName,
  1746. gdi.IsBid
  1747. FROM
  1748. Grp_DelegationInfo gdi
  1749. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1750. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1751. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1752. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1753. WHERE
  1754. gdi.IsDel = 0
  1755. AND gdi.IsBid = 0
  1756. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1757. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1758. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1759. #region 处理所属部门
  1760. /*
  1761. * 1.sq 和 gyy 等显示 市场部
  1762. * 2.王鸽和主管及张总还有管理员号统一国交部
  1763. * 2-1. 4 管理员 ,21 张海麟
  1764. */
  1765. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1766. var userIds1 = new List<int>() { 4, 21 };
  1767. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1768. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1769. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1770. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1771. .ToListAsync();
  1772. var droupIds = groupList.Select(it => it.Id).ToList();
  1773. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1774. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1775. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1776. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1777. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1778. {
  1779. DiId = tcl.DiId,
  1780. LastName = dc.LastName,
  1781. FirstName = dc.FirstName,
  1782. Sex = dc.Sex,
  1783. Birthday = dc.BirthDay,
  1784. Company = cc.CompanyFullName,
  1785. Job = dc.Job,
  1786. CreateTime = tcl.CreateTime,
  1787. })
  1788. .ToList();
  1789. foreach (var item in groupList)
  1790. {
  1791. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1792. string groupFirstName = "";
  1793. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1794. if (currDatas.Any())
  1795. {
  1796. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1797. }
  1798. item.GroupFirst = groupFirstName;
  1799. }
  1800. #endregion
  1801. #region Excel
  1802. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1803. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1804. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1805. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1806. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1807. //载入模板
  1808. var designer = new WorkbookDesigner
  1809. {
  1810. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1811. };
  1812. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1813. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1814. dt.TableName = "GroupList";
  1815. designer.SetDataSource(dt);
  1816. designer.Process();
  1817. if (!Directory.Exists(savePath))
  1818. {
  1819. Directory.CreateDirectory(savePath);
  1820. }
  1821. string serverPath = $"{savePath}{fileName}";
  1822. designer.Workbook.Save(serverPath);
  1823. string rst = $"{servicePath}{ftpPath}{fileName}";
  1824. #endregion
  1825. return Ok(JsonView(true, "操作成功!", rst));
  1826. }
  1827. /// <summary>
  1828. /// 团组合同下载(1.付款80% 2.付全款)
  1829. /// </summary>
  1830. /// <param name="dto"></param>
  1831. /// <returns></returns>
  1832. /// <exception cref="Exception"></exception>
  1833. [HttpPost]
  1834. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1835. {
  1836. var jw = JsonView(false);
  1837. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1838. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1839. if (di == null)
  1840. {
  1841. jw.Msg = "团组Id有误!";
  1842. return Ok(jw);
  1843. }
  1844. #region 权限校验
  1845. var allDownFile = new List<int>() { 21 };
  1846. try
  1847. {
  1848. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1849. .First(x => x.Id == 1418 && x.IsDel == 0);
  1850. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1851. }
  1852. catch (Exception)
  1853. { }
  1854. var guojiaoDownFile = new List<int>() { 330 };
  1855. var shichangDownFile = new List<int>() { 95 };
  1856. if (allDownFile.Contains(dto.UserId))
  1857. {
  1858. }
  1859. else if (guojiaoDownFile.Contains(dto.UserId))
  1860. {
  1861. var guojiaobuDi = new List<int>() { 4, 21 };
  1862. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1863. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1864. .Where((d, u) => u.Id == di.JietuanOperator)
  1865. .Select((d, u) => d.DepName)
  1866. .First();
  1867. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1868. {
  1869. jw.Msg = "暂无下载权限!";
  1870. return Ok(jw);
  1871. }
  1872. }
  1873. else if (shichangDownFile.Contains(dto.UserId))
  1874. {
  1875. var dic = new Dictionary<int, int[]>()
  1876. {
  1877. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1878. };
  1879. try
  1880. {
  1881. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1882. if (sqSetting != null)
  1883. {
  1884. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1885. foreach (var item in result.Keys)
  1886. {
  1887. if (dic.ContainsKey(item))
  1888. {
  1889. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1890. Array.Copy(dic[item], dilatation, dic[item].Length);
  1891. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1892. dic[item] = dilatation;
  1893. }
  1894. else
  1895. {
  1896. dic.Add(item, result[item]);
  1897. }
  1898. }
  1899. }
  1900. if (!dic[95].Contains(di.CreateUserId))
  1901. {
  1902. jw.Msg = "暂无下载权限!";
  1903. return Ok(jw);
  1904. }
  1905. }
  1906. catch (Exception)
  1907. { }
  1908. }
  1909. else if (dto.UserId == di.CreateUserId)
  1910. {
  1911. }
  1912. else
  1913. {
  1914. jw.Msg = "暂无下载权限!";
  1915. return Ok(jw);
  1916. }
  1917. #endregion
  1918. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1919. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1920. .ToListAsync();
  1921. if (!blackCodeList.Any())
  1922. {
  1923. jw.Msg = "该团无机票行程代码!";
  1924. return Ok(jw);
  1925. }
  1926. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1927. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1928. if (groupEnterExitCost == null)
  1929. {
  1930. jw.Msg = "暂无三公费用信息!";
  1931. return Ok(jw);
  1932. }
  1933. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1934. rateList ??= new List<CurrencyInfo>();
  1935. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1936. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1937. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1938. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1939. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1940. .Select((x, a, b) => new
  1941. {
  1942. x.Index,
  1943. itemName = a.Name,
  1944. CurrencyStr = b.Name,
  1945. x.Cost,
  1946. x.SubTotal,
  1947. x.Remark
  1948. })
  1949. .OrderBy((x) => x.Index)
  1950. .ToList();
  1951. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1952. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1953. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1954. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1955. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1956. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1957. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1958. decimal subJJC = 0.00M,
  1959. subGWC = 0.00M,
  1960. subTDC = 0.00M;
  1961. //经济舱
  1962. if (groupEnterExitCost.SumJJC == 1)
  1963. {
  1964. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1965. }
  1966. //公务舱
  1967. if (groupEnterExitCost.SumGWC == 1)
  1968. {
  1969. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1970. }
  1971. //头等舱
  1972. if (groupEnterExitCost.SumTDC == 1)
  1973. {
  1974. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1975. }
  1976. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1977. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1978. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1979. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1980. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1981. .Select((x, s, dc, cc) => new GroupClints
  1982. {
  1983. Id = x.Id,
  1984. Name = s.Name,
  1985. IsAccompany = x.IsAccompany,
  1986. CompanyFullName = cc.CompanyFullName
  1987. })
  1988. .ToListAsync();
  1989. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1990. //获取舱位人数
  1991. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1992. .GroupBy(x => x.Name)
  1993. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1994. .ToList();
  1995. string cityPath = string.Empty;
  1996. string startCity = string.Empty;
  1997. string endCity = string.Empty;
  1998. foreach (var item in blackCodeList)
  1999. {
  2000. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2001. cityPath += city + "\r\n";
  2002. if (item.Equals(blackCodeList.First()))
  2003. {
  2004. var sp = city.Split('-');
  2005. startCity = sp[0];
  2006. endCity = sp[^1];
  2007. }
  2008. }
  2009. var bookMarkDic = new Dictionary<string, string>
  2010. {
  2011. { "ClientUnit", di.ClientUnit },
  2012. { "VisitCountry", di.VisitCountry },
  2013. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2014. { "VisitPNumber", di.VisitPNumber.ToString() },
  2015. { "CityPath", cityPath },
  2016. { "StartCity", startCity },
  2017. { "EndCity", endCity },
  2018. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2019. };
  2020. Document doc = null;
  2021. var percentage = 0.8M;
  2022. var fileNameadd = "预付";
  2023. if (dto.FileType == 1)
  2024. {
  2025. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2026. }
  2027. else if (dto.FileType == 2)
  2028. {
  2029. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2030. percentage = 1;
  2031. fileNameadd = "全款";
  2032. }
  2033. else
  2034. {
  2035. throw new Exception("FileType有误!");
  2036. }
  2037. var builder = new DocumentBuilder(doc);
  2038. decimal totalPrice = 0.00M;
  2039. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2040. if (firstTable != null)
  2041. {
  2042. // 遍历表格的行和单元格
  2043. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2044. {
  2045. for (int i = 0; i < row.Cells.Count; i++)
  2046. {
  2047. var cell = row.Cells[i];
  2048. // 读取单元格内容
  2049. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2050. if (cellTextFirst.Contains("舱位"))
  2051. {
  2052. break;
  2053. }
  2054. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2055. {
  2056. if (i == 2)
  2057. {
  2058. if (cellTextFirst == "经济舱")
  2059. {
  2060. // 设置单元格内容
  2061. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2062. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2063. }
  2064. else
  2065. {
  2066. // 设置单元格内容
  2067. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2068. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2069. }
  2070. }
  2071. if (i == 3)
  2072. {
  2073. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2074. if (count != null)
  2075. {
  2076. // 设置单元格内容
  2077. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2078. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2079. }
  2080. }
  2081. if (i == 4)
  2082. {
  2083. var rowPrice = 0.00M;
  2084. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2085. count ??= 0;
  2086. if (cellTextFirst == "经济舱")
  2087. {
  2088. rowPrice = subJJC * (int)count;
  2089. }
  2090. else
  2091. {
  2092. rowPrice = subGWC * (int)count;
  2093. }
  2094. totalPrice += rowPrice;
  2095. // 设置单元格内容
  2096. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2097. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2098. }
  2099. }
  2100. }
  2101. }
  2102. }
  2103. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2104. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2105. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2106. //--合同表格部分
  2107. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2108. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2109. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2110. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2111. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2112. bookMarkDic.Add("CityPath1", cityPath);
  2113. bookMarkDic.Add("CityPath2", cityPath);
  2114. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2115. if (contractTable != null)
  2116. {
  2117. //数据源
  2118. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2119. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2120. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2121. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2122. .Select((it, y, s) => new
  2123. {
  2124. it.Cost,
  2125. it.SubTotal,
  2126. it.Type,
  2127. y.Id,
  2128. y.City,
  2129. s.Name,
  2130. CurrencyCodeCn = s.Remark
  2131. })
  2132. .ToList()
  2133. .Select(x => new
  2134. {
  2135. CurrencyCode = x.Name,
  2136. CityId = x.Id,
  2137. x.City,
  2138. di.VisitPNumber,
  2139. x.Type,
  2140. x.Cost,
  2141. x.SubTotal,
  2142. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2143. x.CurrencyCodeCn,
  2144. });
  2145. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2146. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2147. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2148. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2149. var tableSettings = new List<tableSetting>()
  2150. {
  2151. new(){ Index = 1 , Property = "City"},
  2152. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2153. new(){ Index = 3 , Property = "Cost"},
  2154. new(){ Index = 4 , Property = "VisitPNumber"},
  2155. //new tableSetting{ Index = 5 , Property = ""},
  2156. //new tableSetting{ Index = 6 , Property = ""},
  2157. new(){ Index = 7 , Property = "Rate"},
  2158. //new tableSetting{ Index = 8 , Property = ""},
  2159. };
  2160. //1.住宿费
  2161. int cloneRow = 8;
  2162. int startDayPrice = 8; //写入index
  2163. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2164. foreach (var dac in dac1)
  2165. {
  2166. var first = dac.First();
  2167. var dayCount = dac.Count();
  2168. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2169. for (int i = 1; i < row.Cells.Count; i++)
  2170. {
  2171. var cell = row.Cells[i];
  2172. var findProperty = tableSettings.Find(x => x.Index == i);
  2173. if (findProperty != null)
  2174. {
  2175. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2176. // 设置单元格内容
  2177. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2178. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2179. }
  2180. else
  2181. {
  2182. switch (i)
  2183. {
  2184. case 5:
  2185. cell.FirstParagraph.Runs.Clear();
  2186. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2187. break;
  2188. case 6:
  2189. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2190. cell.FirstParagraph.Runs.Clear();
  2191. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2192. break;
  2193. case 8:
  2194. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2195. cell.FirstParagraph.Runs.Clear();
  2196. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2197. ZSPriceSum += xiaojiRMB;
  2198. break;
  2199. default:
  2200. break;
  2201. }
  2202. }
  2203. }
  2204. startDayPrice++;
  2205. if (!dac1.Last().Equals(dac))
  2206. {
  2207. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2208. // 将克隆的行追加到原行后面
  2209. contractTable.Rows.Insert(startDayPrice, newRow);
  2210. }
  2211. else
  2212. {
  2213. cloneRow += dac1.Count + 1;
  2214. startDayPrice = cloneRow;
  2215. }
  2216. }
  2217. //2.伙食费
  2218. foreach (var dac in dac2)
  2219. {
  2220. var first = dac.First();
  2221. var dayCount = dac.Count();
  2222. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2223. for (int i = 1; i < row.Cells.Count; i++)
  2224. {
  2225. var cell = row.Cells[i];
  2226. var findProperty = tableSettings.Find(x => x.Index == i);
  2227. if (findProperty != null)
  2228. {
  2229. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2230. // 设置单元格内容
  2231. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2232. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2233. }
  2234. else
  2235. {
  2236. switch (i)
  2237. {
  2238. case 5:
  2239. cell.FirstParagraph.Runs.Clear();
  2240. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2241. break;
  2242. case 6:
  2243. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2244. cell.FirstParagraph.Runs.Clear();
  2245. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2246. break;
  2247. case 8:
  2248. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2249. cell.FirstParagraph.Runs.Clear();
  2250. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2251. HSPriceSum += xiaojiRMB;
  2252. break;
  2253. default:
  2254. break;
  2255. }
  2256. }
  2257. }
  2258. startDayPrice++;
  2259. if (!dac2.Last().Equals(dac))
  2260. {
  2261. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2262. // 将克隆的行追加到原行后面
  2263. contractTable.Rows.Insert(startDayPrice, newRow);
  2264. }
  2265. else
  2266. {
  2267. cloneRow += dac2.Count + 1;
  2268. startDayPrice = cloneRow;
  2269. }
  2270. }
  2271. //3.公杂费
  2272. foreach (var dac in dac3)
  2273. {
  2274. var first = dac.First();
  2275. var dayCount = dac.Count();
  2276. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2277. for (int i = 1; i < row.Cells.Count; i++)
  2278. {
  2279. var cell = row.Cells[i];
  2280. var findProperty = tableSettings.Find(x => x.Index == i);
  2281. if (findProperty != null)
  2282. {
  2283. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2284. // 设置单元格内容
  2285. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2286. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2287. }
  2288. else
  2289. {
  2290. switch (i)
  2291. {
  2292. case 5:
  2293. cell.FirstParagraph.Runs.Clear();
  2294. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2295. break;
  2296. case 6:
  2297. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2298. cell.FirstParagraph.Runs.Clear();
  2299. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2300. break;
  2301. case 8:
  2302. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2303. cell.FirstParagraph.Runs.Clear();
  2304. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2305. GZPriceSum += xiaojiRMB;
  2306. break;
  2307. default:
  2308. break;
  2309. }
  2310. }
  2311. }
  2312. startDayPrice++;
  2313. if (!dac3.Last().Equals(dac))
  2314. {
  2315. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2316. // 将克隆的行追加到原行后面
  2317. contractTable.Rows.Insert(startDayPrice, newRow);
  2318. }
  2319. else
  2320. {
  2321. cloneRow += dac3.Count + 1;
  2322. startDayPrice = cloneRow;
  2323. }
  2324. }
  2325. //合并单元格
  2326. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2327. {
  2328. var currentRow = contractTable.Rows[i];
  2329. var nextRow = contractTable.Rows[i + 1];
  2330. // 获取当前行和下一行的第一个单元格
  2331. Cell currentCell = currentRow.Cells[0];
  2332. Cell nextCell = nextRow.Cells[0];
  2333. // 检查单元格内容是否一致(去除尾部的换行符)
  2334. string currentText = currentCell.GetText().Trim();
  2335. string nextText = nextCell.GetText().Trim();
  2336. if (currentText == nextText)
  2337. {
  2338. // 如果当前单元格已经被合并,找到合并的起始单元格
  2339. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2340. {
  2341. // 找到合并的起始单元格
  2342. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2343. // 将下一行的单元格设置为合并的后续单元格
  2344. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2345. }
  2346. else
  2347. {
  2348. // 如果当前单元格是合并的起始单元格
  2349. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2350. // 将下一行的单元格设置为合并的后续单元格
  2351. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2352. }
  2353. }
  2354. else
  2355. {
  2356. // 如果内容不一致,重置当前单元格的合并属性
  2357. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2358. {
  2359. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2360. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2361. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2362. }
  2363. else
  2364. {
  2365. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2366. }
  2367. }
  2368. }
  2369. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2370. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2371. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2372. }
  2373. foreach (var bookmarkName in bookMarkDic.Keys)
  2374. {
  2375. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2376. if (bookmark != null)
  2377. {
  2378. if (bookmarkName == "ClientUnit")
  2379. {
  2380. // 移动到书签位置
  2381. builder.MoveTo(bookmark.BookmarkStart);
  2382. // 设置字体样式为下划线
  2383. builder.Font.Underline = Aspose.Words.Underline.Single;
  2384. // 插入书签值
  2385. builder.Write(bookMarkDic[bookmarkName]);
  2386. // 清除字体格式,避免影响后续文本
  2387. builder.Font.ClearFormatting();
  2388. }
  2389. else
  2390. {
  2391. builder.MoveToBookmark(bookmarkName);
  2392. builder.Write(bookMarkDic[bookmarkName]);
  2393. }
  2394. }
  2395. }
  2396. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2397. doc.Save(savePaht);
  2398. jw.Msg = "生成成功!";
  2399. jw.Code = 200;
  2400. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2401. return Ok(jw);
  2402. }
  2403. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2404. {
  2405. int index = rowIndex;
  2406. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2407. {
  2408. index--;
  2409. }
  2410. return index;
  2411. }
  2412. #endregion
  2413. #region 团组&签证
  2414. #region 团组&签证 New
  2415. /// <summary>
  2416. /// 团组&签证 New
  2417. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2418. /// </summary>
  2419. /// <param name="file">请求dto</param>
  2420. /// <returns></returns>
  2421. [HttpPost]
  2422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2423. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile file, int fileTypeId)
  2424. {
  2425. //文件验证
  2426. if (file.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2427. //var visaFiles = new VisaUploadFileTypeView();
  2428. var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2429. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2430. //服务器存储文件
  2431. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2432. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2433. var filePath = Path.Combine(fileServerPath, file.FileName);
  2434. using (var stream = new FileStream(filePath, FileMode.Create))
  2435. {
  2436. await file.CopyToAsync(stream);
  2437. }
  2438. //日志记录-上传文件
  2439. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, file.FileName);
  2440. //kimi AI 识别文档返回json结果
  2441. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2442. var KiMiApi = new KiMiApiClient();
  2443. var files = new List<IFormFile>() { file };
  2444. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2445. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2446. var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2447. var messages = new List<SeedMessages>
  2448. {
  2449. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2450. new() { Role = KimiRole.user, Content = seedMessage }
  2451. };
  2452. messages.InsertRange(1, seedConter);
  2453. string jsonString = string.Empty;
  2454. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2455. while (!isJson)
  2456. {
  2457. kimiAI_API_Index++;
  2458. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2459. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2460. jsonString += kimiApiResult_JObject["content"].ToString();
  2461. string startStr = "```json", endStr = "```";
  2462. // 判断并清除开头部分
  2463. if (jsonString.StartsWith(startStr))
  2464. {
  2465. jsonString = jsonString.Replace(startStr, "");
  2466. }
  2467. // 判断并清除结尾部分
  2468. if (jsonString.EndsWith(endStr))
  2469. {
  2470. jsonString = jsonString.Replace(endStr, "");
  2471. }
  2472. //验证json格式是否正确
  2473. try
  2474. {
  2475. JsonDocument.Parse(jsonString);
  2476. isJson = true; // 如果解析成功,则是json格式
  2477. }
  2478. catch (Exception)
  2479. {
  2480. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2481. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2482. }
  2483. }
  2484. var clientInfo = new Crm_DeleClient(); //客户资料表
  2485. var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2486. var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2487. var clientCert = new Crm_CustomerCert(); //客户证件表
  2488. var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2489. //按照表格类型分别进行参数处理
  2490. switch (fileTypeId)
  2491. {
  2492. //澳新签证个人申请表
  2493. case 1:
  2494. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2495. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2496. break;
  2497. default:
  2498. break;
  2499. }
  2500. return Ok(JsonView(true, jsonString));
  2501. }
  2502. #endregion
  2503. /// <summary>
  2504. /// 根据团组Id获取签证客户信息List
  2505. /// </summary>
  2506. /// <param name="dto">请求dto</param>
  2507. /// <returns></returns>
  2508. [HttpPost]
  2509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2510. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2511. {
  2512. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2513. if (groupData.Code != 0)
  2514. {
  2515. return Ok(JsonView(false, groupData.Msg));
  2516. }
  2517. return Ok(JsonView(groupData.Data));
  2518. }
  2519. /// <summary>
  2520. /// IOS获取团组签证拍照上传进度01(团组列表)
  2521. /// </summary>
  2522. /// <param name="dto">请求dto</param>
  2523. /// <returns></returns>
  2524. [HttpPost]
  2525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2526. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2527. {
  2528. if (dto == null)
  2529. {
  2530. return Ok(JsonView(false, "参数为空"));
  2531. }
  2532. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2533. return Ok(JsonView(visaList));
  2534. }
  2535. /// <summary>
  2536. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2537. /// </summary>
  2538. /// <returns></returns>
  2539. [HttpPost]
  2540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2541. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2542. {
  2543. if (dto == null)
  2544. {
  2545. return Ok(JsonView(false, "请求错误:"));
  2546. }
  2547. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2548. return Ok(JsonView(list));
  2549. }
  2550. /// <summary>
  2551. /// IOS获取团组签证拍照上传进度03(相册)
  2552. /// </summary>
  2553. /// <returns></returns>
  2554. [HttpPost]
  2555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2556. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2557. {
  2558. if (dto == null)
  2559. {
  2560. return Ok(JsonView(false, "请求错误:"));
  2561. }
  2562. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2563. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2564. list.ForEach(s => s.url = url);
  2565. return Ok(JsonView(list));
  2566. }
  2567. /// <summary>
  2568. /// IOS获取团组签证拍照上传进度04(图片上传)
  2569. /// </summary>
  2570. /// <param name="dto"></param>
  2571. /// <returns></returns>
  2572. [HttpPost]
  2573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2574. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2575. {
  2576. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2577. //if (!string.IsNullOrEmpty(result))
  2578. //{
  2579. //}
  2580. //else {
  2581. // return Ok(JsonView(false, "上传失败"));
  2582. //}
  2583. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2584. int sucNum = 0;
  2585. try
  2586. {
  2587. foreach (var item in dto.base64DataList)
  2588. {
  2589. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2590. string result = DecodeBase64ToImage(item, imageName);
  2591. if (!string.IsNullOrEmpty(result))
  2592. {
  2593. var pic = new Grp_VisaProgressCustomerPicture
  2594. {
  2595. CreateUserId = dto.CreateUserId,
  2596. PicName = imageName,
  2597. PicPath = result,
  2598. VisaProgressCustomerId = dto.visaProgressCustomerId
  2599. };
  2600. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2601. if (insertResult > 0)
  2602. {
  2603. sucNum++;
  2604. }
  2605. }
  2606. }
  2607. }
  2608. catch (Exception ex)
  2609. {
  2610. return Ok(JsonView(false, ex.Message));
  2611. }
  2612. string msg = string.Format(@"成功上传{0}张", sucNum);
  2613. return Ok(JsonView(true, msg));
  2614. }
  2615. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2616. {
  2617. string filename = "";//声明一个string类型的相对路径
  2618. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2619. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2620. try//会有异常抛出,try,catch一下
  2621. {
  2622. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2623. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2624. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2625. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2626. //文件名称
  2627. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2628. //上传的文件的路径
  2629. string filePath = "";
  2630. if (!Directory.Exists(fileDir))
  2631. {
  2632. Directory.CreateDirectory(fileDir);
  2633. }
  2634. //上传的文件的路径
  2635. filePath = fileDir + filename;
  2636. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2637. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2638. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2639. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2640. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2641. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2642. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2643. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2644. bitmap.Dispose();
  2645. }
  2646. catch (Exception e)
  2647. {
  2648. string massage = e.Message;
  2649. Logs("IOS图片上传Error:" + massage);
  2650. //filename = e.Message;
  2651. }
  2652. return filename;//返回相对路径
  2653. }
  2654. /// <summary>
  2655. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2656. /// </summary>
  2657. /// <param name="dto"></param>
  2658. /// <returns></returns>
  2659. [HttpPost]
  2660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2661. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2662. {
  2663. if (dto == null)
  2664. {
  2665. return Ok(JsonView(false, "请求错误:"));
  2666. }
  2667. string msg = "参数错误";
  2668. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2669. {
  2670. try
  2671. {
  2672. //_delegationVisaRep.BeginTran();
  2673. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2674. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2675. .Where(s => s.Id == dto.visaProgressCustomerId)
  2676. .ExecuteCommandAsync();
  2677. if (updCount > 0 && dto.publishCode == 1)
  2678. {
  2679. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2680. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2681. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2682. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2683. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2684. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2685. if (groupData == null)
  2686. {
  2687. _delegationVisaRep.RollbackTran();
  2688. }
  2689. string title = string.Format(@"[签证进度更新]");
  2690. string content = string.Format(@"测试文本");
  2691. bool rst = await _message.AddMsg(new MessageDto()
  2692. {
  2693. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2694. IssuerId = dto.publisher,
  2695. Title = title,
  2696. Content = content,
  2697. ReleaseTime = DateTime.Now,
  2698. UIdList = new List<int> {
  2699. 234
  2700. }
  2701. });
  2702. if (rst)
  2703. {
  2704. return Ok(JsonView(true, "发送通知成功"));
  2705. }
  2706. }
  2707. //_delegationVisaRep.CommitTran();
  2708. }
  2709. catch (Exception)
  2710. {
  2711. //_delegationVisaRep.RollbackTran();
  2712. }
  2713. }
  2714. return Ok(JsonView(true, msg));
  2715. }
  2716. #endregion
  2717. #region 团组任务分配
  2718. /// <summary>
  2719. /// 团组任务分配初始化
  2720. /// </summary>
  2721. /// <returns></returns>
  2722. [HttpPost]
  2723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2724. public async Task<IActionResult> GetTaskAssignmen()
  2725. {
  2726. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2727. if (groupData.Code != 0)
  2728. {
  2729. return Ok(JsonView(false, groupData.Msg));
  2730. }
  2731. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2732. }
  2733. /// <summary>
  2734. /// 团组任务分配查询
  2735. /// </summary>
  2736. /// <param name="dto"></param>
  2737. /// <returns></returns>
  2738. [HttpPost]
  2739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2740. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2741. {
  2742. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2743. if (groupData.Code != 0)
  2744. {
  2745. return Ok(JsonView(false, groupData.Msg));
  2746. }
  2747. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2748. }
  2749. /// <summary>
  2750. /// 团组任务分配操作
  2751. /// </summary>
  2752. /// <param name="dto"></param>
  2753. /// <returns></returns>
  2754. [HttpPost]
  2755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2756. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2757. {
  2758. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2759. if (groupData.Code != 0)
  2760. {
  2761. return Ok(JsonView(false, groupData.Msg));
  2762. }
  2763. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2764. }
  2765. /// <summary>
  2766. /// 团组任务分配
  2767. /// 批量分配
  2768. /// 查询团组
  2769. /// </summary>
  2770. /// <param name="dto"></param>
  2771. /// <returns></returns>
  2772. [HttpPost]
  2773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2774. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2775. {
  2776. //参数验证
  2777. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2778. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2779. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2780. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2781. }
  2782. /// <summary>
  2783. /// 团组任务分配
  2784. /// 批量分配
  2785. /// </summary>
  2786. /// <param name="dto"></param>
  2787. /// <returns></returns>
  2788. [HttpPost]
  2789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2790. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2791. {
  2792. //参数验证
  2793. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2794. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2795. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2796. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2797. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2798. }
  2799. #endregion
  2800. #region 团组费用审核
  2801. /// <summary>
  2802. /// 费用审核
  2803. /// 团组列表 Page
  2804. /// </summary>
  2805. /// <param name="_dto">团组列表请求dto</param>
  2806. /// <returns></returns>
  2807. [HttpPost]
  2808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2809. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2810. {
  2811. #region 参数验证
  2812. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2813. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2814. #region 页面操作权限验证
  2815. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2816. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2817. #endregion
  2818. #endregion
  2819. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2820. {
  2821. string sqlWhere = string.Empty;
  2822. if (_dto.IsSure == 0) //未完成
  2823. {
  2824. sqlWhere += string.Format(@" And IsSure = 0");
  2825. }
  2826. else if (_dto.IsSure == 1) //已完成
  2827. {
  2828. sqlWhere += string.Format(@" And IsSure = 1");
  2829. }
  2830. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2831. {
  2832. string tj = _dto.SearchCriteria;
  2833. 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}%')",
  2834. tj, tj, tj, tj, tj);
  2835. }
  2836. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2837. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2838. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2839. From (
  2840. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2841. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2842. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2843. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2844. From Grp_DelegationInfo gdi
  2845. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2846. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2847. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2848. Where gdi.IsDel = 0 {0}
  2849. ) temp ", sqlWhere);
  2850. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2851. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2852. var _view = new
  2853. {
  2854. PageFuncAuth = pageFunAuthView,
  2855. Data = _DelegationList
  2856. };
  2857. return Ok(JsonView(true, "查询成功!", _view, total));
  2858. }
  2859. else
  2860. {
  2861. return Ok(JsonView(false, "查询失败"));
  2862. }
  2863. }
  2864. /// <summary>
  2865. /// 获取团组费用审核
  2866. /// </summary>
  2867. /// <param name="_dto"></param>
  2868. /// <returns></returns>
  2869. [HttpPost]
  2870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2871. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2872. {
  2873. try
  2874. {
  2875. #region 参数验证
  2876. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2877. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2878. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2879. #region 页面操作权限验证
  2880. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2881. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2882. #endregion
  2883. #endregion
  2884. var _view = new Grp_CreditCardPaymentView();
  2885. var clientNameList = GetSimplClientList(_dto.DiId);
  2886. #region 费用清单
  2887. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2888. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2889. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2890. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2891. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2892. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2893. /*
  2894. * 76://酒店预订
  2895. */
  2896. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2897. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2898. /*
  2899. * 79://车/导游地接
  2900. */
  2901. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2902. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2903. /*
  2904. * 80: //签证
  2905. */
  2906. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2907. /*
  2908. *81: //邀请/公务活动
  2909. */
  2910. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2911. /*
  2912. * 82: //团组客户保险
  2913. */
  2914. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2915. /*
  2916. * Lable = 85 机票预订
  2917. */
  2918. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2919. /*
  2920. * 85 机票预定
  2921. */
  2922. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2923. /*
  2924. * 98 其他款项
  2925. */
  2926. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2927. /*
  2928. * 285:收款退还
  2929. */
  2930. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2931. /*
  2932. * 1015: //超支费用
  2933. */
  2934. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2935. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2936. /*
  2937. * 币种信息
  2938. */
  2939. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2940. /*
  2941. * 车/导游地接 费用类型
  2942. */
  2943. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2944. /*
  2945. * 车/导游地接 费用类型
  2946. */
  2947. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2948. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2949. /*
  2950. * 用户信息
  2951. */
  2952. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2953. /*
  2954. * 费用模块
  2955. */
  2956. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2957. string priceModule = string.Empty;
  2958. if (sdPriceName != null)
  2959. {
  2960. priceModule = sdPriceName.Name;
  2961. }
  2962. /*
  2963. * 成本信息
  2964. */
  2965. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2966. decimal _groupRate = 0.0000M;
  2967. string _groupCurrencyCode = "-";
  2968. if (groupCost != null)
  2969. {
  2970. _groupRate = groupCost.Rate;
  2971. if (int.TryParse(groupCost.Currency, out int _currency))
  2972. {
  2973. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2974. }
  2975. else _groupCurrencyCode = groupCost.Currency;
  2976. }
  2977. string costContentSql = $"Select * From Grp_GroupCost";
  2978. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2979. //处理日期为空的天数
  2980. for (int i = 0; i < groupCostDetails.Count; i++)
  2981. if (i != 0)
  2982. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2983. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2984. /*
  2985. * 处理详情数据
  2986. */
  2987. foreach (var entity in entityList)
  2988. {
  2989. var _detail = new Grp_CreditCardPaymentDetailView
  2990. {
  2991. Id = entity.Id,
  2992. PriceName = priceModule,
  2993. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  2994. };
  2995. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2996. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2997. //处理金额
  2998. if (entity.CTable == 1015)
  2999. {
  3000. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3001. if (czInfo != null)
  3002. {
  3003. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3004. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3005. }
  3006. }
  3007. /*
  3008. * 应付款金额
  3009. */
  3010. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3011. string PaymentCurrency_WaitPay = "Unknown";
  3012. string hotelCurrncyCode = "Unknown";
  3013. string hotelCurrncyName = "Unknown";
  3014. if (sdPaymentCurrency_WaitPay != null)
  3015. {
  3016. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3017. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3018. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3019. if (hotelCurrncyCode.Equals("CNY"))
  3020. {
  3021. entity.DayRate = 1.0000M;
  3022. }
  3023. }
  3024. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3025. /*
  3026. * 此次付款金额
  3027. */
  3028. decimal CurrPayStr = 0.00M,
  3029. OriginalCurrPay = 0.00M;
  3030. if (entity.PayPercentage == 0)
  3031. {
  3032. if (entity.PayThenMoney != 0)
  3033. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3034. }
  3035. else
  3036. {
  3037. if (entity.PayMoney != 0)
  3038. {
  3039. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3040. }
  3041. }
  3042. //if (_dto.Label == 79)
  3043. //{
  3044. // string original = string.Empty;
  3045. // if (hotelCurrncyCode.Equals("CNY"))
  3046. // {
  3047. // OriginalCurrPay = CurrPayStr;
  3048. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3049. // }
  3050. // else
  3051. // {
  3052. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3053. // //760 EUR(7600.00 CNY)
  3054. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3055. // }
  3056. //}
  3057. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3058. string original = string.Empty;
  3059. if (hotelCurrncyCode.Equals("CNY"))
  3060. {
  3061. OriginalCurrPay = CurrPayStr;
  3062. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3063. }
  3064. else
  3065. {
  3066. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3067. //760 EUR(7600.00 CNY)
  3068. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3069. }
  3070. /*
  3071. * 剩余尾款
  3072. */
  3073. decimal BalanceStr = 0;
  3074. if (CurrPayStr != 0)
  3075. {
  3076. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3077. BalanceStr = 0;
  3078. else
  3079. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3080. }
  3081. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3082. /*
  3083. * Bus名称
  3084. */
  3085. _detail.BusName = "待增加";
  3086. /*
  3087. *费用所属
  3088. */
  3089. switch (entity.CTable)
  3090. {
  3091. case 76://酒店预订
  3092. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3093. if (hotelReservations != null)
  3094. {
  3095. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3096. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3097. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3098. string roomFeeStr = "", roomFeestr1 = "";
  3099. //是否比较房型价格
  3100. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3101. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3102. roomFeeStr += $"<br/>";
  3103. var roomTotal = 0.00M;
  3104. if (hotelReservations.SingleRoomPrice > 0)
  3105. {
  3106. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3107. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3108. //__isSingle = true;
  3109. roomTotal += fee;
  3110. }
  3111. if (hotelReservations.DoubleRoomPrice > 0)
  3112. {
  3113. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3114. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3115. // __isDouble = true;
  3116. roomTotal += fee;
  3117. }
  3118. if (hotelReservations.SuiteRoomPrice > 0)
  3119. {
  3120. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3121. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3122. //__isSuite = true;
  3123. roomTotal += fee;
  3124. }
  3125. if (hotelReservations.OtherRoomPrice > 0)
  3126. {
  3127. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3128. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3129. //__isOther = true;
  3130. roomTotal += fee;
  3131. }
  3132. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3133. else roomFeeStr += " 0.00 * 0";
  3134. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3135. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3136. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3137. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3138. /*
  3139. * 费用类型
  3140. * 1:房费
  3141. * 2:早餐
  3142. * 3:地税
  3143. * 4:城市税
  3144. * </summary>
  3145. */
  3146. //地税
  3147. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3148. if (governmentRentData != null)
  3149. {
  3150. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3151. governmentRentFee = governmentRentData.Price;
  3152. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3153. if (governmentRentCurrData != null)
  3154. {
  3155. governmentRentCode = governmentRentCurrData.Name;
  3156. governmentRentName = $"({governmentRentCurrData.Remark})";
  3157. }
  3158. }
  3159. //城市税
  3160. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3161. if (cityTaxData != null)
  3162. {
  3163. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3164. cityTaxFee = cityTaxData.Price;
  3165. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3166. if (cityTaxCurrData != null)
  3167. {
  3168. cityTaxCode = cityTaxCurrData.Name;
  3169. cityTaxName = $"({cityTaxCurrData.Remark})";
  3170. }
  3171. }
  3172. //酒店早餐
  3173. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3174. if (breakfastData != null)
  3175. {
  3176. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3177. breakfastFee = breakfastData.Price;
  3178. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3179. if (breakfastCurrData != null)
  3180. {
  3181. breakfastCode = breakfastCurrData.Name;
  3182. breakfastName = $"({breakfastCurrData.Remark})";
  3183. }
  3184. }
  3185. //房间费用
  3186. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3187. if (roomData != null)
  3188. {
  3189. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3190. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3191. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3192. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3193. roomFee = roomData.Price;
  3194. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3195. if (roomCurrData != null)
  3196. {
  3197. roomCode = roomCurrData.Name;
  3198. roomName = $"({roomCurrData.Remark})";
  3199. }
  3200. }
  3201. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3202. string hotelCostStr = "";
  3203. decimal hotelCsotTotal = 0.00M;
  3204. if (groupCost != null)
  3205. {
  3206. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3207. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3208. }
  3209. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3210. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3211. string hotelCost_day = "";
  3212. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3213. foreach (var item in hotelCostDetails1)
  3214. {
  3215. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3216. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3217. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3218. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3219. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3220. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3221. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3222. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3223. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3224. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3225. hotelCost_day += @$"<br/>";
  3226. }
  3227. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3228. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3229. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3230. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3231. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3232. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3233. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3234. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3235. $"房间说明: {hotelReservations.Remark} <br/>" +
  3236. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3237. $"{hotelBreakfastStr}" +
  3238. $"{hotelGovernmentRentStr}" +
  3239. $"{hotelCityTaxStr}";
  3240. _detail.PriceNameContent = hotelReservations.HotelName;
  3241. }
  3242. break;
  3243. case 79://车/导游地接
  3244. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3245. if (touristGuideGroundReservations != null)
  3246. {
  3247. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3248. {
  3249. _detail.BusName = touristGuideGroundReservations.BusName;
  3250. }
  3251. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3252. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3253. //if (isInt)
  3254. //{
  3255. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3256. // if (cityInfo != null)
  3257. // {
  3258. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3259. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3260. // if (carFeeItem != null)
  3261. // {
  3262. // nameContent += $@"({carFeeItem.Name})";
  3263. // }
  3264. // _detail.PriceNameContent = nameContent;
  3265. // }
  3266. //}
  3267. //else
  3268. //{
  3269. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3270. //}
  3271. var touristGuideGroundReservationsContents =
  3272. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3273. var opContent_sb = new StringBuilder();
  3274. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3275. opContent_sb.AppendLine(contetTitle);
  3276. foreach (var item in touristGuideGroundReservationsContents)
  3277. {
  3278. string typeName = "Unknown";
  3279. string carCurrencyCode = "Unknown";
  3280. string carCurrencyName = "Unknown";
  3281. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3282. if (carTypeData != null) typeName = carTypeData.Name;
  3283. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3284. if (currencyData != null)
  3285. {
  3286. carCurrencyCode = currencyData.Name;
  3287. carCurrencyName = currencyData.Remark;
  3288. }
  3289. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3290. bool IsCurrencyAgreement = false;
  3291. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3292. string opCostStr = string.Empty;
  3293. decimal opCostTypePrice = 0.00M;
  3294. #region 处理成本各项费用
  3295. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3296. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3297. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3298. costOPFeeCNY = 0.00M, //团组成本 op费用
  3299. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3300. if (opCost.Count > 0)
  3301. {
  3302. switch (item.SId)
  3303. {
  3304. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3305. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3306. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3307. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3308. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3309. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3310. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3311. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3312. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3313. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3314. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3315. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3316. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3317. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3318. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3319. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3320. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3321. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3322. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3323. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3324. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3325. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3326. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3327. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3328. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3329. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3330. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3331. }
  3332. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3333. costOPFeeCNY = opCostTypePrice * _groupRate;
  3334. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3335. }
  3336. #endregion
  3337. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3338. aduitOPFeeCNY = item.Price * entity.DayRate;
  3339. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3340. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3341. $"{opTypeStr} {opCostStr}<br/>" +
  3342. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3343. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3344. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3345. {
  3346. if (IsCurrencyAgreement)
  3347. {
  3348. if (item.Price > opCostTypePrice)
  3349. {
  3350. opContent_sb.Append("<span style='color:red;'>");
  3351. opContent_sb.Append(opContent);
  3352. opContent_sb.Append("</span>");
  3353. opContent_sb.AppendLine();
  3354. }
  3355. else
  3356. {
  3357. opContent_sb.Append(opContent);
  3358. opContent_sb.AppendLine();
  3359. }
  3360. }
  3361. else
  3362. {
  3363. //验证是否超成本 按付款比例计算
  3364. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3365. {
  3366. opContent_sb.Append("<span style='color:red;'>");
  3367. opContent_sb.Append(opContent);
  3368. opContent_sb.Append("</span>");
  3369. opContent_sb.AppendLine();
  3370. }
  3371. else
  3372. {
  3373. opContent_sb.Append(opContent);
  3374. opContent_sb.AppendLine();
  3375. }
  3376. }
  3377. }
  3378. else
  3379. {
  3380. opContent_sb.Append(opContent);
  3381. opContent_sb.AppendLine();
  3382. }
  3383. }
  3384. _detail.PriceMsgContent = opContent_sb.ToString();
  3385. }
  3386. break;
  3387. case 80: //签证
  3388. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3389. if (visaInfo != null)
  3390. {
  3391. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3392. _detail.PriceNameContent = visaInfo.VisaDescription;
  3393. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3394. }
  3395. break;
  3396. case 81: //邀请/公务活动
  3397. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3398. if (_ioa != null)
  3399. {
  3400. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3401. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3402. sendCurrName = "Unknown", //快递费用币种 Name
  3403. sendCurrCode = "Unknown", //快递费用币种 Code
  3404. eventsCurrName = "Unknown", //公务活动费币种 Name
  3405. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3406. translateCurrName = "Unknown", //公务翻译费 Name
  3407. translateCurrCode = "Unknown"; //公务翻译费 Code
  3408. #region 处理费用币种
  3409. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3410. if (inviteCurrData != null)
  3411. {
  3412. inviteCurrName = inviteCurrData.Remark;
  3413. inviteCurrCode = inviteCurrData.Name;
  3414. }
  3415. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3416. if (sendCurrData != null)
  3417. {
  3418. sendCurrName = sendCurrData.Remark;
  3419. sendCurrCode = sendCurrData.Name;
  3420. }
  3421. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3422. if (eventsCurrData != null)
  3423. {
  3424. eventsCurrName = eventsCurrData.Remark;
  3425. eventsCurrCode = eventsCurrData.Name;
  3426. }
  3427. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3428. if (translateCurrData != null)
  3429. {
  3430. translateCurrName = translateCurrData.Remark;
  3431. translateCurrCode = translateCurrData.Name;
  3432. }
  3433. #endregion
  3434. _detail.PriceNameContent = _ioa.InviterArea;
  3435. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3436. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3437. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3438. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3439. $@"备注:" + _ioa.Remark + "<br/>";
  3440. }
  3441. break;
  3442. case 82: //团组客户保险
  3443. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3444. if (customers != null)
  3445. {
  3446. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3447. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3448. }
  3449. break;
  3450. case 85: //机票预订
  3451. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3452. if (jpRes != null)
  3453. {
  3454. string FlightsDescription = jpRes.FlightsDescription;
  3455. string PriceDescription = jpRes.PriceDescription;
  3456. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3457. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3458. }
  3459. break;
  3460. case 98://其他款项
  3461. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3462. if (gdpRes != null)
  3463. {
  3464. //var urlBase = $"http://132.232.92.186:24/Office/GrpFile/http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  3465. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  3466. //{
  3467. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  3468. //}
  3469. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3470. _detail.PriceNameContent = gdpRes.PriceName;
  3471. }
  3472. break;
  3473. case 285://收款退还
  3474. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3475. if (refundAndOtherMoney != null)
  3476. {
  3477. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3478. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3479. }
  3480. break;
  3481. case 751://酒店早餐
  3482. break;
  3483. case 1015://超支费用
  3484. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3485. if (groupExtraCost != null)
  3486. {
  3487. _detail.PriceNameContent = groupExtraCost.PriceName;
  3488. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3489. }
  3490. break;
  3491. default:
  3492. break;
  3493. }
  3494. /*
  3495. * 申请人
  3496. */
  3497. string operatorName = " - ";
  3498. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3499. if (_opUser != null)
  3500. {
  3501. operatorName = _opUser.CnName;
  3502. }
  3503. _detail.OperatorName = operatorName;
  3504. /*
  3505. * 审核人
  3506. */
  3507. string auditOperatorName = " - ";
  3508. if (entity.IsAuditGM != 0)
  3509. {
  3510. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3511. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3512. else
  3513. {
  3514. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3515. if (_adUser != null)
  3516. {
  3517. auditOperatorName = _adUser.CnName;
  3518. }
  3519. }
  3520. }
  3521. _detail.AuditOperatorName = auditOperatorName;
  3522. /*
  3523. * 超预算比例
  3524. */
  3525. string overBudgetStr = "";
  3526. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3527. else if (entity.ExceedBudget == 0)
  3528. {
  3529. if (entity.CTable == 76 || entity.CTable == 79)
  3530. {
  3531. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3532. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3533. }
  3534. else
  3535. {
  3536. overBudgetStr = "未超预算";
  3537. }
  3538. }
  3539. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3540. _detail.OverBudget = overBudgetStr;
  3541. decimal auditFee = 0.00M; //已审核金额 人名币
  3542. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3543. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3544. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3545. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3546. {
  3547. auditedFeeOriginal = entity.PayMoney;
  3548. auditFee = CurrPayStr;
  3549. }
  3550. else if (entity.IsAuditGM == 0)
  3551. {
  3552. unAuditFeeCNY = CurrPayStr;
  3553. unAuditFeeOriginal = OriginalCurrPay;
  3554. OriginalCurrPay = 0.00M;
  3555. }
  3556. /*
  3557. * 费用总计
  3558. */
  3559. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3560. {
  3561. CurrencyId = entity.PaymentCurrency,
  3562. CurrencyName = PaymentCurrency_WaitPay,
  3563. AmountPayable = entity.PayMoney,
  3564. ThisPayment = OriginalCurrPay,
  3565. BalancePayment = BalanceStr,
  3566. AuditedFunds = auditFee,
  3567. AuditedFundsOriginal = auditedFeeOriginal,
  3568. UnAuditFundsCNY = unAuditFeeCNY,
  3569. UnAuditFundsOriginal = unAuditFeeOriginal
  3570. });
  3571. _detail.IsAuditGM = entity.IsAuditGM;
  3572. detailList.Add(_detail);
  3573. }
  3574. #endregion
  3575. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3576. /*
  3577. * 下方描述处理
  3578. */
  3579. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3580. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3581. if (ccpCurrencyPrice != null)
  3582. {
  3583. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3584. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3585. }
  3586. else
  3587. {
  3588. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3589. }
  3590. string amountPayableStr = string.Format(@"应付款总金额: ");
  3591. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3592. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3593. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3594. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3595. foreach (var item in nonDuplicat)
  3596. {
  3597. var currencyName = item.CurrencyName;
  3598. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3599. if (strs.Count > 0)
  3600. {
  3601. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3602. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3603. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3604. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3605. //单独处理此次付款金额
  3606. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3607. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3608. //单独处理已审核费用
  3609. //if (item.CurrencyId == 836) //人民币
  3610. //{
  3611. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3612. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3613. //}
  3614. //else
  3615. //{
  3616. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3617. //}
  3618. if (currencyName.Equals("CNY"))
  3619. {
  3620. //已审核费用
  3621. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3622. //未审核费用
  3623. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3624. }
  3625. else
  3626. {
  3627. //已审核费用
  3628. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  3629. //未审核费用
  3630. unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
  3631. }
  3632. }
  3633. }
  3634. _view.TotalStr1 = amountPayableStr[..^1];
  3635. _view.TotalStr2 = thisPaymentStr[..^1];
  3636. _view.TotalStr3 = balancePaymentStr[..^1];
  3637. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3638. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3639. var _view1 = new
  3640. {
  3641. PageFuncAuth = pageFunAuthView,
  3642. Data = _view
  3643. };
  3644. return Ok(JsonView(_view1));
  3645. }
  3646. catch (Exception ex)
  3647. {
  3648. return Ok(JsonView(false, ex.Message));
  3649. }
  3650. }
  3651. /// <summary>
  3652. /// 费用审核
  3653. /// 修改团组费用审核状态
  3654. /// </summary>
  3655. /// <param name="_dto">参数Json字符串</param>
  3656. /// <returns></returns>
  3657. [HttpPost]
  3658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3659. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3660. {
  3661. #region 参数验证
  3662. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3663. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3664. #endregion
  3665. #region 页面操作权限验证
  3666. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3667. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3668. #endregion
  3669. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3670. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3671. DateTime dtNow = DateTime.Now;
  3672. _groupRepository.BeginTran();
  3673. int rst = 0;
  3674. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3675. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3676. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3677. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3678. var msgDatas = new List<dynamic>();
  3679. var dic_ccp_user = new Dictionary<int, int>() { };
  3680. foreach (var item in idList)
  3681. {
  3682. int CreditId = int.Parse(item);
  3683. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3684. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3685. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3686. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3687. .Where(s => s.Id == CreditId)
  3688. .ExecuteCommandAsync();
  3689. if (result < 1)
  3690. {
  3691. rst = -1;
  3692. _groupRepository.RollbackTran();
  3693. return Ok(JsonView(false, "操作失败并回滚!"));
  3694. }
  3695. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3696. if (creditData != null)
  3697. {
  3698. #region 应用通知配置
  3699. try
  3700. {
  3701. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3702. }
  3703. catch (Exception ex)
  3704. {
  3705. }
  3706. #endregion
  3707. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3708. string groupNameStr = string.Empty;
  3709. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3710. if (groupData != null) groupNameStr = groupData.TeamName;
  3711. string creditTypeStr = string.Empty;
  3712. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3713. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3714. string creditCurrency = string.Empty;
  3715. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3716. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3717. if (creditCurrency.Equals("CNY"))
  3718. {
  3719. creditData.DayRate = 1.0000M;
  3720. }
  3721. if (creditData.PayPercentage == 0.00M)
  3722. {
  3723. creditData.PayPercentage = 100M;
  3724. }
  3725. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3726. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3727. string msgContent = "";
  3728. if (creditCurrency.Equals("CNY"))
  3729. {
  3730. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3731. }
  3732. else
  3733. {
  3734. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3735. }
  3736. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3737. }
  3738. }
  3739. if (rst == 0)
  3740. {
  3741. _groupRepository.CommitTran();
  3742. foreach (var item in msgDatas)
  3743. {
  3744. //发送消息
  3745. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3746. }
  3747. #region 应用推送
  3748. try
  3749. {
  3750. foreach (var ccpId in dic_ccp_user.Keys)
  3751. {
  3752. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3753. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3754. }
  3755. }
  3756. catch (Exception)
  3757. {
  3758. }
  3759. #endregion
  3760. return Ok(JsonView(true, "操作成功!"));
  3761. }
  3762. return Ok(JsonView(false, "操作失败!"));
  3763. }
  3764. /// <summary>
  3765. /// 费用审核
  3766. /// 其他款项 文件下载
  3767. /// </summary>
  3768. /// <param name="id">其他款项 主键编号</param>
  3769. /// <returns></returns>
  3770. [HttpGet("{id}")]
  3771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3772. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1,int.MaxValue,ErrorMessage ="请传入有效的ID")]int id)
  3773. {
  3774. //网站域名
  3775. const string baseUrl = "http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  3776. var otherInfo = await _decreasePaymentsRep._sqlSugar
  3777. .Queryable<Grp_DecreasePayments>()
  3778. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  3779. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  3780. .Select((x, y) => new
  3781. {
  3782. x.Id,
  3783. x.FilePath
  3784. })
  3785. .FirstAsync();
  3786. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  3787. {
  3788. var url = $"{baseUrl}{otherInfo.FilePath}";
  3789. return Ok(JsonView(true, "操作成功!", url));
  3790. }
  3791. return Ok(JsonView(false, "暂无附件"));
  3792. }
  3793. #endregion
  3794. #region 机票费用录入
  3795. /// <summary>
  3796. /// 机票录入当前登录人可操作团组
  3797. /// </summary>
  3798. /// <param name="dto"></param>
  3799. /// <returns></returns>
  3800. [HttpPost]
  3801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3802. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3803. {
  3804. try
  3805. {
  3806. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3807. if (groupData.Code != 0)
  3808. {
  3809. return Ok(JsonView(false, groupData.Msg));
  3810. }
  3811. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3812. }
  3813. catch (Exception ex)
  3814. {
  3815. return Ok(JsonView(false, ex.Message));
  3816. }
  3817. }
  3818. /// <summary>
  3819. /// 机票费用录入列表
  3820. /// </summary>
  3821. /// <param name="dto"></param>
  3822. /// <returns></returns>
  3823. [HttpPost]
  3824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3825. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3826. {
  3827. try
  3828. {
  3829. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3830. if (groupData.Code != 0)
  3831. {
  3832. return Ok(JsonView(false, groupData.Msg));
  3833. }
  3834. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3835. }
  3836. catch (Exception ex)
  3837. {
  3838. return Ok(JsonView(false, ex.Message));
  3839. throw;
  3840. }
  3841. }
  3842. /// <summary>
  3843. /// 根据id查询费用录入信息
  3844. /// </summary>
  3845. /// <param name="dto"></param>
  3846. /// <returns></returns>
  3847. [HttpPost]
  3848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3849. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3850. {
  3851. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3852. if (groupData.Code != 0)
  3853. {
  3854. return Ok(JsonView(false, groupData.Msg));
  3855. }
  3856. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3857. }
  3858. /// <summary>
  3859. /// 机票费用录入操作(Status:1.新增,2.修改)
  3860. /// </summary>
  3861. /// <param name="dto"></param>
  3862. /// <returns></returns>
  3863. [HttpPost]
  3864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3865. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3866. {
  3867. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3868. if (groupData.Code != 0)
  3869. {
  3870. return Ok(JsonView(false, groupData.Msg));
  3871. }
  3872. #region 应用推送
  3873. try
  3874. {
  3875. var diId = dto.AirTicketResOpData.DiId;
  3876. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3877. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3878. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3879. //自动审核
  3880. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3881. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3882. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3883. $"GroupId:{diId};airId:{dataId};",
  3884. status,
  3885. auditMsg);
  3886. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3887. //2024-10-21 新增LZ UID
  3888. var userIds = new List<int>() { 21 };
  3889. string title = $"系统通知";
  3890. string content = "";
  3891. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3892. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3893. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3894. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3895. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3896. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3897. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3898. }
  3899. catch (Exception ex)
  3900. {
  3901. }
  3902. #endregion
  3903. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3904. }
  3905. /// <summary>
  3906. /// 机票费用自动审核 AI识别方式
  3907. /// </summary>
  3908. /// <returns></returns>
  3909. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3910. {
  3911. var ecoTypeIds = new List<int>() {
  3912. 459, //超经舱
  3913. 460, //经济舱
  3914. 1430, //公务舱(实际经济舱)
  3915. 1432, //头等舱(实际经济舱)
  3916. };
  3917. var bizTypeIds = new List<int>() {
  3918. 457, //头等舱
  3919. 458, //公务舱
  3920. 1431, //头等舱(实际公务舱)
  3921. };
  3922. var auditFeeTypeIds = new List<int>() { };
  3923. auditFeeTypeIds.AddRange(ecoTypeIds);
  3924. auditFeeTypeIds.AddRange(bizTypeIds);
  3925. int currModule = 85;
  3926. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3927. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3928. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3929. .Select((x, y) => new
  3930. {
  3931. x.Id,
  3932. CcpId = y.Id,
  3933. x.FlightsDate,
  3934. x.PrePrice,
  3935. x.CType,
  3936. x.ClientNum,
  3937. x.DIId
  3938. })
  3939. .FirstAsync();
  3940. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3941. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3942. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3943. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3944. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3945. var groupCostContents = await _sqlSugar
  3946. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3947. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3948. .ToListAsync();
  3949. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3950. //处理 成本详细信息日期为空 填装费用信息
  3951. var airFeeLabel = new StringBuilder();
  3952. airFeeLabel.AppendLine("费用成本:");
  3953. for (int i = 0; i < groupCostContents.Count; i++)
  3954. {
  3955. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3956. {
  3957. int index = i - 1;
  3958. if (index >= 0)
  3959. {
  3960. groupCostContents[i].Date = groupCostContents[index].Date;
  3961. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3962. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3963. }
  3964. }
  3965. else
  3966. {
  3967. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3968. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3969. }
  3970. var item = groupCostContents[i];
  3971. airFeeLabel.AppendLine($"{item.Date}");
  3972. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3973. }
  3974. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3975. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3976. //访问Kimi AI 返回价格结果
  3977. var msgs = new List<SeedMessages>()
  3978. {
  3979. new ()
  3980. {
  3981. Role = KimiRole.user,
  3982. Content = airFeeLabel.ToString()
  3983. }
  3984. };
  3985. var client = new KiMiApiClient();
  3986. var kimiApiResult = await client.SeedMessage(msgs);
  3987. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3988. string clients = kimiApiResult_JObject["content"].ToString();
  3989. decimal ecoPri_kimiAI = 0.00M,
  3990. bizPri_kimiAI = 0.00M;
  3991. //单个价格: 经济舱价格
  3992. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3993. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3994. if (clients.Contains('/'))
  3995. {
  3996. var priArray = clients.Split('/');
  3997. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  3998. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  3999. }
  4000. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4001. var isAutoAudit = false;
  4002. //价格验证处理
  4003. //经济舱
  4004. if (ecoTypeIds.Contains(airInfo.CType))
  4005. {
  4006. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4007. }
  4008. //公务舱
  4009. else if (bizTypeIds.Contains(airInfo.CType))
  4010. {
  4011. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4012. }
  4013. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4014. //是否执行自动审核
  4015. if (isAutoAudit)
  4016. {
  4017. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4018. .SetColumns(x => x.IsAuditGM == 3)
  4019. .SetColumns(x => x.AuditGMOperate == 4)
  4020. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4021. .Where(x => x.Id == airInfo.CcpId)
  4022. .ExecuteCommandAsync();
  4023. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4024. }
  4025. return (false, "当前费用超过成本费用,不可自动审核!");
  4026. }
  4027. /// <summary>
  4028. /// 机票费用录入
  4029. /// 自动审核测试 - AI 识别
  4030. /// </summary>
  4031. /// <param name="groupId"></param>
  4032. /// <param name="Id"></param>
  4033. /// <returns></returns>
  4034. [HttpPost]
  4035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4036. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4037. {
  4038. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4039. return Ok(JsonView(status, msg));
  4040. }
  4041. /// <summary>
  4042. /// 根据舱位类型查询接团客户名单信息
  4043. /// </summary>
  4044. /// <param name="dto"></param>
  4045. /// <returns></returns>
  4046. [HttpPost]
  4047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4048. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4049. {
  4050. try
  4051. {
  4052. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4053. if (crm_Groups.Count != 0)
  4054. {
  4055. var Customer = new List<dynamic>();
  4056. foreach (var item in crm_Groups)
  4057. {
  4058. var data = new
  4059. {
  4060. item.Id,
  4061. item.Pinyin,
  4062. Name = item.LastName + item.FirstName
  4063. };
  4064. Customer.Add(data);
  4065. }
  4066. return Ok(JsonView(true, "查询成功!", Customer));
  4067. }
  4068. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4069. }
  4070. catch (Exception ex)
  4071. {
  4072. return Ok(JsonView(false, "程序错误!"));
  4073. throw;
  4074. }
  4075. }
  4076. /// <summary>
  4077. /// 根据团号获取客户信息
  4078. /// </summary>
  4079. /// <param name="dto"></param>
  4080. /// <returns></returns>
  4081. [HttpPost]
  4082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4083. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4084. {
  4085. var jw = JsonView(false);
  4086. if (dto.DIID < 1)
  4087. {
  4088. jw.Msg += "请输入正确的diid";
  4089. return Ok(jw);
  4090. }
  4091. var arr = GetSimplClientList(dto.DIID);
  4092. jw = JsonView(true, "获取成功!", arr);
  4093. return Ok(jw);
  4094. }
  4095. private List<SimplClientInfo> GetSimplClientList(int diId)
  4096. {
  4097. 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);
  4098. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4099. foreach (var item in arr)
  4100. {
  4101. EncryptionProcessor.DecryptProperties(item);
  4102. }
  4103. return arr;
  4104. }
  4105. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4106. {
  4107. string result = origin;
  4108. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4109. {
  4110. string[] temparr = origin.Split(',');
  4111. string fistrStr = temparr[0];
  4112. int count = temparr.Length;
  4113. bool success = int.TryParse(fistrStr, out int tempId);
  4114. if (success)
  4115. {
  4116. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4117. if (tempInfo != null)
  4118. {
  4119. if (count > 1)
  4120. {
  4121. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4122. }
  4123. else
  4124. {
  4125. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4126. }
  4127. }
  4128. }
  4129. }
  4130. return result;
  4131. }
  4132. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4133. {
  4134. string result = origin;
  4135. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4136. {
  4137. string[] temparr = origin.Split(',');
  4138. result = "";
  4139. foreach (var item in temparr)
  4140. {
  4141. bool success = int.TryParse(item, out int tempId);
  4142. if (success)
  4143. {
  4144. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4145. if (tempInfo != null)
  4146. {
  4147. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4148. }
  4149. }
  4150. }
  4151. }
  4152. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4153. return result;
  4154. }
  4155. /// <summary>
  4156. /// 机票费用录入,删除
  4157. /// </summary>
  4158. /// <param name="dto"></param>
  4159. /// <returns></returns>
  4160. [HttpPost]
  4161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4162. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4163. {
  4164. try
  4165. {
  4166. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4167. if (res)
  4168. {
  4169. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4170. {
  4171. IsDel = 1,
  4172. DeleteUserId = dto.DeleteUserId,
  4173. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4174. }).ExecuteCommandAsync();
  4175. return Ok(JsonView(true, "删除成功!"));
  4176. }
  4177. return Ok(JsonView(false, "删除失败!"));
  4178. }
  4179. catch (Exception ex)
  4180. {
  4181. return Ok(JsonView(false, "程序错误!"));
  4182. throw;
  4183. }
  4184. }
  4185. /// <summary>
  4186. /// 导出机票录入报表
  4187. /// </summary>
  4188. /// <param name="dto"></param>
  4189. /// <returns></returns>
  4190. [HttpPost]
  4191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4192. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4193. {
  4194. try
  4195. {
  4196. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4197. if (groupData.Code != 0)
  4198. {
  4199. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4200. }
  4201. else
  4202. {
  4203. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4204. if (AirTicketReservations.Count != 0)
  4205. {
  4206. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4207. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4208. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4209. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4210. var designer = new WorkbookDesigner
  4211. {
  4212. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4213. };
  4214. decimal countCost = 0;
  4215. foreach (var item in AirTicketReservations)
  4216. {
  4217. #region 处理客人姓名
  4218. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4219. item.ClientName = clientNames;
  4220. #endregion
  4221. if (item.BankType == "其他")
  4222. {
  4223. item.BankNo = "--";
  4224. }
  4225. else
  4226. {
  4227. if (!string.IsNullOrEmpty(item.BankType))
  4228. {
  4229. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  4230. }
  4231. }
  4232. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4233. item.Price = System.Decimal.Round(item.Price, 2);
  4234. countCost += Convert.ToDecimal(item.Price);
  4235. }
  4236. designer.SetDataSource("Export", AirTicketReservations);
  4237. designer.SetDataSource("ExportDiCode", diCode);
  4238. designer.SetDataSource("ExportDiName", diName);
  4239. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4240. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4241. designer.Process();
  4242. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4243. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4244. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4245. return Ok(JsonView(true, "成功", url = rst));
  4246. }
  4247. else
  4248. {
  4249. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4250. }
  4251. }
  4252. }
  4253. catch (Exception ex)
  4254. {
  4255. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4256. throw;
  4257. }
  4258. }
  4259. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4260. /// <summary>
  4261. /// 行程单导出
  4262. /// </summary>
  4263. /// <param name="dto"></param>
  4264. /// <returns></returns>
  4265. [HttpPost]
  4266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4267. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4268. {
  4269. try
  4270. {
  4271. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4272. if (groupData.Code != 0)
  4273. {
  4274. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4275. }
  4276. else
  4277. {
  4278. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4279. if (dto.Language == "CN")
  4280. {
  4281. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4282. var builder = new DocumentBuilder(doc);
  4283. int tableIndex = 0;//表格索引
  4284. //得到文档中的第一个表格
  4285. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4286. foreach (var item in _AirTicketReservations)
  4287. {
  4288. #region 处理固定数据
  4289. string[] FlightsCode = item.FlightsCode.Split('/');
  4290. if (FlightsCode.Length != 0)
  4291. {
  4292. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4293. if (_AirCompany != null)
  4294. {
  4295. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4296. }
  4297. else
  4298. {
  4299. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4300. }
  4301. }
  4302. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4303. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4304. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4305. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4306. string name = "";
  4307. foreach (string clientName in nameArray)
  4308. {
  4309. if (!name.Contains(clientName))
  4310. {
  4311. name += clientName + ",";
  4312. }
  4313. }
  4314. if (!string.IsNullOrWhiteSpace(name))
  4315. {
  4316. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4317. }
  4318. else
  4319. {
  4320. table.Range.Bookmarks["ClientName"].Text = "--";
  4321. }
  4322. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4323. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4324. table.Range.Bookmarks["JointTicket"].Text = "--";
  4325. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4326. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4327. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4328. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4329. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4330. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4331. #endregion
  4332. #region 循环数据处理
  4333. var airs = new List<AirInfo>();
  4334. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4335. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4336. for (int i = 0; i < FlightsCode.Length; i++)
  4337. {
  4338. var air = new AirInfo();
  4339. string[] tempstr = DayArray[i]
  4340. .Replace("\r\n", string.Empty)
  4341. .Replace("\\r\\n", string.Empty)
  4342. .TrimStart().TrimEnd()
  4343. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4344. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4345. string starCity = "";
  4346. if (star_Three != null)
  4347. {
  4348. starCity = star_Three.AirPort;
  4349. }
  4350. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4351. string EndCity = "";
  4352. if (End_Three != null)
  4353. {
  4354. EndCity = End_Three.AirPort;
  4355. }
  4356. air.Destination = starCity + "/" + EndCity;
  4357. air.Flight = FlightsCode[i];
  4358. air.SeatingClass = item.CTypeName;
  4359. string dateTime = tempstr[2];
  4360. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4361. air.FlightDate = DateTemp;
  4362. air.DepartureTime = tempstr[5];
  4363. air.LandingTime = tempstr[6];
  4364. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4365. air.TicketStatus = "--";
  4366. air.Luggage = "--";
  4367. air.DepartureTerminal = "--";
  4368. air.LandingTerminal = "--";
  4369. airs.Add(air);
  4370. }
  4371. int row = 13;
  4372. for (int i = 0; i < airs.Count; i++)
  4373. {
  4374. if (airs.Count > 2)
  4375. {
  4376. for (int j = 0; j < airs.Count - 2; j++)
  4377. {
  4378. var CopyRow = table.Rows[12].Clone(true);
  4379. table.Rows.Add(CopyRow);
  4380. }
  4381. }
  4382. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4383. int index = 0;
  4384. foreach (PropertyInfo property in properties)
  4385. {
  4386. string value = property.GetValue(airs[i]).ToString();
  4387. Cell ishcel0 = table.Rows[row].Cells[index];
  4388. var p = new Paragraph(doc);
  4389. string s = value;
  4390. p.AppendChild(new Run(doc, s));
  4391. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4392. ishcel0.AppendChild(p);
  4393. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4394. index++;
  4395. }
  4396. row++;
  4397. }
  4398. #endregion
  4399. var lastParagraph = new Paragraph(doc);
  4400. //第一个表格末尾加段落
  4401. table.ParentNode.InsertAfter(lastParagraph, table);
  4402. //复制第一个表格
  4403. Table cloneTable = (Table)table.Clone(true);
  4404. //在文档末尾段落后面加入复制的表格
  4405. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4406. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4407. {
  4408. int rownewsIndex = 13;
  4409. for (int i = 0; i < 2; i++)
  4410. {
  4411. var CopyRow = table.Rows[12].Clone(true);
  4412. table.Rows.RemoveAt(13);
  4413. table.Rows.Add(CopyRow);
  4414. rownewsIndex++;
  4415. }
  4416. }
  4417. else
  4418. {
  4419. table.Rows.RemoveAt(12);
  4420. }
  4421. cloneTable.Rows.RemoveAt(12);
  4422. }
  4423. if (_AirTicketReservations.Count != 0)
  4424. {
  4425. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4426. if (FlightsCode.Length != 0)
  4427. {
  4428. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4429. if (_AirCompany != null)
  4430. {
  4431. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4432. }
  4433. else
  4434. {
  4435. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4436. }
  4437. }
  4438. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4439. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4440. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4441. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4442. string name = "";
  4443. foreach (string clientName in nameArray)
  4444. {
  4445. if (!name.Contains(clientName))
  4446. {
  4447. name += clientName + ",";
  4448. }
  4449. }
  4450. if (!string.IsNullOrWhiteSpace(name))
  4451. {
  4452. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4453. }
  4454. else
  4455. {
  4456. table.Range.Bookmarks["ClientName"].Text = "--";
  4457. }
  4458. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4459. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4460. table.Range.Bookmarks["JointTicket"].Text = "--";
  4461. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4462. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4463. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4464. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4465. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4466. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4467. }
  4468. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4469. //保存合并后的文档
  4470. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4471. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4472. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4473. return Ok(JsonView(true, "成功!", rst));
  4474. }
  4475. else
  4476. {
  4477. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4478. var builder = new DocumentBuilder(doc);
  4479. int tableIndex = 0;//表格索引
  4480. //得到文档中的第一个表格
  4481. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4482. var texts = new List<string>();
  4483. foreach (var item in _AirTicketReservations)
  4484. {
  4485. string[] FlightsCode = item.FlightsCode.Split('/');
  4486. if (FlightsCode.Length != 0)
  4487. {
  4488. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4489. if (_AirCompany != null)
  4490. {
  4491. if (!transDic.ContainsKey(_AirCompany.CnName))
  4492. {
  4493. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4494. }
  4495. }
  4496. else
  4497. {
  4498. if (!transDic.ContainsKey("--"))
  4499. {
  4500. transDic.Add("--", "--");
  4501. }
  4502. }
  4503. }
  4504. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4505. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4506. string name = "";
  4507. foreach (string clientName in nameArray)
  4508. {
  4509. name += clientName + ",";
  4510. }
  4511. if (!texts.Contains(name))
  4512. {
  4513. texts.Add(name);
  4514. }
  4515. var airs = new List<AirInfo>();
  4516. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4517. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4518. for (int i = 0; i < FlightsCode.Length; i++)
  4519. {
  4520. var air = new AirInfo();
  4521. string[] tempstr = DayArray[i]
  4522. .Replace("\r\n", string.Empty)
  4523. .Replace("\\r\\n", string.Empty)
  4524. .TrimStart().TrimEnd()
  4525. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4526. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4527. if (star_Three != null)
  4528. {
  4529. if (!transDic.ContainsKey(star_Three.AirPort))
  4530. {
  4531. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4532. }
  4533. }
  4534. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4535. if (End_Three != null)
  4536. {
  4537. if (!transDic.ContainsKey(End_Three.AirPort))
  4538. {
  4539. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4540. }
  4541. }
  4542. if (!texts.Contains(item.CTypeName))
  4543. {
  4544. texts.Add(item.CTypeName);
  4545. }
  4546. }
  4547. }
  4548. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4549. if (transData.Count > 0)
  4550. {
  4551. foreach (TranslateResult item in transData)
  4552. {
  4553. if (!transDic.ContainsKey(item.Query))
  4554. {
  4555. transDic.Add(item.Query, item.Translation);
  4556. }
  4557. }
  4558. }
  4559. foreach (var item in _AirTicketReservations)
  4560. {
  4561. #region 处理固定数据
  4562. string[] FlightsCode = item.FlightsCode.Split('/');
  4563. if (FlightsCode.Length != 0)
  4564. {
  4565. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4566. if (_AirCompany != null)
  4567. {
  4568. string str = "--";
  4569. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4570. if (!string.IsNullOrEmpty(translateResult))
  4571. {
  4572. str = translateResult;
  4573. str = _airTicketResRep.Processing(str);
  4574. }
  4575. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4576. }
  4577. else
  4578. {
  4579. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4580. }
  4581. }
  4582. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4583. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4584. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4585. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4586. string names = "";
  4587. foreach (string clientName in nameArray)
  4588. {
  4589. names += clientName + ",";
  4590. }
  4591. if (!string.IsNullOrWhiteSpace(names))
  4592. {
  4593. string str = "--";
  4594. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4595. if (!string.IsNullOrEmpty(translateResult))
  4596. {
  4597. str = translateResult;
  4598. str = _airTicketResRep.Processing(str);
  4599. }
  4600. table.Range.Bookmarks["ClientName"].Text = str;
  4601. }
  4602. else
  4603. {
  4604. table.Range.Bookmarks["ClientName"].Text = "--";
  4605. }
  4606. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4607. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4608. table.Range.Bookmarks["JointTicket"].Text = "--";
  4609. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4610. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4611. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4612. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4613. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4614. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4615. #endregion
  4616. #region 循环数据处理
  4617. var airs = new List<AirInfo>();
  4618. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4619. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4620. for (int i = 0; i < FlightsCode.Length; i++)
  4621. {
  4622. var air = new AirInfo();
  4623. string[] tempstr = DayArray[i]
  4624. .Replace("\r\n", string.Empty)
  4625. .Replace("\\r\\n", string.Empty)
  4626. .TrimStart().TrimEnd()
  4627. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4628. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4629. string starCity = "";
  4630. if (star_Three != null)
  4631. {
  4632. string str2 = "--";
  4633. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4634. if (!string.IsNullOrEmpty(translateResult2))
  4635. {
  4636. str2 = translateResult2;
  4637. str2 = _airTicketResRep.Processing(str2);
  4638. }
  4639. starCity = str2;
  4640. }
  4641. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4642. string EndCity = "";
  4643. if (End_Three != null)
  4644. {
  4645. string str1 = "--";
  4646. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4647. if (!string.IsNullOrEmpty(translateResult1))
  4648. {
  4649. str1 = translateResult1;
  4650. str1 = _airTicketResRep.Processing(str1);
  4651. }
  4652. EndCity = str1;
  4653. }
  4654. air.Destination = starCity + "/" + EndCity;
  4655. air.Flight = FlightsCode[i];
  4656. string str = "--";
  4657. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4658. if (!string.IsNullOrEmpty(translateResult))
  4659. {
  4660. str = translateResult;
  4661. str = _airTicketResRep.Processing(str);
  4662. }
  4663. air.SeatingClass = str;
  4664. string dateTime = tempstr[2];
  4665. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4666. air.FlightDate = DateTemp;
  4667. air.DepartureTime = tempstr[5];
  4668. air.LandingTime = tempstr[6];
  4669. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4670. air.TicketStatus = "--";
  4671. air.Luggage = "--";
  4672. air.DepartureTerminal = "--";
  4673. air.LandingTerminal = "--";
  4674. airs.Add(air);
  4675. }
  4676. int row = 13;
  4677. for (int i = 0; i < airs.Count; i++)
  4678. {
  4679. if (airs.Count > 2)
  4680. {
  4681. for (int j = 0; j < airs.Count - 2; j++)
  4682. {
  4683. var CopyRow = table.Rows[12].Clone(true);
  4684. table.Rows.Add(CopyRow);
  4685. }
  4686. }
  4687. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4688. int index = 0;
  4689. foreach (PropertyInfo property in properties)
  4690. {
  4691. string value = property.GetValue(airs[i]).ToString();
  4692. Cell ishcel0 = table.Rows[row].Cells[index];
  4693. var p = new Paragraph(doc);
  4694. string s = value;
  4695. p.AppendChild(new Run(doc, s));
  4696. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4697. ishcel0.AppendChild(p);
  4698. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4699. //ishcel0.CellFormat.VerticalAlignment=
  4700. index++;
  4701. }
  4702. row++;
  4703. }
  4704. #endregion
  4705. var lastParagraph = new Paragraph(doc);
  4706. //第一个表格末尾加段落
  4707. table.ParentNode.InsertAfter(lastParagraph, table);
  4708. //复制第一个表格
  4709. Table cloneTable = (Table)table.Clone(true);
  4710. //在文档末尾段落后面加入复制的表格
  4711. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4712. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4713. {
  4714. int rownewsIndex = 13;
  4715. for (int i = 0; i < 2; i++)
  4716. {
  4717. var CopyRow = table.Rows[12].Clone(true);
  4718. table.Rows.RemoveAt(13);
  4719. table.Rows.Add(CopyRow);
  4720. rownewsIndex++;
  4721. }
  4722. }
  4723. else
  4724. {
  4725. table.Rows.RemoveAt(12);
  4726. }
  4727. cloneTable.Rows.RemoveAt(12);
  4728. }
  4729. if (_AirTicketReservations.Count != 0)
  4730. {
  4731. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4732. if (FlightsCode.Length != 0)
  4733. {
  4734. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4735. if (_AirCompany != null)
  4736. {
  4737. string str = "--";
  4738. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4739. if (!string.IsNullOrEmpty(translateResult))
  4740. {
  4741. str = translateResult;
  4742. str = _airTicketResRep.Processing(str);
  4743. }
  4744. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4745. }
  4746. else
  4747. {
  4748. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4749. }
  4750. }
  4751. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4752. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4753. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4754. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4755. string names = "";
  4756. foreach (string clientName in nameArray)
  4757. {
  4758. names += clientName + ",";
  4759. }
  4760. if (!string.IsNullOrWhiteSpace(names))
  4761. {
  4762. string str = "--";
  4763. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4764. if (!string.IsNullOrEmpty(translateResult))
  4765. {
  4766. str = translateResult;
  4767. str = _airTicketResRep.Processing(str);
  4768. }
  4769. table.Range.Bookmarks["ClientName"].Text = str;
  4770. }
  4771. else
  4772. {
  4773. table.Range.Bookmarks["ClientName"].Text = "--";
  4774. }
  4775. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4776. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4777. table.Range.Bookmarks["JointTicket"].Text = "--";
  4778. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4779. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4780. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4781. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4782. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4783. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4784. }
  4785. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4786. //保存合并后的文档
  4787. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4788. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4789. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4790. return Ok(JsonView(true, "成功!", rst));
  4791. }
  4792. }
  4793. }
  4794. catch (Exception ex)
  4795. {
  4796. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4797. throw;
  4798. }
  4799. }
  4800. #endregion
  4801. #region 团组增减款项 --> 其他款项
  4802. /// <summary>
  4803. /// 团组增减款项下拉框绑定
  4804. /// </summary>
  4805. /// <param name="dto"></param>
  4806. /// <returns></returns>
  4807. [HttpPost]
  4808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4809. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4810. {
  4811. #region 参数验证
  4812. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4813. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4814. #endregion
  4815. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4816. }
  4817. /// <summary>
  4818. /// 根据团组Id查询团组增减款项
  4819. /// </summary>
  4820. /// <param name="dto"></param>
  4821. /// <returns></returns>
  4822. [HttpPost]
  4823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4824. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4825. {
  4826. #region 参数验证
  4827. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4828. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4829. #endregion
  4830. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4831. }
  4832. /// <summary>
  4833. /// 团组增减款项操作(Status:1.新增,2.修改)
  4834. /// </summary>
  4835. /// <param name="dto"></param>
  4836. /// <returns></returns>
  4837. [HttpPost]
  4838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4839. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4840. {
  4841. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4842. if (groupData.Code != 200)
  4843. {
  4844. return Ok(JsonView(false, groupData.Msg));
  4845. }
  4846. #region 应用推送
  4847. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4848. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4849. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4850. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4851. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4852. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4853. //自动审核
  4854. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4855. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4856. //2024-10-21 新增LZ UID
  4857. var userIds = new List<int>() { 21 };
  4858. string title = $"系统通知";
  4859. string content = "";
  4860. var diId = dto.DiId;
  4861. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4862. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4863. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4864. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4865. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4866. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4867. #endregion
  4868. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4869. }
  4870. /// <summary>
  4871. ///
  4872. /// 团组增减款项操作 删除
  4873. /// </summary>
  4874. /// <param name="dto"></param>
  4875. /// <returns></returns>
  4876. [HttpPost]
  4877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4878. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4879. {
  4880. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4881. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4882. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4883. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4884. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4885. }
  4886. /// <summary>
  4887. /// 根据团组增减款项Id查询
  4888. /// </summary>
  4889. /// <param name="dto"></param>
  4890. /// <returns></returns>
  4891. [HttpPost]
  4892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4893. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4894. {
  4895. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4896. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4897. }
  4898. /// <summary>
  4899. /// 查询供应商名称
  4900. /// </summary>
  4901. /// <param name="dto"></param>
  4902. /// <returns></returns>
  4903. [HttpPost]
  4904. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4905. {
  4906. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4907. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4908. ?? new List<Grp_DecreasePayments>();
  4909. dbResult = dbResult.Distinct(new
  4910. ProductComparer()).ToList();
  4911. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4912. {
  4913. x.Id,
  4914. x.SupplierAddress,
  4915. x.SupplierArea,
  4916. x.SupplierContact,
  4917. x.SupplierContactNumber,
  4918. x.SupplierEmail,
  4919. x.SupplierName,
  4920. x.SupplierSocialAccount,
  4921. x.SupplierTypeId,
  4922. }).ToList());
  4923. return Ok(jw);
  4924. }
  4925. /// <summary>
  4926. /// 团组增减款项 OTA匹配
  4927. /// </summary>
  4928. /// <param name="file"></param>
  4929. /// <returns></returns>
  4930. [HttpPost]
  4931. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4932. {
  4933. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4934. string fileName = file.FileName;
  4935. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4936. {
  4937. return Ok(JsonView(false, "请上传Excel文件!"));
  4938. }
  4939. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4940. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4941. if (!Directory.Exists(path))
  4942. {
  4943. Directory.CreateDirectory(path);
  4944. }
  4945. var filePath = @$"{path}/{fileName}";
  4946. //保存文件
  4947. using (FileStream fs = System.IO.File.Create(filePath))
  4948. {
  4949. file.CopyTo(fs);
  4950. fs.Flush();
  4951. }
  4952. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4953. //读取ExcelFile
  4954. DataTable dt = ConvertExcelToDataTable(filePath);
  4955. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4956. dt.TableName = "TB";
  4957. //修改table列名
  4958. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4959. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4960. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4961. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4962. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4963. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4964. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4965. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4966. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4967. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4968. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4969. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4970. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4971. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4972. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4973. var otaOrderNos = new List<string>();
  4974. foreach (DataRow item in dt.Rows)
  4975. {
  4976. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4977. }
  4978. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4979. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4980. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4981. .Select((dp, di) => new
  4982. {
  4983. dp.PriceName,
  4984. dp.OTAOrderNo,
  4985. dp.FeeTotal,
  4986. di.TeamName,
  4987. })
  4988. .ToListAsync();
  4989. foreach (DataRow item in dt.Rows)
  4990. {
  4991. var otaOrderNo = item["OTAOrderNo"].ToString();
  4992. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4993. if (oaData == null) continue;
  4994. item["GroupName"] = oaData.TeamName;
  4995. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4996. }
  4997. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  4998. var pairs = new Dictionary<string, object>();
  4999. var datas = new List<DataTable>
  5000. {
  5001. dt
  5002. };
  5003. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5004. return Ok(JsonView(true, "操作成功", new { url }));
  5005. }
  5006. #region
  5007. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5008. {
  5009. // 创建Workbook对象
  5010. var workbook = new Workbook(excelFilePath);
  5011. // 获取第一个工作表
  5012. var worksheet = workbook.Worksheets[0];
  5013. // 将工作表转换为DataTable
  5014. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5015. return dataTable;
  5016. }
  5017. #endregion
  5018. /// <summary>
  5019. /// 世运会数据
  5020. /// </summary>
  5021. /// <returns></returns>
  5022. [HttpGet]
  5023. public IActionResult WorldGamesData()
  5024. {
  5025. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5026. var groupMenu = setData.GroupBy(x => x.T0);
  5027. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5028. foreach (var item in groupMenu)
  5029. {
  5030. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5031. {
  5032. Data = new SetDataView
  5033. {
  5034. Name = item.Key
  5035. },
  5036. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5037. });
  5038. }
  5039. return Ok(JsonView(true, "success", resultArr));
  5040. }
  5041. #endregion
  5042. #region 文件上传、删除
  5043. /// <summary>
  5044. /// region 文件上传 可以带参数
  5045. /// </summary>
  5046. /// <param name="file"></param>
  5047. /// <returns></returns>
  5048. [HttpPost]
  5049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5050. public async Task<IActionResult> UploadProject(IFormFile file)
  5051. {
  5052. //var TypeName = Request.Headers["TypeName"].ToString();
  5053. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5054. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5055. ////文件名称
  5056. //string projectFileName = file.FileName;
  5057. ////上传的文件的路径
  5058. //string filePath = $"{fileDir}/{projectFileName}";
  5059. //if (TypeName == "A")//A代表团组增减款项
  5060. //{
  5061. // filePath = fileDir + $@"\团组增减款项相关文件";
  5062. // if (!Directory.Exists(filePath))
  5063. // {
  5064. // Directory.CreateDirectory(filePath);
  5065. // }
  5066. // //上传的文件的路径
  5067. // filePath += $@"\{projectFileName}";
  5068. //}
  5069. //else if (TypeName == "B")//B代表商邀相关文件
  5070. //{
  5071. // //上传的文件的路径
  5072. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5073. // if (!Directory.Exists(filePath))
  5074. // {
  5075. // Directory.CreateDirectory(filePath);
  5076. // }
  5077. // //上传的文件的路径
  5078. // filePath = $@"\{projectFileName}";
  5079. //}
  5080. //try
  5081. //{
  5082. // using (FileStream fs = System.IO.File.Create(filePath))
  5083. // {
  5084. // file.CopyTo(fs);
  5085. // fs.Flush();
  5086. // }
  5087. //}
  5088. //catch (Exception ex)
  5089. //{
  5090. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5091. //}
  5092. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5093. try
  5094. {
  5095. var TypeName = Request.Headers["TypeName"].ToString();
  5096. if (file != null)
  5097. {
  5098. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5099. //文件名称
  5100. string projectFileName = file.FileName;
  5101. //上传的文件的路径
  5102. string filePath = $"{fileDir}/{projectFileName}";
  5103. if (TypeName == "A")//A代表团组增减款项
  5104. {
  5105. if (!Directory.Exists(fileDir))
  5106. {
  5107. Directory.CreateDirectory(fileDir);
  5108. }
  5109. //上传的文件的路径
  5110. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5111. }
  5112. else if (TypeName == "B")//B代表商邀相关文件
  5113. {
  5114. if (!Directory.Exists(fileDir))
  5115. {
  5116. Directory.CreateDirectory(fileDir);
  5117. }
  5118. //上传的文件的路径
  5119. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5120. }
  5121. using (FileStream fs = System.IO.File.Create(filePath))
  5122. {
  5123. file.CopyTo(fs);
  5124. fs.Flush();
  5125. }
  5126. return Ok(JsonView(true, "上传成功!", projectFileName));
  5127. }
  5128. else
  5129. {
  5130. return Ok(JsonView(false, "上传失败!"));
  5131. }
  5132. }
  5133. catch (Exception ex)
  5134. {
  5135. return Ok(JsonView(false, ex.Message));
  5136. }
  5137. }
  5138. /// <summary>
  5139. /// 删除指定文件
  5140. /// </summary>
  5141. /// <param name="dto"></param>
  5142. /// <returns></returns>
  5143. [HttpPost]
  5144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5145. public async Task<IActionResult> DelFile(DelFileDto dto)
  5146. {
  5147. try
  5148. {
  5149. var TypeName = Request.Headers["TypeName"].ToString();
  5150. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5151. string filePath = "";
  5152. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5153. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5154. int id = 0;
  5155. if (TypeName == "A")
  5156. {
  5157. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5158. // 删除该文件
  5159. System.IO.File.Delete(filePath);
  5160. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5161. .Where(a => a.Id == dto.Id)
  5162. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5163. .ExecuteCommandAsync();
  5164. }
  5165. else if (TypeName == "B")
  5166. {
  5167. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5168. // 删除该文件
  5169. System.IO.File.Delete(filePath);
  5170. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5171. if (info != null)
  5172. {
  5173. string[] files = Array.Empty<string>();
  5174. if (!string.IsNullOrEmpty(info.Attachment))
  5175. {
  5176. try
  5177. {
  5178. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5179. }
  5180. catch (Exception)
  5181. {
  5182. files = new List<string>() { info.Attachment }.ToArray();
  5183. }
  5184. }
  5185. if (files.Length > 0)
  5186. {
  5187. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5188. string filePath2 = string.Empty;
  5189. if (files1.Length > 0)
  5190. {
  5191. filePath2 = JsonConvert.SerializeObject(files1);
  5192. }
  5193. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5194. .Where(a => a.Id == dto.Id)
  5195. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5196. .ExecuteCommandAsync();
  5197. }
  5198. }
  5199. }
  5200. if (id != 0)
  5201. {
  5202. return Ok(JsonView(true, "成功!"));
  5203. }
  5204. else
  5205. {
  5206. return Ok(JsonView(false, "失败!"));
  5207. }
  5208. }
  5209. catch (Exception ex)
  5210. {
  5211. return Ok(JsonView(false, "程序错误!"));
  5212. throw;
  5213. }
  5214. }
  5215. /// <summary>
  5216. /// 文件上传多个文件 可以带参数
  5217. /// </summary>
  5218. /// <param name="files"></param>
  5219. /// <returns></returns>
  5220. [HttpPost]
  5221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5222. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5223. {
  5224. try
  5225. {
  5226. var TypeName = Request.Headers["TypeName"].ToString();
  5227. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5228. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5229. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5230. var filePahts = new List<string>();
  5231. foreach (var file in files)
  5232. {
  5233. //文件名称
  5234. string projectFileName = file.FileName;
  5235. //上传的文件的路径
  5236. string filePath = $"{fileDir}/{projectFileName}";
  5237. if (TypeName == "A")//A代表团组增减款项
  5238. {
  5239. if (!Directory.Exists(fileDir))
  5240. {
  5241. Directory.CreateDirectory(fileDir);
  5242. }
  5243. //上传的文件的路径
  5244. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5245. }
  5246. else if (TypeName == "B")//B代表商邀相关文件
  5247. {
  5248. if (!Directory.Exists(fileDir))
  5249. {
  5250. Directory.CreateDirectory(fileDir);
  5251. }
  5252. //上传的文件的路径
  5253. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5254. }
  5255. using (FileStream fs = System.IO.File.Create(filePath))
  5256. {
  5257. file.CopyTo(fs);
  5258. fs.Flush();
  5259. }
  5260. filePahts.Add(projectFileName);
  5261. }
  5262. return Ok(JsonView(true, "上传成功!", filePahts));
  5263. }
  5264. catch (Exception ex)
  5265. {
  5266. return Ok(JsonView(false, ex.Message));
  5267. }
  5268. }
  5269. #endregion
  5270. #region 商邀费用录入
  5271. /// <summary>
  5272. /// 根据团组Id查询商邀费用列表
  5273. /// </summary>
  5274. /// <param name="dto"></param>
  5275. /// <returns></returns>
  5276. [HttpPost]
  5277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5278. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5279. {
  5280. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5281. if (groupData.Code != 0)
  5282. {
  5283. return Ok(JsonView(false, groupData.Msg));
  5284. }
  5285. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5286. }
  5287. /// <summary>
  5288. /// 商邀费用列表
  5289. /// 下载文件
  5290. /// </summary>
  5291. /// <param name="id"></param>
  5292. /// <returns></returns>
  5293. [HttpGet("{id}")]
  5294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5295. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5296. {
  5297. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5298. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5299. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5300. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5301. var filePaths = new List<string>();
  5302. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5303. try
  5304. {
  5305. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5306. }
  5307. catch (Exception ex)
  5308. {
  5309. filePaths.Add(info.Attachment);
  5310. }
  5311. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5312. for (int i = 0; i < filePaths.Count; i++)
  5313. {
  5314. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5315. }
  5316. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5317. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5318. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5319. {
  5320. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5321. {
  5322. foreach (string filePath in filePaths)
  5323. {
  5324. if (System.IO.File.Exists(filePath))
  5325. {
  5326. // 获取文件名
  5327. string fileName = Path.GetFileName(filePath);
  5328. // 将文件添加到ZIP归档中
  5329. zipArchive.CreateEntryFromFile(filePath, fileName);
  5330. }
  5331. }
  5332. }
  5333. }
  5334. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5335. }
  5336. /// <summary>
  5337. /// 商邀费用 Info Page 基础数据源
  5338. /// </summary>
  5339. /// <returns></returns>
  5340. [HttpPost]
  5341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5342. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5343. {
  5344. try
  5345. {
  5346. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5347. if (groupData.Code != 0)
  5348. {
  5349. return Ok(JsonView(false, groupData.Msg));
  5350. }
  5351. return Ok(JsonView(true, "操作成功", groupData.Data));
  5352. }
  5353. catch (Exception ex)
  5354. {
  5355. return Ok(JsonView(false, ex.Message));
  5356. throw;
  5357. }
  5358. }
  5359. /// <summary>
  5360. /// 根据商邀费用ID查询C表和商邀费用数据
  5361. /// </summary>
  5362. /// <param name="dto"></param>
  5363. /// <returns></returns>
  5364. [HttpPost]
  5365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5366. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5367. {
  5368. try
  5369. {
  5370. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5371. if (groupData.Code != 0)
  5372. {
  5373. return Ok(JsonView(false, groupData.Msg));
  5374. }
  5375. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5376. }
  5377. catch (Exception ex)
  5378. {
  5379. return Ok(JsonView(false, ex.Message));
  5380. throw;
  5381. }
  5382. }
  5383. /// <summary>
  5384. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5385. /// </summary>
  5386. /// <param name="dto"></param>
  5387. /// <returns></returns>
  5388. [HttpPost]
  5389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5390. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5391. {
  5392. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5393. if (groupData.Code != 0)
  5394. {
  5395. return Ok(JsonView(false, groupData.Msg));
  5396. }
  5397. #region 应用推送
  5398. try
  5399. {
  5400. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5401. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5402. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5403. //2024-10-21 新增LZ UID
  5404. var userIds = new List<int>() { 21 };
  5405. string title = $"系统通知";
  5406. string content = "";
  5407. var diId = dto.DiId;
  5408. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5409. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5410. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5411. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5412. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5413. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5414. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5415. }
  5416. catch (Exception ex)
  5417. {
  5418. }
  5419. #endregion
  5420. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5421. }
  5422. /// <summary>
  5423. /// 商邀删除
  5424. /// </summary>
  5425. /// <param name="dto"></param>
  5426. /// <returns></returns>
  5427. [HttpPost]
  5428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5429. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5430. {
  5431. try
  5432. {
  5433. _sqlSugar.BeginTran();
  5434. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5435. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5436. {
  5437. IsDel = 1,
  5438. DeleteUserId = dto.DeleteUserId,
  5439. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5440. })
  5441. .Where(it => it.Id == dto.Id)
  5442. .ExecuteCommand();
  5443. if (res1 > 0)
  5444. {
  5445. int _diId = 0;
  5446. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5447. if (_ioaInfo != null)
  5448. {
  5449. _diId = _ioaInfo.DiId;
  5450. }
  5451. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5452. .SetColumns(a => new Grp_CreditCardPayment()
  5453. {
  5454. IsDel = 1,
  5455. DeleteUserId = dto.DeleteUserId,
  5456. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5457. })
  5458. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5459. .ExecuteCommand();
  5460. if (res2 > 0)
  5461. {
  5462. _sqlSugar.CommitTran();
  5463. return Ok(JsonView(true, "删除成功!"));
  5464. }
  5465. }
  5466. _sqlSugar.RollbackTran();
  5467. return Ok(JsonView(false, "删除失败"));
  5468. }
  5469. catch (Exception ex)
  5470. {
  5471. _sqlSugar.RollbackTran();
  5472. return Ok(JsonView(false, ex.Message));
  5473. }
  5474. }
  5475. #endregion
  5476. #region 票据上传
  5477. /// <summary>
  5478. /// 团组模块文件上传
  5479. /// </summary>
  5480. /// <param name="dto"></param>
  5481. /// <returns></returns>
  5482. [HttpPost]
  5483. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5484. {
  5485. var jw = JsonView(false);
  5486. long M = 1024 * 1024;
  5487. if (dto.Files == null || dto.Files.Count == 0)
  5488. {
  5489. jw.Msg = "无文件信息!";
  5490. return Ok(jw);
  5491. }
  5492. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5493. {
  5494. jw.Msg = "文件大小超过20M!";
  5495. return Ok(jw);
  5496. }
  5497. //var nameSp = dto.File.FileName.Split(".");
  5498. //if (nameSp.Length < 2)
  5499. //{
  5500. // jw.Msg = "拓展名称有误!";
  5501. // return Ok(jw);
  5502. //}
  5503. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5504. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5505. //{
  5506. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5507. // return Ok(jw);
  5508. //}
  5509. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5510. if (Ctable == null)
  5511. {
  5512. jw.Msg = "Ctable指向有误!";
  5513. return Ok(jw);
  5514. }
  5515. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5516. if (groupInfo == null)
  5517. {
  5518. jw.Msg = "团组信息不存在!";
  5519. return Ok(jw);
  5520. }
  5521. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5522. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5523. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5524. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5525. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5526. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5527. try
  5528. {
  5529. if (!Directory.Exists(fileBase))
  5530. {
  5531. Directory.CreateDirectory(fileBase);
  5532. }
  5533. var saveArr = new List<Grp_GroupModelFile>();
  5534. foreach (var fileStream in dto.Files)
  5535. {
  5536. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5537. var file = new Grp_GroupModelFile()
  5538. {
  5539. Cid = dto.Cid,
  5540. CreateTime = DateTime.Now,
  5541. CreateUserId = dto.Userid,
  5542. Ctable = dto.Ctable,
  5543. Diid = dto.Diid,
  5544. IsDel = 0,
  5545. FilePath = saveFilePath,
  5546. FileName = fileStream.FileName
  5547. };
  5548. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5549. {
  5550. fileStream.CopyTo(fs);
  5551. fs.Flush();
  5552. }
  5553. saveArr.Add(file);
  5554. }
  5555. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5556. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5557. jw = JsonView(true, "保存成功!", new
  5558. {
  5559. count = addResult,
  5560. filesName = saveArr.Select(x => x.FileName)
  5561. });
  5562. }
  5563. catch (Exception ex)
  5564. {
  5565. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5566. {
  5567. count = 0,
  5568. filesName = Array.Empty<string>(),
  5569. });
  5570. }
  5571. return Ok(jw);
  5572. }
  5573. /// <summary>
  5574. /// 查询各模块已保存文件
  5575. /// </summary>
  5576. /// <param name="dto"></param>
  5577. /// <returns></returns>
  5578. [HttpPost]
  5579. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5580. {
  5581. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5582. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5583. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5584. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5585. {
  5586. expression = Expressionable.Create<Grp_GroupModelFile>()
  5587. .And(x => visaIds.Contains(x.CreateUserId));
  5588. }
  5589. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5590. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5591. .Where(expression.ToExpression())
  5592. .ToList();
  5593. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5594. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5595. {
  5596. x.FileName,
  5597. x.Id,
  5598. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5599. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5600. })));
  5601. }
  5602. /// <summary>
  5603. /// 下载该团组下的所有文件
  5604. /// </summary>
  5605. /// <param name="dto"></param>
  5606. /// <returns></returns>
  5607. [HttpPost]
  5608. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5609. {
  5610. var jw = JsonView(false);
  5611. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5612. if (groupInfo == null)
  5613. {
  5614. jw.Msg = "团组信息不存在!";
  5615. return Ok(jw);
  5616. }
  5617. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5618. var isModule = Convert.ToBoolean(dto.isModule);
  5619. var Zips = new Dictionary<string, Stream>();
  5620. var io = new IOOperatorHelper();
  5621. if (isModule)
  5622. {
  5623. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5624. foreach (var moduleArr in moduleGroup)
  5625. {
  5626. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5627. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5628. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5629. var chiZips = new Dictionary<string, Stream>();
  5630. foreach (var item in moduleArr)
  5631. {
  5632. if (System.IO.File.Exists(item.FilePath))
  5633. {
  5634. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5635. {
  5636. byte[] bytes = new byte[fileStream.Length];
  5637. fileStream.Read(bytes, 0, bytes.Length);
  5638. fileStream.Close();
  5639. Stream stream = new MemoryStream(bytes);
  5640. chiZips.Add(item.FileName, stream);
  5641. }
  5642. }
  5643. }
  5644. if (chiZips.Count > 0)
  5645. {
  5646. var byts = io.ConvertZipStream(chiZips);
  5647. Stream stream = new MemoryStream(byts);
  5648. Zips.Add(key.Name + "_.zip", stream);
  5649. }
  5650. }
  5651. }
  5652. else
  5653. {
  5654. foreach (var item in dbQuery)
  5655. {
  5656. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5657. {
  5658. byte[] bytes = new byte[fileStream.Length];
  5659. fileStream.Read(bytes, 0, bytes.Length);
  5660. fileStream.Close();
  5661. var stream = new MemoryStream(bytes);
  5662. while (Zips.ContainsKey(item.FileName))
  5663. {
  5664. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5665. }
  5666. Zips.Add(item.FileName, stream);
  5667. }
  5668. }
  5669. }
  5670. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5671. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5672. if (Zips.Count > 0)
  5673. {
  5674. var byts = io.ConvertZipStream(Zips);
  5675. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5676. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5677. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5678. }
  5679. else
  5680. {
  5681. jw.Msg = "暂无生成文件!";
  5682. }
  5683. return Ok(jw);
  5684. }
  5685. /// <summary>
  5686. /// 下载该团组下此模块的所有文件
  5687. /// </summary>
  5688. /// <param name="dto"></param>
  5689. /// <returns></returns>
  5690. [HttpPost]
  5691. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5692. {
  5693. var jw = JsonView(false);
  5694. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5695. if (groupInfo == null)
  5696. {
  5697. jw.Msg = "团组信息不存在!";
  5698. return Ok(jw);
  5699. }
  5700. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5701. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5702. && x.IsDel == 0);
  5703. if (key == null)
  5704. {
  5705. jw.Msg = "Ctable指向错误!";
  5706. return Ok(jw);
  5707. }
  5708. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5709. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5710. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5711. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5712. var io = new IOOperatorHelper();
  5713. var Zips = new Dictionary<string, Stream>();
  5714. foreach (var item in dbQuery)
  5715. {
  5716. if (System.IO.File.Exists(item.FilePath))
  5717. {
  5718. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5719. {
  5720. byte[] bytes = new byte[fileStream.Length];
  5721. fileStream.Read(bytes, 0, bytes.Length);
  5722. fileStream.Close();
  5723. var stream = new MemoryStream(bytes);
  5724. while (Zips.ContainsKey(item.FileName))
  5725. {
  5726. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5727. }
  5728. Zips.Add(item.FileName, stream);
  5729. }
  5730. }
  5731. }
  5732. if (Zips.Count > 0)
  5733. {
  5734. var byts = io.ConvertZipStream(Zips);
  5735. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5736. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5737. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5738. }
  5739. else
  5740. {
  5741. jw.Msg = "暂无生成文件!";
  5742. }
  5743. return Ok(jw);
  5744. }
  5745. /// <summary>
  5746. /// 删除该团组下的指定文件
  5747. /// </summary>
  5748. /// <param name="dto"></param>
  5749. /// <returns></returns>
  5750. [HttpPost]
  5751. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5752. {
  5753. var jw = JsonView(false);
  5754. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5755. if (sing == null)
  5756. {
  5757. jw.Msg = "暂无";
  5758. return Ok(jw);
  5759. }
  5760. if (System.IO.File.Exists(sing.FilePath))
  5761. {
  5762. try
  5763. {
  5764. System.IO.File.Delete(sing.FilePath);
  5765. }
  5766. catch (Exception ex)
  5767. {
  5768. jw.Msg = "删除失败!" + ex.Message;
  5769. return Ok(jw);
  5770. }
  5771. }
  5772. sing.IsDel = 1;
  5773. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5774. sing.DeleteUserId = dto.UserId;
  5775. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5776. jw = JsonView(true, "删除成功!");
  5777. return Ok(jw);
  5778. }
  5779. #endregion
  5780. #region 共享文件上传
  5781. /// <summary>
  5782. /// 共享文件数据初始化
  5783. /// </summary>
  5784. /// <returns></returns>
  5785. [HttpGet]
  5786. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5787. {
  5788. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5789. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5790. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5791. .Select(x => x.Id)
  5792. .ToList()
  5793. .Contains(userid);
  5794. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5795. .Where(x => x.STid == 111 && x.IsDel == 0)
  5796. .Select(x => new
  5797. {
  5798. x.Name,
  5799. x.Id,
  5800. }).ToList();
  5801. if (isMarketingDepartment)
  5802. {
  5803. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5804. }
  5805. if (portType == 1)
  5806. {
  5807. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5808. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5809. .Where(x => x.IsDel == 0)
  5810. .OrderByDescending(x => x.VisitDate)
  5811. .Select(x => new
  5812. {
  5813. x.TeamName,
  5814. x.Id,
  5815. x.CityId,
  5816. })
  5817. .ToList()
  5818. .Select(x =>
  5819. {
  5820. var provinceId = x.CityId;
  5821. var isDefualtVal = true;
  5822. if (provinceId > 0)
  5823. {
  5824. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5825. if (parentId != null)
  5826. {
  5827. isDefualtVal = false;
  5828. provinceId = (int)parentId;
  5829. }
  5830. }
  5831. if (isDefualtVal)
  5832. {
  5833. provinceId = 122; //默认四川
  5834. }
  5835. return new
  5836. {
  5837. x.TeamName,
  5838. x.Id,
  5839. provinceId,
  5840. };
  5841. })
  5842. .ToList();
  5843. return Ok(JsonView(true, "SUCCESS!", new
  5844. {
  5845. dropDownType,
  5846. dropDownGroupList,
  5847. isMarketingDepartment
  5848. }));
  5849. }
  5850. else if (portType == 2 || portType == 3)
  5851. {
  5852. return Ok(JsonView(true, "SUCCESS!", new
  5853. {
  5854. dropDownType,
  5855. isMarketingDepartment
  5856. }));
  5857. }
  5858. else
  5859. {
  5860. return Ok(JsonView(false, "portType有误!"));
  5861. }
  5862. }
  5863. /// <summary>
  5864. /// 共享文件上传
  5865. /// </summary>
  5866. /// <param name="dto"></param>
  5867. /// <returns></returns>
  5868. [HttpPost]
  5869. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5870. {
  5871. var isGroup = new List<int> { 1412 };
  5872. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5873. {
  5874. return Ok(JsonView(false, "该文件需要关联团组!"));
  5875. }
  5876. if (dto.Files == null || dto.Files.Count == 0)
  5877. {
  5878. return Ok(JsonView(false, "无文件信息!"));
  5879. }
  5880. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5881. {
  5882. return Ok(JsonView(false, "文件大小超过20M!"));
  5883. }
  5884. if (dto.Userid < 1)
  5885. {
  5886. return Ok(JsonView(false, "请传入有效的Userid!"));
  5887. }
  5888. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5889. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5890. .Select((u, j) => new
  5891. {
  5892. u.CnName,
  5893. UserId = u.Id,
  5894. j.JobName,
  5895. })
  5896. .First();
  5897. if (jobInfo == null)
  5898. {
  5899. return Ok(JsonView(false, "请传入有效的Userid!"));
  5900. }
  5901. var commonFileExtensions = new List<string>
  5902. {
  5903. // 文本文件
  5904. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5905. // 图片文件
  5906. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5907. // 视频文件
  5908. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5909. // 音频文件
  5910. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5911. // 压缩文件
  5912. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5913. // 数据文件
  5914. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5915. };
  5916. try
  5917. {
  5918. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5919. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5920. commonFileExtensions.AddRange(settingExtend);
  5921. }
  5922. catch (Exception)
  5923. { }
  5924. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5925. if (setdata == null)
  5926. {
  5927. return Ok(JsonView(false, "请传入有效的FileType!"));
  5928. }
  5929. var insertList = new List<Grp_GroupShareFile>();
  5930. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5931. if (!Directory.Exists(winPath))
  5932. {
  5933. Directory.CreateDirectory(winPath);
  5934. }
  5935. foreach (var item in dto.Files)
  5936. {
  5937. var houzui = Path.GetExtension(item.FileName);
  5938. if (!commonFileExtensions.Contains(houzui))
  5939. {
  5940. return Ok(JsonView(false, "未知后缀名称!"));
  5941. }
  5942. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5943. var saveFilePath = winPath + fileName;
  5944. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5945. {
  5946. item.CopyTo(fs);
  5947. fs.Flush();
  5948. }
  5949. var fileDetail = new Grp_GroupShareFile()
  5950. {
  5951. CreateUserId = dto.Userid,
  5952. CreateTime = DateTime.Now,
  5953. UploadJob = jobInfo.JobName,
  5954. FileName = fileName,
  5955. FileType = dto.FileType,
  5956. Diid = dto.Diid,
  5957. FilePath = winPath + fileName,
  5958. };
  5959. insertList.Add(fileDetail);
  5960. }
  5961. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5962. return Ok(JsonView(true, "保存成功!"));
  5963. }
  5964. /// <summary>
  5965. /// 查询共享文件列表
  5966. /// </summary>
  5967. /// <param name="dto"></param>
  5968. /// <returns></returns>
  5969. [HttpPost]
  5970. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5971. {
  5972. var isGroup = new List<int> { 1412 };
  5973. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5974. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5975. .And(x => x.Diid == dto.Diid)
  5976. .And(x => x.FileType == dto.FileType)
  5977. .And(x => x.IsDel == 0)
  5978. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5979. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5980. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5981. int totalCount = 0;
  5982. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5983. .Where(queryExpression.ToExpression())
  5984. .OrderBy(x => x.UploadJob)
  5985. .Select(x => new
  5986. {
  5987. x.Id,
  5988. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5989. x.FileName,
  5990. x.FileType,
  5991. x.CreateTime,
  5992. })
  5993. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5994. return Ok(JsonView(true, "SUCCESS!", new
  5995. {
  5996. FileList = dbQuery,
  5997. dto.PageSize,
  5998. dto.PageIndex,
  5999. totalCount
  6000. }));
  6001. }
  6002. /// <summary>
  6003. /// 删除共享文件模块下的指定文件
  6004. /// </summary>
  6005. /// <param name="dto"></param>
  6006. /// <returns></returns>
  6007. [HttpPost]
  6008. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6009. {
  6010. var jw = JsonView(false);
  6011. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6012. if (sing == null)
  6013. {
  6014. jw.Msg = "暂无文件信息!";
  6015. return Ok(jw);
  6016. }
  6017. if (sing.CreateUserId != dto.UserId)
  6018. {
  6019. jw.Msg = "只能删除自己上传的文件!";
  6020. return Ok(jw);
  6021. }
  6022. if (System.IO.File.Exists(sing.FilePath))
  6023. {
  6024. try
  6025. {
  6026. System.IO.File.Delete(sing.FilePath);
  6027. }
  6028. catch (Exception ex)
  6029. {
  6030. jw.Msg = "删除失败!" + ex.Message;
  6031. return Ok(jw);
  6032. }
  6033. }
  6034. sing.IsDel = 1;
  6035. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6036. sing.DeleteUserId = dto.UserId;
  6037. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6038. jw = JsonView(true, "删除成功!");
  6039. return Ok(jw);
  6040. }
  6041. #endregion
  6042. #region 团组英文资料
  6043. /// <summary>
  6044. /// 查询团组英文所有资料
  6045. /// </summary>
  6046. /// <param name="dto"></param>
  6047. /// <returns></returns>
  6048. [HttpPost]
  6049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6050. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6051. {
  6052. try
  6053. {
  6054. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6055. if (groupData.Code != 0)
  6056. {
  6057. return Ok(JsonView(false, groupData.Msg));
  6058. }
  6059. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6060. }
  6061. catch (Exception ex)
  6062. {
  6063. return Ok(JsonView(false, ex.Message));
  6064. throw;
  6065. }
  6066. }
  6067. /// <summary>
  6068. /// 团组英文资料操作(Status:1.新增,2.修改)
  6069. /// </summary>
  6070. /// <param name="dto"></param>
  6071. /// <returns></returns>
  6072. [HttpPost]
  6073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6074. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6075. {
  6076. try
  6077. {
  6078. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6079. if (groupData.Code != 0)
  6080. {
  6081. return Ok(JsonView(false, groupData.Msg));
  6082. }
  6083. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6084. }
  6085. catch (Exception ex)
  6086. {
  6087. return Ok(JsonView(false, ex.Message));
  6088. throw;
  6089. }
  6090. }
  6091. /// <summary>
  6092. /// 团组英文资料Id查询数据
  6093. /// </summary>
  6094. /// <param name="dto"></param>
  6095. /// <returns></returns>
  6096. [HttpPost]
  6097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6098. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6099. {
  6100. try
  6101. {
  6102. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6103. if (_DelegationEnData != null)
  6104. {
  6105. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6106. }
  6107. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6108. }
  6109. catch (Exception ex)
  6110. {
  6111. return Ok(JsonView(false, "程序错误!"));
  6112. throw;
  6113. }
  6114. }
  6115. /// <summary>
  6116. /// 团组英文资料删除
  6117. /// </summary>
  6118. /// <param name="dto"></param>
  6119. /// <returns></returns>
  6120. [HttpPost]
  6121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6122. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6123. {
  6124. try
  6125. {
  6126. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6127. if (!res)
  6128. {
  6129. return Ok(JsonView(false, "删除失败"));
  6130. }
  6131. return Ok(JsonView(true, "删除成功!"));
  6132. }
  6133. catch (Exception ex)
  6134. {
  6135. return Ok(JsonView(false, ex.Message));
  6136. throw;
  6137. }
  6138. }
  6139. #endregion
  6140. #region 导出邀请函
  6141. /// <summary>
  6142. /// 导出邀请函页面初始化
  6143. /// </summary>
  6144. /// <param name="dto"></param>
  6145. /// <returns></returns>
  6146. [HttpPost]
  6147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6148. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6149. {
  6150. try
  6151. {
  6152. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6153. var crm_Deles = new List<Crm_DeleClient>();
  6154. if (dto.DiId == 0)
  6155. {
  6156. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6157. }
  6158. else
  6159. {
  6160. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6161. }
  6162. return Ok(JsonView(true, "查询成功!", new
  6163. {
  6164. deleClient = crm_Deles,
  6165. delegations = grp_Delegations
  6166. }));
  6167. }
  6168. catch (Exception ex)
  6169. {
  6170. return Ok(JsonView(false, "程序错误!"));
  6171. throw;
  6172. }
  6173. }
  6174. /// <summary>
  6175. /// 导出邀请函
  6176. /// </summary>
  6177. /// <param name="dto"></param>
  6178. /// <returns></returns>
  6179. [HttpPost]
  6180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6181. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6182. {
  6183. #region 参数验证
  6184. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6185. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6186. #endregion
  6187. try
  6188. {
  6189. var transDic = new Dictionary<string, string>();
  6190. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6191. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6192. From Grp_TourClientList tcl
  6193. Left Join
  6194. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6195. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6196. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6197. From Crm_DeleClient dc
  6198. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6199. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6200. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6201. Where dc.IsDel = 0) temp
  6202. On temp.DcId =tcl.ClientId
  6203. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6204. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6205. var texts = new List<string>();
  6206. if (datas.Count != 0)
  6207. {
  6208. foreach (TourClientListDetailsView item in datas)
  6209. {
  6210. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6211. {
  6212. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6213. }
  6214. else
  6215. {
  6216. string name = item.LastName + item.FirstName;
  6217. texts.Add(name);
  6218. }
  6219. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6220. {
  6221. if (!transDic.ContainsKey(item.Job))
  6222. {
  6223. texts.Add(item.Job);
  6224. }
  6225. }
  6226. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6227. {
  6228. texts.Add(item.CompanyFullName);
  6229. }
  6230. }
  6231. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6232. if (transData.Count > 0)
  6233. {
  6234. foreach (TranslateResult item in transData)
  6235. {
  6236. if (!transDic.ContainsKey(item.Query))
  6237. {
  6238. transDic.Add(item.Query, item.Translation);
  6239. }
  6240. }
  6241. }
  6242. var list = new List<GuestList>();
  6243. foreach (var dele in datas)
  6244. {
  6245. var guestList = new GuestList();
  6246. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6247. {
  6248. guestList.Name = dele.Pinyin;
  6249. }
  6250. else
  6251. {
  6252. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6253. guestList.Name = Name;
  6254. }
  6255. if (dele.Sex == 0)
  6256. {
  6257. guestList.Sex = "Male";
  6258. }
  6259. else if (dele.Sex == 1)
  6260. {
  6261. guestList.Sex = "Female";
  6262. }
  6263. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6264. if (!string.IsNullOrEmpty(dele.Job))
  6265. {
  6266. guestList.Job = dele.Job;
  6267. }
  6268. list.Add(guestList);
  6269. }
  6270. //载入模板
  6271. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6272. var builder = new DocumentBuilder(doc);
  6273. //获取word里所有表格
  6274. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6275. //获取所填表格的序数
  6276. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6277. var rowStart = tableOne.Rows[0]; //获取第1行
  6278. //循环赋值
  6279. for (int i = 0; i < list.Count; i++)
  6280. {
  6281. builder.MoveToCell(0, i + 1, 0, 0);
  6282. builder.Write(list[i].Name.ToString());
  6283. builder.MoveToCell(0, i + 1, 1, 0);
  6284. builder.Write(list[i].Sex.ToString());
  6285. builder.MoveToCell(0, i + 1, 2, 0);
  6286. builder.Write(list[i].DOB.ToString());
  6287. builder.MoveToCell(0, i + 1, 3, 0);
  6288. builder.Write(list[i].Job.ToString());
  6289. }
  6290. //删除多余行
  6291. while (tableOne.Rows.Count > list.Count + 1)
  6292. {
  6293. tableOne.Rows.RemoveAt(list.Count + 1);
  6294. }
  6295. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6296. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6297. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6298. doc.Save(filePath);
  6299. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6300. return Ok(JsonView(true, "操作成功!", Url));
  6301. }
  6302. else
  6303. {
  6304. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6305. }
  6306. }
  6307. catch (Exception ex)
  6308. {
  6309. return Ok(JsonView(false, ex.Message));
  6310. throw;
  6311. }
  6312. }
  6313. #endregion
  6314. #region 团组经理模块 出入境费用
  6315. /// <summary>
  6316. /// 团组模块 - 出入境费用 - 省份基础数据源
  6317. /// </summary>
  6318. /// <returns></returns>
  6319. [HttpGet]
  6320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6321. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6322. {
  6323. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6324. }
  6325. /// <summary>
  6326. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6327. /// </summary>
  6328. /// <param name="dto"></param>
  6329. /// <returns></returns>
  6330. [HttpPost]
  6331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6332. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6333. {
  6334. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6335. var groupNamFirst = groupNameData.FirstOrDefault();
  6336. //SetDataInfoView
  6337. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6338. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6339. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6340. //验证城市归属并给默认值
  6341. int provinceId = 122;
  6342. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6343. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6344. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6345. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6346. return Ok(JsonView(true, "查询成功!", new
  6347. {
  6348. GroupNameData = groupNameData,
  6349. CurrencyData = _CurrencyData,
  6350. WordTypeData = wordTypeData,
  6351. ExcelTypeData = excelTypeData,
  6352. CurrencyInit = _currencyInfos,
  6353. ViewPermissionData = viewPermissionData
  6354. }));
  6355. }
  6356. /// <summary>
  6357. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6358. /// </summary>
  6359. /// <returns></returns>
  6360. [HttpGet("{provinceId}")]
  6361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6362. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6363. {
  6364. //验证城市归属并给默认值
  6365. if (provinceId < 1) provinceId = 122;
  6366. /*
  6367. * 122 四川
  6368. * 108 贵州
  6369. * 103 重庆
  6370. * 132 云南
  6371. */
  6372. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6373. return Ok(JsonView(true, "查询成功!", new
  6374. {
  6375. WordTypeData = wordTypeData,
  6376. ExcelTypeData = excelTypeData,
  6377. }));
  6378. }
  6379. /// <summary>
  6380. /// 团组模块 - 出入境费用
  6381. /// 实时汇率 tips
  6382. /// 签证费用 tips
  6383. /// 机票费用 tips
  6384. /// </summary>
  6385. /// <returns></returns>
  6386. [HttpPost]
  6387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6388. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6389. {
  6390. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6391. //默认币种显示
  6392. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6393. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6394. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6395. return Ok(JsonView(true, "查询成功!", new
  6396. {
  6397. //GroupNameData = groupNameData.Data,
  6398. visaData = visaData.Data,
  6399. airData,
  6400. reteInfos
  6401. }));
  6402. }
  6403. /// <summary>
  6404. /// 团组模块 - 出入境费用 - Info
  6405. /// </summary>
  6406. /// <param name="dto"></param>
  6407. /// <returns></returns>
  6408. [HttpPost]
  6409. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6411. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6412. {
  6413. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6414. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6415. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6416. }
  6417. /// <summary>
  6418. /// 团组模块 - 出入境费用 - 设置view权限
  6419. /// </summary>
  6420. /// <returns></returns>
  6421. [HttpPost]
  6422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6423. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6424. {
  6425. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6426. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6427. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6428. var permissions = new List<Grp_EnterExitCostPermission>();
  6429. foreach (var userId in dto.UserIds)
  6430. {
  6431. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6432. }
  6433. if (permissions.Any())
  6434. {
  6435. _sqlSugar.BeginTran();
  6436. try
  6437. {
  6438. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6439. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6440. if (result < 1)
  6441. {
  6442. _sqlSugar.RollbackTran();
  6443. return Ok(JsonView(false));
  6444. }
  6445. }
  6446. catch (Exception ex)
  6447. {
  6448. _sqlSugar.RollbackTran();
  6449. return Ok(JsonView(false, ex.Message));
  6450. }
  6451. _sqlSugar.CommitTran();
  6452. return Ok(JsonView(true));
  6453. }
  6454. return Ok(JsonView(false));
  6455. }
  6456. /// <summary>
  6457. /// 团组模块 - 出入境费用 - Add And Update
  6458. /// </summary>
  6459. /// <returns></returns>
  6460. [HttpPost]
  6461. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6463. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6464. {
  6465. try
  6466. {
  6467. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6468. if (dto.DayOtherPriceData.Any())
  6469. {
  6470. var inserList = dto.DayOtherPriceData
  6471. .Where(x => x.Id == 0)
  6472. .Select(x => new Grp_DayOtherPrice
  6473. {
  6474. Cost = x.Cost,
  6475. Id = x.Id,
  6476. CreateTime = DateTime.Now,
  6477. CreateUserId = dto.UserId,
  6478. Currency = x.Currency,
  6479. Diid = x.DiId,
  6480. Index = x.Index,
  6481. IsDel = 0,
  6482. SetDataId = x.SetDataId,
  6483. SubTotal = x.SubTotal,
  6484. Remark = x.Remark
  6485. })
  6486. .ToList();
  6487. var updateList = dto.DayOtherPriceData
  6488. .Where(x => x.Id != 0)
  6489. .Select(x => new Grp_DayOtherPrice
  6490. {
  6491. Cost = x.Cost,
  6492. Id = x.Id,
  6493. CreateTime = DateTime.Now,
  6494. CreateUserId = dto.UserId,
  6495. Currency = x.Currency,
  6496. Diid = x.DiId,
  6497. Index = x.Index,
  6498. IsDel = 0,
  6499. SetDataId = x.SetDataId,
  6500. SubTotal = x.SubTotal,
  6501. Remark = x.Remark
  6502. })
  6503. .ToList();
  6504. //添加
  6505. _sqlSugar.BeginTran();
  6506. if (inserList.Any())
  6507. {
  6508. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6509. }
  6510. if (updateList.Any())
  6511. {
  6512. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6513. }
  6514. _sqlSugar.CommitTran();
  6515. }
  6516. if (data.Code != 0)
  6517. {
  6518. return Ok(JsonView(false, data.Msg));
  6519. }
  6520. //生成默认文件pdf并且通知人员
  6521. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6522. {
  6523. DiId = dto.DiId,
  6524. ExportType = 1,
  6525. SubTypeId = 1005
  6526. }, "pdf");
  6527. //发送通知
  6528. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6529. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6530. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6531. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6532. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6533. //汇率信息记录
  6534. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6535. return Ok(JsonView(true, data.Msg, data.Data));
  6536. }
  6537. catch (Exception ex)
  6538. {
  6539. return Ok(JsonView(false, ex.Message));
  6540. }
  6541. }
  6542. /// <summary>
  6543. /// 团组模块 - 出入境费用 - Confirm 费用
  6544. /// </summary>
  6545. /// <returns></returns>
  6546. [HttpPost]
  6547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6548. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6549. {
  6550. //TODO:测试完毕需把对应的用户ID更改
  6551. //1、数据表添加字段
  6552. //2、更改字段接口()
  6553. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6554. //3、确认成功 给财务发送消息
  6555. if (_view.Code == 200)
  6556. {
  6557. if (dto.Type == 1)
  6558. {
  6559. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6560. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6561. }
  6562. }
  6563. return Ok(_view);
  6564. }
  6565. /// <summary>
  6566. /// 团组模块 - 出入境费用 - File download
  6567. /// </summary>
  6568. /// <param name="dto"></param>
  6569. /// <returns></returns>
  6570. [HttpPost]
  6571. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6573. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6574. {
  6575. try
  6576. {
  6577. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6578. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6579. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6580. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6581. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6582. 3 团组成员名单 1 团组成员名单", ""));
  6583. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6584. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6585. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6586. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6587. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6588. //数据源
  6589. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6590. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6591. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6592. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6593. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6594. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6595. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6596. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6597. .Select((x, a, b) => new
  6598. {
  6599. x.Index,
  6600. itemName = a.Name,
  6601. CurrencyStr = b.Name,
  6602. x.Cost,
  6603. x.SubTotal,
  6604. x.Remark
  6605. })
  6606. .OrderBy((x) => x.Index)
  6607. .ToList(); //其他款项费用
  6608. var peiceItemCurrencys = new List<string>();
  6609. if (_DayAndCosts.Any())
  6610. {
  6611. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6612. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6613. }
  6614. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6615. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6616. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6617. {
  6618. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6619. }
  6620. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6621. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6622. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6623. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6624. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6625. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6626. .Select((tcl, dc, cc) => new ClientInfo
  6627. {
  6628. LastName = dc.LastName,
  6629. FirstName = dc.FirstName,
  6630. Sex = dc.Sex,
  6631. Birthday = dc.BirthDay,
  6632. Company = cc.CompanyFullName,
  6633. Job = dc.Job
  6634. })
  6635. .ToList();
  6636. foreach (var item in DeleClientList)
  6637. {
  6638. EncryptionProcessor.DecryptProperties(item);
  6639. }
  6640. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6641. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6642. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6643. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6644. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6645. if (dto.ExportType == 1) //明细表
  6646. {
  6647. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6648. {
  6649. //获取模板
  6650. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6651. //载入模板
  6652. var doc = new Document(tempPath);
  6653. var builder = new DocumentBuilder(doc);
  6654. var dic = new Dictionary<string, string>();
  6655. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6656. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6657. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6658. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6659. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6660. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6661. //境内费用(其他费用)
  6662. if (_EnterExitCosts.ChoiceOne == 1)
  6663. {
  6664. string row1_1 = "";
  6665. if (_EnterExitCosts.Visa > 0)
  6666. {
  6667. //insidePayTotal += _EnterExitCosts.Visa;
  6668. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 人民币/人";
  6669. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6670. //{
  6671. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6672. //}
  6673. }
  6674. string row1_2 = "";
  6675. if (_EnterExitCosts.YiMiao > 0)
  6676. {
  6677. //insidePayTotal += _EnterExitCosts.YiMiao;
  6678. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 人民币/人";
  6679. }
  6680. if (_EnterExitCosts.HeSuan > 0)
  6681. {
  6682. //insidePayTotal += _EnterExitCosts.HeSuan;
  6683. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 人民币/人";
  6684. }
  6685. if (_EnterExitCosts.Service > 0)
  6686. {
  6687. //insidePayTotal += _EnterExitCosts.Service;
  6688. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 人民币/人";
  6689. }
  6690. string row1_3 = "";
  6691. if (_EnterExitCosts.Safe > 0)
  6692. {
  6693. //insidePayTotal += _EnterExitCosts.Safe;
  6694. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 人民币/人";
  6695. }
  6696. if (_EnterExitCosts.Ticket > 0)
  6697. {
  6698. //insidePayTotal += _EnterExitCosts.Ticket;
  6699. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 人民币/人";
  6700. }
  6701. string row1 = "";
  6702. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6703. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6704. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6705. row1 += $"备注:{_EnterExitCosts.Remark}";
  6706. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6707. dic.Add("Row1Str", row1);
  6708. }
  6709. string airTotalStr = string.Empty,
  6710. airPriceStr = string.Empty;
  6711. //经济舱
  6712. if (_EnterExitCosts.SumJJC == 1)
  6713. {
  6714. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6715. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6716. }
  6717. //公务舱
  6718. if (_EnterExitCosts.SumGWC == 1)
  6719. {
  6720. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6721. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6722. }
  6723. //头等舱
  6724. if (_EnterExitCosts.SumTDC == 1)
  6725. {
  6726. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6727. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6728. }
  6729. //汇率描述
  6730. string rateStr = "";
  6731. if (peiceItemCurrencyInfos.Any())
  6732. {
  6733. rateStr = "\r\n汇率描述:";
  6734. foreach (var item in peiceItemCurrencyInfos)
  6735. {
  6736. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  6737. }
  6738. }
  6739. string twoItemRemark = "备注:";
  6740. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6741. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6742. dic.Add("AirTotalStr", airTotalStr);
  6743. dic.Add("AirPriceStr", airPriceStr);
  6744. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6745. dic.Add("TwoItemRemark", twoItemRemark);
  6746. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6747. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6748. int table1Row = 0,
  6749. table2Row = 0,
  6750. table3Row = 0,
  6751. table4Row = 0,
  6752. table5Row = 0;
  6753. //住宿费
  6754. if (_EnterExitCosts.ChoiceThree == 1)
  6755. {
  6756. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6757. table1Row = dac1.Count;
  6758. #region 填充word表格内容
  6759. for (int i = 0; i < dac1.Count; i++)
  6760. {
  6761. Grp_DayAndCost dac = dac1[i];
  6762. if (dac == null) continue;
  6763. builder.MoveToCell(0, i, 0, 0);
  6764. builder.Write("第" + dac.Days.ToString() + "晚:");
  6765. builder.MoveToCell(0, i, 1, 0);
  6766. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6767. //builder.Write(dac.Place == null ? "" : dac.Place);
  6768. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6769. builder.MoveToCell(0, i, 2, 0);
  6770. builder.Write("费用标准:");
  6771. string curr = "";
  6772. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6773. if (currData != null)
  6774. {
  6775. curr = currData.Name;
  6776. }
  6777. builder.MoveToCell(0, i, 3, 0);
  6778. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6779. builder.MoveToCell(0, i, 4, 0);
  6780. builder.Write("费用小计:");
  6781. builder.MoveToCell(0, i, 5, 0);
  6782. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6783. }
  6784. #endregion
  6785. }
  6786. else dic.Add("SubZS", "0.00");
  6787. //删除多余行
  6788. while (table1.Rows.Count > table1Row)
  6789. {
  6790. table1.Rows.RemoveAt(table1Row);
  6791. }
  6792. //伙食费
  6793. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6794. if (_EnterExitCosts.ChoiceFour == 1)
  6795. {
  6796. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6797. table2Row = dac2.Count;
  6798. #region 填充word表格内容
  6799. for (int i = 0; i < dac2.Count; i++)
  6800. {
  6801. Grp_DayAndCost dac = dac2[i];
  6802. if (dac == null) continue;
  6803. builder.MoveToCell(1, i, 0, 0);
  6804. builder.Write("第" + dac.Days.ToString() + "天:");
  6805. builder.MoveToCell(1, i, 1, 0);
  6806. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6807. builder.MoveToCell(1, i, 2, 0);
  6808. builder.Write("费用标准:");
  6809. string curr = "";
  6810. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6811. if (currData != null)
  6812. {
  6813. curr = currData.Name;
  6814. }
  6815. builder.MoveToCell(1, i, 3, 0);
  6816. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6817. builder.MoveToCell(1, i, 4, 0);
  6818. builder.Write("费用小计:");
  6819. builder.MoveToCell(1, i, 5, 0);
  6820. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6821. }
  6822. #endregion
  6823. }
  6824. else dic.Add("SubHS", "0.00");
  6825. //删除多余行
  6826. while (table2.Rows.Count > table2Row)
  6827. {
  6828. table2.Rows.RemoveAt(table2Row);
  6829. }
  6830. //公杂费
  6831. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6832. if (_EnterExitCosts.ChoiceFive == 1)
  6833. {
  6834. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6835. table3Row = dac3.Count;
  6836. #region 填充word表格内容
  6837. for (int i = 0; i < dac3.Count; i++)
  6838. {
  6839. Grp_DayAndCost dac = dac3[i];
  6840. if (dac == null) continue;
  6841. builder.MoveToCell(2, i, 0, 0);
  6842. builder.Write("第" + dac.Days.ToString() + "天:");
  6843. builder.MoveToCell(2, i, 1, 0);
  6844. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6845. builder.MoveToCell(2, i, 2, 0);
  6846. builder.Write("费用标准:");
  6847. string curr = "";
  6848. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6849. if (currData != null)
  6850. {
  6851. curr = currData.Name;
  6852. }
  6853. builder.MoveToCell(2, i, 3, 0);
  6854. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6855. builder.MoveToCell(2, i, 4, 0);
  6856. builder.Write("费用小计:");
  6857. builder.MoveToCell(2, i, 5, 0);
  6858. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6859. }
  6860. //删除多余行
  6861. while (table3.Rows.Count > table3Row)
  6862. {
  6863. table3.Rows.RemoveAt(table3Row);
  6864. }
  6865. #endregion
  6866. }
  6867. else dic.Add("SubGZF", "0.00");
  6868. //删除多余行
  6869. while (table3.Rows.Count > table3Row)
  6870. {
  6871. table3.Rows.RemoveAt(table3Row);
  6872. }
  6873. //培训费
  6874. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6875. if (_EnterExitCosts.ChoiceSix == 1)
  6876. {
  6877. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  6878. dic.Add("SubPX", pxStr);
  6879. table4Row = dac4.Count;
  6880. #region 填充word表格内容
  6881. for (int i = 0; i < dac4.Count; i++)
  6882. {
  6883. Grp_DayAndCost dac = dac4[i];
  6884. if (dac == null) continue;
  6885. builder.MoveToCell(3, i, 0, 0);
  6886. builder.Write("第" + dac.Days.ToString() + "天:");
  6887. builder.MoveToCell(3, i, 1, 0);
  6888. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6889. builder.MoveToCell(3, i, 2, 0);
  6890. builder.Write("费用标准:");
  6891. string curr = "";
  6892. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6893. if (currData != null)
  6894. {
  6895. curr = currData.Name;
  6896. }
  6897. builder.MoveToCell(3, i, 3, 0);
  6898. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6899. builder.MoveToCell(3, i, 4, 0);
  6900. builder.Write("费用小计:");
  6901. builder.MoveToCell(3, i, 5, 0);
  6902. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6903. }
  6904. #endregion
  6905. }
  6906. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6907. //删除多余行
  6908. while (table4.Rows.Count > table4Row)
  6909. {
  6910. table4.Rows.RemoveAt(table4Row);
  6911. }
  6912. //其他费用
  6913. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6914. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6915. {
  6916. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  6917. dic.Add("titleQi", qtStr);
  6918. table5Row = dac5.Count;
  6919. #region 填充word表格内容
  6920. for (int i = 0; i < dac5.Count; i++)
  6921. {
  6922. var dac = dac5[i];
  6923. if (dac == null) continue;
  6924. builder.MoveToCell(4, i, 0, 0);
  6925. builder.Write("第" + dac.Index.ToString() + "项:");
  6926. builder.MoveToCell(4, i, 1, 0);
  6927. builder.Write(dac.itemName);
  6928. builder.MoveToCell(4, i, 2, 0);
  6929. builder.Write("费用标准:");
  6930. builder.MoveToCell(4, i, 3, 0);
  6931. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6932. builder.MoveToCell(4, i, 4, 0);
  6933. builder.Write("费用小计:");
  6934. builder.MoveToCell(4, i, 5, 0);
  6935. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6936. builder.MoveToCell(4, i, 6, 0);
  6937. builder.Write("备注:");
  6938. builder.MoveToCell(4, i, 7, 0);
  6939. builder.Write(dac.Remark);
  6940. }
  6941. #endregion
  6942. }
  6943. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6944. //删除多余行
  6945. while (table5.Rows.Count > table5Row)
  6946. {
  6947. table5.Rows.RemoveAt(table5Row);
  6948. }
  6949. //加上其他费用
  6950. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6951. decimal subJJC = 0.00M,
  6952. subGWC = 0.00M,
  6953. subTDC = 0.00M;
  6954. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6955. string totalLabel = string.Format("全部费用总计:");
  6956. //经济舱
  6957. if (_EnterExitCosts.SumJJC == 1)
  6958. {
  6959. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6960. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  6961. }
  6962. //公务舱
  6963. if (_EnterExitCosts.SumGWC == 1)
  6964. {
  6965. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6966. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  6967. }
  6968. //头等舱
  6969. if (_EnterExitCosts.SumTDC == 1)
  6970. {
  6971. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6972. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  6973. }
  6974. //TotalLabel
  6975. dic.Add("TotalLabel", totalLabel);
  6976. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6977. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6978. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6979. #region 填充word模板书签内容
  6980. foreach (var key in dic.Keys)
  6981. {
  6982. Bookmark bookmark = doc.Range.Bookmarks[key];
  6983. if (bookmark != null)
  6984. {
  6985. builder.MoveToBookmark(key);
  6986. builder.Write(dic[key]);
  6987. }
  6988. }
  6989. #endregion
  6990. #region 设置页眉
  6991. string userLabel = string.Empty;
  6992. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6993. if (currUserInfo != null)
  6994. {
  6995. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6996. if (userInfo != null)
  6997. {
  6998. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6999. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7000. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7001. }
  7002. }
  7003. //设置页脚
  7004. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7005. #endregion
  7006. //文件名
  7007. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  7008. AsposeHelper.removewatermark_v2180();
  7009. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7010. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7011. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7012. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7013. }
  7014. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7015. {
  7016. //获取模板
  7017. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7018. //载入模板
  7019. var doc = new Document(tempPath);
  7020. var builder = new DocumentBuilder(doc);
  7021. var dic = new Dictionary<string, string>();
  7022. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7023. {
  7024. var list = new List<string>();
  7025. try
  7026. {
  7027. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7028. foreach (var item in spilitArr)
  7029. {
  7030. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7031. var depCode = spDotandEmpty[2].Substring(0, 3);
  7032. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7033. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7034. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7035. list.Add(depName);
  7036. list.Add(arrName);
  7037. }
  7038. list = list.Distinct().ToList();
  7039. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7040. }
  7041. catch (Exception)
  7042. {
  7043. dic.Add("ReturnCode", "行程录入不正确!");
  7044. }
  7045. }
  7046. else
  7047. {
  7048. dic.Add("ReturnCode", "未录入行程!");
  7049. }
  7050. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7051. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7052. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7053. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7054. {
  7055. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7056. dic.Add("Day", sp.Days.ToString());
  7057. }
  7058. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7059. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7060. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7061. //dic.Add("Names", Names);
  7062. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7063. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7064. decimal dac1totalPrice = 0.00M;
  7065. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7066. foreach (var dac in dac1)
  7067. {
  7068. if (dac.SubTotal == 0.00M)
  7069. {
  7070. continue;
  7071. }
  7072. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7073. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7074. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7075. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7076. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7077. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7078. builder.Write(currency);//币种
  7079. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7080. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7081. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7082. builder.Write("");//人数
  7083. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7084. builder.Write("");//天数
  7085. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7086. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7087. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7088. decimal rate = 0.00M;
  7089. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7090. builder.Write(rate.ToString("#0.0000"));//汇率
  7091. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7092. decimal rbmPrice = dac.SubTotal;
  7093. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7094. accommodationStartIndex++;
  7095. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7096. }
  7097. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7098. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7099. {
  7100. table1.Rows.RemoveAt(i - 1);
  7101. foodandotherStartIndex--;
  7102. }
  7103. if (dac2.Count == dac3.Count)//国家 币种 金额
  7104. {
  7105. for (int i = 0; i < dac2.Count; i++)
  7106. {
  7107. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7108. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7109. }
  7110. }
  7111. decimal dac2totalPrice = 0.00M;
  7112. foreach (var dac in dac2)
  7113. {
  7114. if (dac.SubTotal == 0)
  7115. {
  7116. continue;
  7117. }
  7118. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7119. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7120. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7121. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7122. builder.Write(currency);//币种
  7123. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7124. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7125. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7126. builder.Write("");//人数
  7127. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7128. builder.Write("");//天数
  7129. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7130. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7131. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7132. decimal rate = 0.00M;
  7133. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7134. builder.Write(rate.ToString("#0.0000"));//汇率
  7135. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7136. decimal rbmPrice = dac.SubTotal;
  7137. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7138. foodandotherStartIndex++;
  7139. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7140. }
  7141. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7142. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7143. {
  7144. table1.Rows.RemoveAt(i - 1);
  7145. }
  7146. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7147. string otherFeeStr = "";
  7148. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7149. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7150. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7151. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7152. foreach (var otherInfo in dac5)
  7153. {
  7154. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7155. }
  7156. #endregion
  7157. if (otherFeeStr.Length > 0)
  7158. {
  7159. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7160. otherFeeStr = $"({otherFeeStr})";
  7161. dic.Add("OtherFeeStr", otherFeeStr);
  7162. }
  7163. //总计
  7164. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7165. //国际旅费
  7166. string outsideAir = string.Empty;
  7167. string allPriceAir = string.Empty;
  7168. if (_EnterExitCosts.SumJJC == 1)
  7169. {
  7170. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7171. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7172. }
  7173. if (_EnterExitCosts.SumGWC == 1)
  7174. {
  7175. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7176. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7177. }
  7178. if (_EnterExitCosts.SumTDC == 1)
  7179. {
  7180. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7181. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7182. }
  7183. dic.Add("InTravelPrice", $"({outsideAir})");
  7184. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7185. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7186. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7187. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7188. foreach (var key in dic.Keys)
  7189. {
  7190. builder.MoveToBookmark(key);
  7191. builder.Write(dic[key]);
  7192. }
  7193. //模板文件名
  7194. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7195. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7196. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7197. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7198. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7199. }
  7200. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7201. {
  7202. //获取模板
  7203. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7204. //载入模板
  7205. var designer = new WorkbookDesigner
  7206. {
  7207. Workbook = new Workbook(tempPath)
  7208. };
  7209. var dic = new Dictionary<string, string>();
  7210. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7211. {
  7212. var list = new List<string>();
  7213. try
  7214. {
  7215. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7216. foreach (var item in spilitArr)
  7217. {
  7218. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7219. var depCode = spDotandEmpty[2].Substring(0, 3);
  7220. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7221. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7222. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7223. list.Add(depName);
  7224. list.Add(arrName);
  7225. }
  7226. list = list.Distinct().ToList();
  7227. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7228. }
  7229. catch (Exception)
  7230. {
  7231. dic.Add("ReturnCode", "行程录入不正确!");
  7232. }
  7233. }
  7234. else
  7235. {
  7236. dic.Add("ReturnCode", "未录入行程!");
  7237. }
  7238. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7239. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7240. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7241. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7242. {
  7243. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7244. dic.Add("Day", sp.Days.ToString());
  7245. }
  7246. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7247. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7248. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7249. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7250. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7251. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7252. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7253. designer.SetDataSource("Name", Names);
  7254. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7255. designer.SetDataSource("Day", dic["Day"] + "天");
  7256. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7257. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7258. int startIndex = 10;
  7259. const int startIndexcopy = 10;
  7260. if (dac2.Count == dac3.Count)//国家 币种 金额
  7261. {
  7262. for (int i = 0; i < dac2.Count; i++)
  7263. {
  7264. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7265. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7266. }
  7267. }
  7268. var dtdac1 = new DataTable();
  7269. var place = new List<string>();
  7270. dtdac1.Columns.AddRange(new DataColumn[] {
  7271. new(){ ColumnName = "city"},
  7272. new(){ ColumnName = "curr"},
  7273. new(){ ColumnName = "criterion"},
  7274. new(){ ColumnName = "number",DataType = typeof(int)},
  7275. new(){ ColumnName = "day",DataType = typeof(int)},
  7276. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7277. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7278. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7279. });
  7280. var dtdac2 = new DataTable();
  7281. dtdac2.Columns.AddRange(new DataColumn[] {
  7282. new(){ ColumnName = "city"},
  7283. new(){ ColumnName = "curr"},
  7284. new(){ ColumnName = "criterion"},
  7285. new(){ ColumnName = "number",DataType = typeof(int)},
  7286. new(){ ColumnName = "day",DataType = typeof(int)},
  7287. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7288. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7289. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7290. });
  7291. dtdac1.TableName = "tb1";
  7292. dtdac2.TableName = "tb2";
  7293. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7294. foreach (var item in dac1)
  7295. {
  7296. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7297. if (place.Contains(item.Place))
  7298. {
  7299. continue;
  7300. }
  7301. DataRow row = dtdac1.NewRow();
  7302. row["city"] = item.Place;
  7303. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7304. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7305. row["curr"] = currency;
  7306. row["rate"] = rate.ToString("#0.0000");
  7307. row["criterion"] = item.Cost.ToString("#0.00");
  7308. row["number"] = 1;
  7309. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7310. //row["costRMB"] = rbmPrice;
  7311. dtdac1.Rows.Add(row);
  7312. place.Add(item.Place);
  7313. }
  7314. place = new List<string>();
  7315. foreach (var item in dac2)
  7316. {
  7317. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7318. if (place.Contains(item.Place))
  7319. {
  7320. continue;
  7321. }
  7322. DataRow row = dtdac2.NewRow();
  7323. row["city"] = item.Place;
  7324. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7325. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7326. row["curr"] = currency;
  7327. row["rate"] = rate.ToString("#0.0000");
  7328. row["criterion"] = item.Cost.ToString("#0.00");
  7329. row["number"] = 1;
  7330. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7331. //row["cost"] = item.SubTotal;
  7332. //row["costRMB"] = rbmPrice;
  7333. dtdac2.Rows.Add(row);
  7334. place.Add(item.Place);
  7335. //dac2totalPrice += rbmPrice;
  7336. }
  7337. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7338. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7339. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7340. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7341. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7342. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7343. string cell4Str1 = string.Empty;
  7344. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7345. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7346. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7347. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7348. string cellStr = $" 5.其他费用(";
  7349. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7350. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7351. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7352. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7353. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7354. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7355. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7356. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7357. foreach (var otherInfo in dac5)
  7358. {
  7359. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7360. }
  7361. #endregion
  7362. if (cellStr.Length > 8)
  7363. {
  7364. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7365. }
  7366. cellStr += ")";
  7367. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7368. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7369. decimal pxFee = dac4.Sum(it => it.Cost);
  7370. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7371. string celllastStr1 = "";
  7372. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7373. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7374. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7375. celllastStr1 += $",国际旅费 元";
  7376. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7377. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7378. designer.SetDataSource("cell4Str", cell4Str);
  7379. designer.SetDataSource("cellStr", cellStr);
  7380. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7381. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7382. designer.SetDataSource("celllastStr", celllastStr);
  7383. Workbook wb = designer.Workbook;
  7384. var sheet = wb.Worksheets[0];
  7385. //绑定datatable数据集
  7386. designer.SetDataSource(dtdac1);
  7387. designer.SetDataSource(dtdac2);
  7388. designer.Process();
  7389. var rowStart = dtdac1.Rows.Count;
  7390. while (rowStart > 0)
  7391. {
  7392. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7393. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7394. startIndex++;
  7395. rowStart--;
  7396. }
  7397. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7398. startIndex += 1; //总计行
  7399. rowStart = dtdac2.Rows.Count;
  7400. while (rowStart > 0)
  7401. {
  7402. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7403. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7404. startIndex++;
  7405. rowStart--;
  7406. }
  7407. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7408. wb.CalculateFormula(true);
  7409. //模板文件名
  7410. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7411. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7412. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7413. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7414. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7415. }
  7416. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7417. {
  7418. //获取模板
  7419. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7420. //载入模板
  7421. var doc = new Document(tempPath);
  7422. var builder = new DocumentBuilder(doc);
  7423. var dic = new Dictionary<string, string>
  7424. {
  7425. { "GroupName", _DelegationInfo.TeamName },
  7426. { "ClientUnit", _DelegationInfo.ClientUnit }
  7427. };
  7428. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7429. string missionLeaderJob = "";//负责人job
  7430. //int groupNumber = 0; //团人数
  7431. if (DeleClientList.Count > 0)
  7432. {
  7433. missionLeader = DeleClientList[0]?.Name ?? "";
  7434. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7435. }
  7436. dic.Add("MissionLeader", missionLeader); //团负责人
  7437. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7438. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7439. #region MyRegion
  7440. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7441. //{
  7442. // List<string> list = new List<string>();
  7443. // try
  7444. // {
  7445. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7446. // foreach (var item in spilitArr)
  7447. // {
  7448. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7449. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7450. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7451. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7452. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7453. // list.Add(depName);
  7454. // list.Add(arrName);
  7455. // }
  7456. // list = list.Distinct().ToList();
  7457. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7458. // }
  7459. // catch (Exception)
  7460. // {
  7461. // dic.Add("ReturnCode", "行程录入不正确!");
  7462. // }
  7463. //}
  7464. //else
  7465. //{
  7466. // dic.Add("ReturnCode", "未录入行程!");
  7467. //}
  7468. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7469. dic.Add("ReturnCode", string.Join("、", countrys));
  7470. #endregion
  7471. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7472. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7473. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7474. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7475. //{
  7476. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7477. // dic.Add("Day", sp.Days.ToString());
  7478. //}
  7479. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7480. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7481. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7482. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7483. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7484. //培训人员名单
  7485. int cultivateRowIndex = 7;
  7486. foreach (var item in DeleClientList)
  7487. {
  7488. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7489. builder.Write(item.Name);
  7490. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7491. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7492. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7493. string birthDay = "";
  7494. if (item.Birthday != null)
  7495. {
  7496. DateTime dt = Convert.ToDateTime(item.Birthday);
  7497. birthDay = $"{dt.Year}.{dt.Month}";
  7498. }
  7499. builder.Write(birthDay);
  7500. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7501. builder.Write(item.Company);
  7502. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7503. builder.Write(item.Job);
  7504. cultivateRowIndex++;
  7505. }
  7506. //删除多余行
  7507. //cultivateRowIndex -= 2;
  7508. int delRows = 10 + 7 - cultivateRowIndex;
  7509. if (delRows > 0)
  7510. {
  7511. for (int i = 0; i < delRows; i++)
  7512. {
  7513. table1.Rows.RemoveAt(cultivateRowIndex);
  7514. //cultivateRowIndex++;
  7515. }
  7516. }
  7517. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7518. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7519. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7520. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7521. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7522. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7523. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7524. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7525. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7526. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7527. //其他费用
  7528. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7529. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7530. //其他费用合计
  7531. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7532. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7533. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7534. //公务舱合计
  7535. //国际旅费
  7536. //string outsideJJ = "";
  7537. //string allPriceJJ = "";
  7538. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7539. {
  7540. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7541. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7542. }
  7543. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7544. {
  7545. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7546. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7547. }
  7548. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7549. {
  7550. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7551. dic.Add("AirFeeTotal", airFeeTotalStr);
  7552. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7553. dic.Add("FeeTotal", feeTotalStr);
  7554. }
  7555. foreach (var key in dic.Keys)
  7556. {
  7557. builder.MoveToBookmark(key);
  7558. builder.Write(dic[key]);
  7559. }
  7560. //模板文件名
  7561. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7562. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7563. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7564. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7565. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7566. }
  7567. }
  7568. else if (dto.ExportType == 2) //表格
  7569. {
  7570. //利用键值对存放数据
  7571. Dictionary<string, string> dic = new Dictionary<string, string>();
  7572. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7573. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7574. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7575. dic.Add("Day", sp.Days.ToString());
  7576. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7577. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7578. {
  7579. //获取模板
  7580. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7581. //载入模板
  7582. var doc = new Document(tempPath);
  7583. var builder = new DocumentBuilder(doc);
  7584. dic.Add("TeamName", _DelegationInfo.TeamName);
  7585. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7586. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7587. string missionLeaderName = "",
  7588. missionLeaderJob = "";
  7589. if (DeleClientList.Count > 0)
  7590. {
  7591. missionLeaderName = DeleClientList[0].Name;
  7592. missionLeaderJob = DeleClientList[0].Job;
  7593. }
  7594. dic.Add("MissionLeaderName", missionLeaderName);
  7595. dic.Add("MissionLeaderJob", missionLeaderJob);
  7596. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7597. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7598. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7599. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7600. int rowCount = 10;//总人数行
  7601. int startRowIndex = 7; //起始行
  7602. for (int i = 0; i < DeleClientList.Count; i++)
  7603. {
  7604. builder.MoveToCell(0, startRowIndex, 0, 0);
  7605. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7606. builder.MoveToCell(0, startRowIndex, 1, 0);
  7607. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7608. builder.Write(sex);//性别
  7609. builder.MoveToCell(0, startRowIndex, 2, 0);
  7610. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7611. builder.MoveToCell(0, startRowIndex, 3, 0);
  7612. builder.Write(DeleClientList[i].Company);//工作单位
  7613. builder.MoveToCell(0, startRowIndex, 4, 0);
  7614. builder.Write(DeleClientList[i].Job);//职务及级别
  7615. builder.MoveToCell(0, startRowIndex, 5, 0);
  7616. builder.Write("");//人员属性
  7617. builder.MoveToCell(0, startRowIndex, 6, 0);
  7618. builder.Write("");//上次出国时间
  7619. startRowIndex++;
  7620. }
  7621. int nullRow = rowCount - DeleClientList.Count;//空行
  7622. for (int i = 0; i < nullRow; i++)
  7623. {
  7624. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7625. }
  7626. foreach (var key in dic.Keys)
  7627. {
  7628. builder.MoveToBookmark(key);
  7629. builder.Write(dic[key]);
  7630. }
  7631. //模板文件名
  7632. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7633. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7634. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7635. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7636. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7637. }
  7638. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7639. {
  7640. //获取模板
  7641. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7642. //载入模板
  7643. var doc = new Document(tempPath);
  7644. var builder = new DocumentBuilder(doc);
  7645. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7646. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7647. dic.Add("Names", Names);
  7648. int accommodationRows = 12;
  7649. //int foodandotherRows = 12;
  7650. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7651. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7652. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7653. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7654. int accommodationStartIndex = 6;
  7655. decimal dac1totalPrice = 0.00M;
  7656. foreach (var dac in dac1)
  7657. {
  7658. if (dac.SubTotal == 0)
  7659. {
  7660. continue;
  7661. }
  7662. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7663. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7664. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7665. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7666. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7667. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7668. builder.Write(currency);//币种
  7669. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7670. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7671. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7672. builder.Write("");//人数
  7673. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7674. builder.Write("");//天数
  7675. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7676. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7677. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7678. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7679. builder.Write(rate.ToString("#0.0000"));//汇率
  7680. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7681. decimal rbmPrice = rate * dac.SubTotal;
  7682. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7683. accommodationStartIndex++;
  7684. dac1totalPrice += rbmPrice;
  7685. }
  7686. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7687. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7688. builder.Write("小计");
  7689. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7690. builder.Write(dac1totalPrice.ToString("#0.00"));
  7691. accommodationStartIndex++;
  7692. int nullRow = accommodationRows - dac1.Count;
  7693. //删除空行
  7694. //if (nullRow > 0)
  7695. //{
  7696. // int rowIndex = accommodationStartIndex;
  7697. // for (int i = 0; i < nullRow; i++)
  7698. // {
  7699. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7700. // row.Remove();
  7701. // rowIndex++;
  7702. // }
  7703. //}
  7704. if (dac2.Count == dac3.Count)//国家 币种 金额
  7705. {
  7706. for (int i = 0; i < dac2.Count; i++)
  7707. {
  7708. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7709. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7710. }
  7711. }
  7712. int foodandotherStartIndex = 19;//
  7713. decimal dac2totalPrice = 0.00M;
  7714. foreach (var dac in dac2)
  7715. {
  7716. if (dac.SubTotal == 0)
  7717. {
  7718. continue;
  7719. }
  7720. //foodandotherStartIndex = 12;
  7721. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7722. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7723. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7724. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7725. builder.Write(currency);//币种
  7726. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7727. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7728. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7729. builder.Write("");//人数
  7730. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7731. builder.Write("");//天数
  7732. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7733. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7734. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7735. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7736. builder.Write(rate.ToString("#0.0000"));//汇率
  7737. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7738. decimal rbmPrice = rate * dac.SubTotal;
  7739. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7740. foodandotherStartIndex++;
  7741. dac2totalPrice += rbmPrice;
  7742. }
  7743. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7744. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7745. //删除空行
  7746. //if (dac2.Count < foodandotherRows)
  7747. //{
  7748. // while (table2.Rows.Count > dac2.Count)
  7749. // {
  7750. // table2.Rows.RemoveAt(dac2.Count);
  7751. // }
  7752. //}
  7753. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7754. string otherFeeStr = "";
  7755. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7756. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7757. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7758. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7759. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7760. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7761. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7762. foreach (var otherInfo in dac5)
  7763. {
  7764. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7765. }
  7766. #endregion
  7767. if (otherFeeStr.Length > 0)
  7768. {
  7769. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7770. otherFeeStr = $"({otherFeeStr})";
  7771. dic.Add("OtherFeeStr", otherFeeStr);
  7772. }
  7773. foreach (var key in dic.Keys)
  7774. {
  7775. builder.MoveToBookmark(key);
  7776. builder.Write(dic[key]);
  7777. }
  7778. //模板文件名
  7779. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7780. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7781. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7782. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7783. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7784. }
  7785. }
  7786. else if (dto.ExportType == 3)
  7787. {
  7788. if (dto.SubTypeId == 1) //团组成员名单
  7789. {
  7790. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7791. //获取模板
  7792. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7793. //载入模板
  7794. var doc = new Document(tempPath);
  7795. var builder = new DocumentBuilder(doc);
  7796. //获取word里所有表格
  7797. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7798. //获取所填表格的序数
  7799. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7800. var rowStart = tableOne.Rows[0]; //获取第1行
  7801. //循环赋值
  7802. for (int i = 0; i < DeleClientList.Count; i++)
  7803. {
  7804. builder.MoveToCell(0, i + 1, 0, 0);
  7805. builder.Write(DeleClientList[i].Name);
  7806. builder.MoveToCell(0, i + 1, 1, 0);
  7807. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7808. builder.Write(sex);
  7809. builder.MoveToCell(0, i + 1, 2, 0);
  7810. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7811. builder.MoveToCell(0, i + 1, 3, 0);
  7812. builder.Write(DeleClientList[i].Company);
  7813. builder.MoveToCell(0, i + 1, 4, 0);
  7814. builder.Write(DeleClientList[i].Job);
  7815. }
  7816. //删除多余行
  7817. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7818. {
  7819. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7820. }
  7821. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7822. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7823. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7824. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7825. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7826. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7827. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7828. }
  7829. }
  7830. return Ok(JsonView(400, "操作失败!", ""));
  7831. }
  7832. catch (Exception ex)
  7833. {
  7834. return Ok(JsonView(400, ex.Message, ""));
  7835. }
  7836. }
  7837. /// <summary>
  7838. /// 获取三公费用标准city
  7839. /// </summary>
  7840. /// <param name="placeData"></param>
  7841. /// <param name="nationalTravelFeeId"></param>
  7842. /// <returns></returns>
  7843. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7844. {
  7845. string _city = string.Empty;
  7846. if (placeData.Count < 1) return _city;
  7847. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7848. if (data == null) return _city;
  7849. string country = data.Country;
  7850. string city = data.City;
  7851. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7852. else _city = city;
  7853. return _city;
  7854. }
  7855. ///// <summary>
  7856. ///// 团组模块 - 出入境费用 - 明细表导出
  7857. ///// </summary>
  7858. ///// <returns></returns>
  7859. //[HttpPost]
  7860. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7861. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7862. //{
  7863. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7864. // if (data.Code != 0)
  7865. // {
  7866. // return Ok(JsonView(false, data.Msg));
  7867. // }
  7868. // return Ok(JsonView(true, data.Msg, data.Data));
  7869. //}
  7870. /// <summary>
  7871. /// 团组模块 - 出入境费用 - 一键清空
  7872. /// </summary>
  7873. /// <returns></returns>
  7874. [HttpPost]
  7875. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7877. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7878. {
  7879. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7880. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7881. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7882. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7883. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7884. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7885. .SetColumns(x => new Grp_DayOtherPrice
  7886. {
  7887. IsDel = 1,
  7888. DeleteUserId = dto.UserId,
  7889. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7890. })
  7891. .ExecuteCommandAsync();
  7892. if (_view.Code == 0)
  7893. {
  7894. return Ok(JsonView(true, "操作成功"));
  7895. }
  7896. return Ok(JsonView(false, "操作失败"));
  7897. }
  7898. /// <summary>
  7899. /// 团组模块 - 出入境费用 - 子项删除
  7900. /// </summary>
  7901. /// <returns></returns>
  7902. [HttpPost]
  7903. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7905. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7906. {
  7907. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7908. if (data.Code != 0)
  7909. {
  7910. return Ok(JsonView(false, data.Msg));
  7911. }
  7912. return Ok(JsonView(true, "操作成功!", data.Data));
  7913. }
  7914. /// <summary>
  7915. /// 删除三公其他费用
  7916. /// </summary>
  7917. /// <param name="dto"></param>
  7918. /// <returns></returns>
  7919. [HttpPost]
  7920. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7921. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7922. {
  7923. var jw = JsonView(false, "删除失败!");
  7924. var data = new Grp_DayOtherPrice()
  7925. {
  7926. Id = dto.Id,
  7927. IsDel = 1,
  7928. DeleteUserId = dto.DeleteUserId,
  7929. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7930. };
  7931. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7932. if (del > 0)
  7933. {
  7934. jw.Code = 200;
  7935. jw.Msg = "删除成功!";
  7936. }
  7937. return Ok(jw);
  7938. }
  7939. /// <summary>
  7940. /// 团组模块 - 出入境国家费用标准 List
  7941. /// </summary>
  7942. /// <returns></returns>
  7943. [HttpPost]
  7944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7945. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7946. {
  7947. int provinceId = dto.ProvinceId;
  7948. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7949. var nftData = await _sqlSugar
  7950. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7951. JoinType.Left, ntf.Currency == sd1.Id,
  7952. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7953. JoinType.Left, ntf.ProvinceId == c.Id
  7954. ))
  7955. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7956. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7957. {
  7958. Id = ntf.Id,
  7959. ProvinceId = ntf.ProvinceId,
  7960. ProvinceName = c.Name_CN,
  7961. Continent = ntf.Continent,
  7962. Country = ntf.Country,
  7963. City = ntf.City,
  7964. Currency = ntf.Currency,
  7965. CurrencyCode = sd1.Name,
  7966. CurrencyName = sd1.Remark,
  7967. RoomCost = ntf.RoomCost,
  7968. FoodCost = ntf.FoodCost,
  7969. PublicCost = ntf.PublicCost,
  7970. LastUpdateUserId = ntf.LastUpdateUserId,
  7971. LastUpdateUserName = u.CnName,
  7972. LastUpdateTime = ntf.LastUpdateTime
  7973. })
  7974. .ToListAsync();
  7975. return Ok(JsonView(true, "查询成功!", nftData));
  7976. }
  7977. /// <summary>
  7978. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7979. /// </summary>
  7980. /// <returns></returns>
  7981. [HttpPost]
  7982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7983. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7984. {
  7985. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7986. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7987. List<string> countryData = new List<string>();
  7988. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7989. countryData = countryData.Distinct().ToList();
  7990. List<dynamic> dataSource = new List<dynamic>();
  7991. foreach (var item in countryData)
  7992. {
  7993. var cityData1 = new List<string>();
  7994. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7995. var countryData2 = new
  7996. {
  7997. CountryName = item,
  7998. CityData = cityData1
  7999. };
  8000. if (!dataSource.Contains(countryData2))
  8001. {
  8002. dataSource.Add(countryData2);
  8003. }
  8004. }
  8005. return Ok(JsonView(true, "查询成功!", dataSource));
  8006. }
  8007. /// <summary>
  8008. /// 团组模块 - 出入境国家费用标准 Page List
  8009. /// </summary>
  8010. /// <returns></returns>
  8011. [HttpPost]
  8012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8013. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8014. {
  8015. int portId = dto.PortType,
  8016. pageIndex = dto.PageIndex,
  8017. pageSize = dto.PageSize;
  8018. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8019. if (pageIndex == 0) pageIndex = 1;
  8020. if (pageSize == 0) pageSize = 10;
  8021. RefAsync<int> total = 0;
  8022. var nationalTravelFeeData = await _sqlSugar
  8023. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8024. JoinType.Left, ntf.Currency == sd1.Id,
  8025. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8026. JoinType.Left, ntf.ProvinceId == sd2.Id
  8027. ))
  8028. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8029. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8030. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8031. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8032. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8033. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8034. {
  8035. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8036. Id = ntf.Id,
  8037. ProvinceId = ntf.ProvinceId,
  8038. ProvinceName = sd2.Name_CN,
  8039. Continent = ntf.Continent,
  8040. Country = ntf.Country,
  8041. City = ntf.City,
  8042. Currency = ntf.Currency,
  8043. CurrencyCode = sd1.Name,
  8044. CurrencyName = sd1.Remark,
  8045. RoomCost = ntf.RoomCost,
  8046. FoodCost = ntf.FoodCost,
  8047. PublicCost = ntf.PublicCost,
  8048. LastUpdateUserId = ntf.LastUpdateUserId,
  8049. LastUpdateUserName = u.CnName,
  8050. LastUpdateTime = ntf.LastUpdateTime,
  8051. Remark = ntf.Remark
  8052. })
  8053. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8054. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8055. }
  8056. /// <summary>
  8057. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8058. /// </summary>
  8059. /// <returns></returns>
  8060. [HttpPost]
  8061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8062. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8063. {
  8064. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8065. int portId = dto.PortType;
  8066. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8067. string whereSql = string.Empty;
  8068. if (!string.IsNullOrEmpty(dto.Country))
  8069. {
  8070. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8071. }
  8072. if (!string.IsNullOrEmpty(dto.City))
  8073. {
  8074. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8075. }
  8076. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8077. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8078. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8079. From Grp_NationalTravelFee gntf
  8080. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8081. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8082. Where gntf.Isdel = 0 {0} ", whereSql);
  8083. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8084. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8085. }
  8086. /// <summary>
  8087. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8088. /// </summary>
  8089. /// <returns></returns>
  8090. [HttpPost]
  8091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8092. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8093. {
  8094. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8095. }
  8096. /// <summary>
  8097. /// 团组模块 - 出入境国家费用标准 - Del
  8098. /// </summary>
  8099. /// <returns></returns>
  8100. [HttpPost]
  8101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8102. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8103. {
  8104. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8105. {
  8106. Id = dto.Id,
  8107. DeleteUserId = dto.DeleteUserId,
  8108. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8109. IsDel = 1
  8110. };
  8111. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8112. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8113. .WhereColumns(it => new { it.Id })
  8114. .ExecuteCommandAsync();
  8115. if (delStatus <= 0)
  8116. {
  8117. return Ok(JsonView(false, "删除失败!"));
  8118. }
  8119. return Ok(JsonView(true, "操作成功!"));
  8120. }
  8121. /// <summary>
  8122. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8123. /// 注:Get 请求Headers 加 Token
  8124. /// </summary>
  8125. /// <param name="groupId"></param>
  8126. /// <returns></returns>
  8127. [HttpGet("{groupId}")]
  8128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8129. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8130. {
  8131. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8132. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8133. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8134. data.ForEach(x =>
  8135. {
  8136. x.CreateUserId = _currUserInfo.UserId;
  8137. });
  8138. if (data.Any())
  8139. {
  8140. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8141. if (add > 0)
  8142. {
  8143. return Ok(JsonView(true, "操作成功!"));
  8144. }
  8145. }
  8146. return Ok(JsonView(false, "未操作!"));
  8147. }
  8148. #endregion
  8149. #region 团组经理模块 出入境费用-草稿
  8150. /// <summary>
  8151. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8152. /// </summary>
  8153. /// <returns></returns>
  8154. [HttpGet]
  8155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8156. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8157. {
  8158. var provData = await _groupRepository.ProvinceBasicSource();
  8159. return Ok(JsonView(true, "查询成功!", provData));
  8160. }
  8161. /// <summary>
  8162. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8163. /// </summary>
  8164. /// <returns></returns>
  8165. [HttpGet("{provinceId}")]
  8166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8167. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8168. {
  8169. //验证城市归属并给默认值
  8170. if (provinceId < 1) provinceId = 122;
  8171. /*
  8172. * 122 四川
  8173. * 108 贵州
  8174. * 103 重庆
  8175. * 132 云南
  8176. */
  8177. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8178. return Ok(JsonView(true, "查询成功!", new
  8179. {
  8180. WordTypeData = wordTypeData,
  8181. ExcelTypeData = excelTypeData,
  8182. }));
  8183. }
  8184. /// <summary>
  8185. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8186. /// </summary>
  8187. /// <returns></returns>
  8188. [HttpPost]
  8189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8190. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8191. {
  8192. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8193. .Where(x => x.IsDel == 0)
  8194. .OrderByDescending(x => x.CreateTime)
  8195. .Select(x => new { x.Id, x.DraftName })
  8196. .ToListAsync();
  8197. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8198. //SetDataInfoView
  8199. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8200. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8201. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8202. int provinceId = dto.ProvinceId;
  8203. if (provinceId < 1) provinceId = 122;
  8204. /*
  8205. * 122 四川
  8206. * 108 贵州
  8207. * 103 重庆
  8208. * 132 云南
  8209. */
  8210. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8211. //默认币种显示
  8212. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8213. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8214. return Ok(JsonView(true, "查询成功!", new
  8215. {
  8216. DraftNameDatas = draftNameDatas,
  8217. CurrencyData = _CurrencyData,
  8218. WordTypeData = wordTypeData,
  8219. ExcelTypeData = excelTypeData,
  8220. CurrencyInit = _currencyInfos,
  8221. ViewPermissionData = viewPermissionData
  8222. }));
  8223. }
  8224. /// <summary>
  8225. /// 团组模块 - 出入境费用-草稿
  8226. /// 实时汇率 tips
  8227. /// 机票费用 tips
  8228. /// </summary>
  8229. /// <returns></returns>
  8230. [HttpPost]
  8231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8232. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8233. {
  8234. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8235. return Ok(JsonView(true, "查询成功!", new
  8236. {
  8237. //GroupNameData = groupNameData.Data,
  8238. //visaData = visaData.Data,
  8239. //airData = airData.Data,
  8240. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8241. }));
  8242. }
  8243. /// <summary>
  8244. /// 团组模块 - 出入境费用-草稿
  8245. /// 签证费用 tips
  8246. /// </summary>
  8247. /// <returns></returns>
  8248. [HttpPost]
  8249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8250. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8251. {
  8252. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8253. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8254. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8255. .Select(x => x.NationalTravelFeeId)
  8256. .Distinct()
  8257. .ToListAsync();
  8258. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8259. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8260. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8261. .Select(x => x.Country)
  8262. .Distinct()
  8263. .ToArrayAsync();
  8264. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8265. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8266. return Ok(JsonView(true, "查询成功!", new
  8267. {
  8268. totalAmt,
  8269. remark
  8270. }));
  8271. }
  8272. /// <summary>
  8273. /// 团组模块 - 出入境费用-草稿 - Info
  8274. /// </summary>
  8275. /// <returns></returns>
  8276. [HttpPost]
  8277. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8279. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8280. {
  8281. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8282. }
  8283. /// <summary>
  8284. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8285. /// </summary>
  8286. /// <returns></returns>
  8287. [HttpPost]
  8288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8289. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8290. {
  8291. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8292. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8293. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8294. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8295. foreach (var userId in dto.UserIds)
  8296. {
  8297. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8298. }
  8299. if (permissions.Any())
  8300. {
  8301. _sqlSugar.BeginTran();
  8302. try
  8303. {
  8304. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8305. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8306. if (result < 1)
  8307. {
  8308. _sqlSugar.RollbackTran();
  8309. return Ok(JsonView(false));
  8310. }
  8311. }
  8312. catch (Exception ex)
  8313. {
  8314. _sqlSugar.RollbackTran();
  8315. return Ok(JsonView(false, ex.Message));
  8316. }
  8317. _sqlSugar.CommitTran();
  8318. return Ok(JsonView(true));
  8319. }
  8320. return Ok(JsonView(false));
  8321. }
  8322. /// <summary>
  8323. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8324. /// </summary>
  8325. /// <returns></returns>
  8326. [HttpPost]
  8327. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8329. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8330. {
  8331. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8332. if (data.Code != 0)
  8333. {
  8334. return Ok(JsonView(false, data.Msg));
  8335. }
  8336. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8337. //汇率信息记录
  8338. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8339. return Ok(JsonView(true, data.Msg, data.Data));
  8340. }
  8341. /// <summary>
  8342. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8343. /// </summary>
  8344. /// <param name="dto"></param>
  8345. /// <returns></returns>
  8346. [HttpPost]
  8347. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8349. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8350. {
  8351. try
  8352. {
  8353. var id = dto.Id;
  8354. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8355. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8356. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8357. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8358. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8359. 3 团组成员名单 1 团组成员名单", ""));
  8360. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8361. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8362. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8363. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8364. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8365. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8366. //数据源
  8367. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8368. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8369. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8370. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8371. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8372. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8373. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8374. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8375. .Select((x, a, b) => new
  8376. {
  8377. x.Index,
  8378. itemName = a.Name,
  8379. CurrencyStr = b.Name,
  8380. x.Cost,
  8381. x.SubTotal,
  8382. x.Remark
  8383. })
  8384. .OrderBy((x) => x.Index)
  8385. .ToList(); //其他款项费用
  8386. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8387. var peiceItemCurrencys = new List<string>();
  8388. if (_DayAndCosts.Any())
  8389. {
  8390. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8391. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8392. }
  8393. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8394. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8395. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8396. {
  8397. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8398. }
  8399. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8400. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8401. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8402. if (dto.ExportType == 1) //明细表
  8403. {
  8404. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8405. {
  8406. //获取模板
  8407. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8408. //载入模板
  8409. Document doc = new Document(tempPath);
  8410. DocumentBuilder builder = new DocumentBuilder(doc);
  8411. //利用键值对存放数据
  8412. Dictionary<string, string> dic = new Dictionary<string, string>();
  8413. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8414. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8415. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8416. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8417. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8418. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8419. //境内费用(其他费用)
  8420. if (_EnterExitCosts.ChoiceOne == 1)
  8421. {
  8422. string row1_1 = "";
  8423. if (_EnterExitCosts.Visa > 0)
  8424. {
  8425. //insidePayTotal += _EnterExitCosts.Visa;
  8426. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8427. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8428. //{
  8429. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8430. //}
  8431. }
  8432. string row1_2 = "";
  8433. if (_EnterExitCosts.YiMiao > 0)
  8434. {
  8435. //insidePayTotal += _EnterExitCosts.YiMiao;
  8436. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8437. }
  8438. if (_EnterExitCosts.HeSuan > 0)
  8439. {
  8440. //insidePayTotal += _EnterExitCosts.HeSuan;
  8441. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8442. }
  8443. if (_EnterExitCosts.Service > 0)
  8444. {
  8445. //insidePayTotal += _EnterExitCosts.Service;
  8446. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8447. }
  8448. string row1_3 = "";
  8449. if (_EnterExitCosts.Safe > 0)
  8450. {
  8451. //insidePayTotal += _EnterExitCosts.Safe;
  8452. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8453. }
  8454. if (_EnterExitCosts.Ticket > 0)
  8455. {
  8456. //insidePayTotal += _EnterExitCosts.Ticket;
  8457. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8458. }
  8459. string row1 = "";
  8460. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8461. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8462. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8463. row1 += $"备注:{_EnterExitCosts.Remark}";
  8464. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8465. dic.Add("Row1Str", row1);
  8466. }
  8467. string airTotalStr = string.Empty,
  8468. airPriceStr = string.Empty;
  8469. //经济舱
  8470. if (_EnterExitCosts.SumJJC == 1)
  8471. {
  8472. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8473. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8474. }
  8475. //公务舱
  8476. if (_EnterExitCosts.SumGWC == 1)
  8477. {
  8478. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8479. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8480. }
  8481. //头等舱
  8482. if (_EnterExitCosts.SumTDC == 1)
  8483. {
  8484. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8485. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8486. }
  8487. //汇率描述
  8488. string rateStr = "";
  8489. if (peiceItemCurrencyInfos.Any())
  8490. {
  8491. rateStr = "\r\n汇率描述:";
  8492. foreach (var item in peiceItemCurrencyInfos)
  8493. {
  8494. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8495. }
  8496. }
  8497. string twoItemRemark = "备注:";
  8498. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8499. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8500. dic.Add("AirTotalStr", airTotalStr);
  8501. dic.Add("AirPriceStr", airPriceStr);
  8502. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8503. dic.Add("TwoItemRemark", twoItemRemark);
  8504. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8505. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8506. int table1Row = 0,
  8507. table2Row = 0,
  8508. table3Row = 0,
  8509. table4Row = 0,
  8510. table5Row = 0;
  8511. //住宿费
  8512. if (_EnterExitCosts.ChoiceThree == 1)
  8513. {
  8514. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8515. table1Row = dac1.Count;
  8516. #region 填充word表格内容
  8517. for (int i = 0; i < dac1.Count; i++)
  8518. {
  8519. var dac = dac1[i];
  8520. if (dac == null) continue;
  8521. builder.MoveToCell(0, i, 0, 0);
  8522. builder.Write("第" + dac.Days.ToString() + "晚:");
  8523. builder.MoveToCell(0, i, 1, 0);
  8524. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8525. //builder.Write(dac.Place == null ? "" : dac.Place);
  8526. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8527. builder.MoveToCell(0, i, 2, 0);
  8528. builder.Write("费用标准:");
  8529. string curr = "";
  8530. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8531. if (currData != null)
  8532. {
  8533. curr = currData.Name;
  8534. }
  8535. builder.MoveToCell(0, i, 3, 0);
  8536. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8537. builder.MoveToCell(0, i, 4, 0);
  8538. builder.Write("费用小计:");
  8539. builder.MoveToCell(0, i, 5, 0);
  8540. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8541. }
  8542. #endregion
  8543. }
  8544. else dic.Add("SubZS", "0.00");
  8545. //删除多余行
  8546. while (table1.Rows.Count > table1Row)
  8547. {
  8548. table1.Rows.RemoveAt(table1Row);
  8549. }
  8550. //伙食费
  8551. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8552. if (_EnterExitCosts.ChoiceFour == 1)
  8553. {
  8554. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8555. table2Row = dac2.Count;
  8556. #region 填充word表格内容
  8557. for (int i = 0; i < dac2.Count; i++)
  8558. {
  8559. var dac = dac2[i];
  8560. if (dac == null) continue;
  8561. builder.MoveToCell(1, i, 0, 0);
  8562. builder.Write("第" + dac.Days.ToString() + "天:");
  8563. builder.MoveToCell(1, i, 1, 0);
  8564. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8565. builder.MoveToCell(1, i, 2, 0);
  8566. builder.Write("费用标准:");
  8567. string curr = "";
  8568. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8569. if (currData != null)
  8570. {
  8571. curr = currData.Name;
  8572. }
  8573. builder.MoveToCell(1, i, 3, 0);
  8574. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8575. builder.MoveToCell(1, i, 4, 0);
  8576. builder.Write("费用小计:");
  8577. builder.MoveToCell(1, i, 5, 0);
  8578. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8579. }
  8580. #endregion
  8581. }
  8582. else dic.Add("SubHS", "0.00");
  8583. //删除多余行
  8584. while (table2.Rows.Count > table2Row)
  8585. {
  8586. table2.Rows.RemoveAt(table2Row);
  8587. }
  8588. //公杂费
  8589. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8590. if (_EnterExitCosts.ChoiceFive == 1)
  8591. {
  8592. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8593. table3Row = dac3.Count;
  8594. #region 填充word表格内容
  8595. for (int i = 0; i < dac3.Count; i++)
  8596. {
  8597. var dac = dac3[i];
  8598. if (dac == null) continue;
  8599. builder.MoveToCell(2, i, 0, 0);
  8600. builder.Write("第" + dac.Days.ToString() + "天:");
  8601. builder.MoveToCell(2, i, 1, 0);
  8602. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8603. builder.MoveToCell(2, i, 2, 0);
  8604. builder.Write("费用标准:");
  8605. string curr = "";
  8606. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8607. if (currData != null)
  8608. {
  8609. curr = currData.Name;
  8610. }
  8611. builder.MoveToCell(2, i, 3, 0);
  8612. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8613. builder.MoveToCell(2, i, 4, 0);
  8614. builder.Write("费用小计:");
  8615. builder.MoveToCell(2, i, 5, 0);
  8616. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8617. }
  8618. //删除多余行
  8619. while (table3.Rows.Count > table3Row)
  8620. {
  8621. table3.Rows.RemoveAt(table3Row);
  8622. }
  8623. #endregion
  8624. }
  8625. else dic.Add("SubGZF", "0.00");
  8626. //删除多余行
  8627. while (table3.Rows.Count > table3Row)
  8628. {
  8629. table3.Rows.RemoveAt(table3Row);
  8630. }
  8631. //培训费
  8632. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8633. if (_EnterExitCosts.ChoiceSix == 1)
  8634. {
  8635. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8636. dic.Add("SubPX", pxStr);
  8637. table4Row = dac4.Count;
  8638. #region 填充word表格内容
  8639. for (int i = 0; i < dac4.Count; i++)
  8640. {
  8641. var dac = dac4[i];
  8642. if (dac == null) continue;
  8643. builder.MoveToCell(3, i, 0, 0);
  8644. builder.Write("第" + dac.Days.ToString() + "天:");
  8645. builder.MoveToCell(3, i, 1, 0);
  8646. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8647. builder.MoveToCell(3, i, 2, 0);
  8648. builder.Write("费用标准:");
  8649. string curr = "";
  8650. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8651. if (currData != null)
  8652. {
  8653. curr = currData.Name;
  8654. }
  8655. builder.MoveToCell(3, i, 3, 0);
  8656. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8657. builder.MoveToCell(3, i, 4, 0);
  8658. builder.Write("费用小计:");
  8659. builder.MoveToCell(3, i, 5, 0);
  8660. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8661. }
  8662. #endregion
  8663. }
  8664. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8665. //删除多余行
  8666. while (table4.Rows.Count > table4Row)
  8667. {
  8668. table4.Rows.RemoveAt(table4Row);
  8669. }
  8670. //其他费用
  8671. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8672. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8673. {
  8674. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8675. dic.Add("titleQi", qtStr);
  8676. table5Row = dac5.Count;
  8677. #region 填充word表格内容
  8678. for (int i = 0; i < dac5.Count; i++)
  8679. {
  8680. var dac = dac5[i];
  8681. if (dac == null) continue;
  8682. builder.MoveToCell(4, i, 0, 0);
  8683. builder.Write("第" + dac.Index.ToString() + "项:");
  8684. builder.MoveToCell(4, i, 1, 0);
  8685. builder.Write(dac.itemName);
  8686. builder.MoveToCell(4, i, 2, 0);
  8687. builder.Write("费用标准:");
  8688. builder.MoveToCell(4, i, 3, 0);
  8689. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8690. builder.MoveToCell(4, i, 4, 0);
  8691. builder.Write("费用小计:");
  8692. builder.MoveToCell(4, i, 5, 0);
  8693. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8694. builder.MoveToCell(4, i, 6, 0);
  8695. builder.Write("备注:");
  8696. builder.MoveToCell(4, i, 7, 0);
  8697. builder.Write(dac.Remark);
  8698. }
  8699. #endregion
  8700. }
  8701. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8702. //删除多余行
  8703. while (table5.Rows.Count > table5Row)
  8704. {
  8705. table5.Rows.RemoveAt(table5Row);
  8706. }
  8707. //加上其他费用
  8708. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8709. decimal subJJC = 0.00M,
  8710. subGWC = 0.00M,
  8711. subTDC = 0.00M;
  8712. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8713. string totalLabel = string.Format("全部费用总计:");
  8714. //经济舱
  8715. if (_EnterExitCosts.SumJJC == 1)
  8716. {
  8717. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8718. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8719. }
  8720. //公务舱
  8721. if (_EnterExitCosts.SumGWC == 1)
  8722. {
  8723. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8724. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8725. }
  8726. //头等舱
  8727. if (_EnterExitCosts.SumTDC == 1)
  8728. {
  8729. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8730. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8731. }
  8732. //TotalLabel
  8733. dic.Add("TotalLabel", totalLabel);
  8734. #region 填充word模板书签内容
  8735. foreach (var key in dic.Keys)
  8736. {
  8737. Bookmark bookmark = doc.Range.Bookmarks[key];
  8738. if (bookmark != null)
  8739. {
  8740. builder.MoveToBookmark(key);
  8741. builder.Write(dic[key]);
  8742. }
  8743. }
  8744. #endregion
  8745. //文件名
  8746. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8747. strFileName = CommonFun.ValidFileName(strFileName);
  8748. AsposeHelper.removewatermark_v2180();
  8749. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8750. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8751. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8752. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8753. }
  8754. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8755. {
  8756. //获取模板
  8757. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8758. //载入模板
  8759. Document doc = new Document(tempPath);
  8760. DocumentBuilder builder = new DocumentBuilder(doc);
  8761. Dictionary<string, string> dic = new Dictionary<string, string>();
  8762. string returnCodeLabel = string.Empty;
  8763. if (nationalTravelFeeData.Any())
  8764. {
  8765. List<string> list = new List<string>();
  8766. foreach (var item in nationalTravelFeeData)
  8767. {
  8768. list.Add($"{item.Country}({item.City})");
  8769. }
  8770. list = list.Distinct().ToList();
  8771. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8772. }
  8773. var countryLabel = string.Empty;
  8774. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8775. if (countryData.Any())
  8776. {
  8777. countryLabel = string.Join("、", countryData);
  8778. }
  8779. dic.Add("ReturnCodeAir", returnCodeLabel);
  8780. dic.Add("VisitStartDate", "-");
  8781. dic.Add("VisitEndDate", "-");
  8782. dic.Add("Day", "-");
  8783. dic.Add("VisitCountry", countryLabel);
  8784. dic.Add("ClientUnit", "-");
  8785. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8786. //dic.Add("Names", Names);
  8787. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8788. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8789. decimal dac1totalPrice = 0.00M;
  8790. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8791. foreach (var dac in dac1)
  8792. {
  8793. if (dac.SubTotal == 0.00M)
  8794. {
  8795. continue;
  8796. }
  8797. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8798. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8799. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8800. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8801. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8802. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8803. builder.Write(currency);//币种
  8804. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8805. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8806. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8807. builder.Write("");//人数
  8808. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8809. builder.Write("");//天数
  8810. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8811. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8812. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8813. decimal rate = 0.00M;
  8814. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8815. builder.Write(rate.ToString("#0.0000"));//汇率
  8816. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8817. decimal rbmPrice = dac.SubTotal;
  8818. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8819. accommodationStartIndex++;
  8820. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8821. }
  8822. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8823. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8824. {
  8825. table1.Rows.RemoveAt(i - 1);
  8826. foodandotherStartIndex--;
  8827. }
  8828. if (dac2.Count == dac3.Count)//国家 币种 金额
  8829. {
  8830. for (int i = 0; i < dac2.Count; i++)
  8831. {
  8832. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8833. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8834. }
  8835. }
  8836. decimal dac2totalPrice = 0.00M;
  8837. foreach (var dac in dac2)
  8838. {
  8839. if (dac.SubTotal == 0)
  8840. {
  8841. continue;
  8842. }
  8843. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8844. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8845. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8846. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8847. builder.Write(currency);//币种
  8848. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8849. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8850. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8851. builder.Write("");//人数
  8852. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8853. builder.Write("");//天数
  8854. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8855. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8856. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8857. decimal rate = 0.00M;
  8858. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8859. builder.Write(rate.ToString("#0.0000"));//汇率
  8860. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8861. decimal rbmPrice = dac.SubTotal;
  8862. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8863. foodandotherStartIndex++;
  8864. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8865. }
  8866. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8867. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8868. {
  8869. table1.Rows.RemoveAt(i - 1);
  8870. }
  8871. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8872. string otherFeeStr = "";
  8873. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8874. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8875. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8876. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8877. foreach (var otherInfo in dac5)
  8878. {
  8879. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8880. }
  8881. #endregion
  8882. if (otherFeeStr.Length > 0)
  8883. {
  8884. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8885. otherFeeStr = $"({otherFeeStr})";
  8886. dic.Add("OtherFeeStr", otherFeeStr);
  8887. }
  8888. //总计
  8889. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8890. //国际旅费
  8891. string outsideAir = string.Empty;
  8892. string allPriceAir = string.Empty;
  8893. if (_EnterExitCosts.SumJJC == 1)
  8894. {
  8895. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8896. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8897. }
  8898. if (_EnterExitCosts.SumGWC == 1)
  8899. {
  8900. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8901. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8902. }
  8903. if (_EnterExitCosts.SumTDC == 1)
  8904. {
  8905. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8906. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8907. }
  8908. dic.Add("InTravelPrice", $"({outsideAir})");
  8909. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8910. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8911. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8912. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8913. foreach (var key in dic.Keys)
  8914. {
  8915. builder.MoveToBookmark(key);
  8916. builder.Write(dic[key]);
  8917. }
  8918. //模板文件名
  8919. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8920. strFileName = CommonFun.ValidFileName(strFileName);
  8921. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8922. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8923. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8924. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8925. }
  8926. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8927. {
  8928. //获取模板
  8929. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8930. //载入模板
  8931. WorkbookDesigner designer = new WorkbookDesigner();
  8932. designer.Workbook = new Workbook(tempPath);
  8933. Dictionary<string, string> dic = new Dictionary<string, string>();
  8934. string returnCodeLabel = string.Empty;
  8935. if (nationalTravelFeeData.Any())
  8936. {
  8937. List<string> list = new List<string>();
  8938. foreach (var item in nationalTravelFeeData)
  8939. {
  8940. list.Add($"{item.Country}({item.City})");
  8941. }
  8942. list = list.Distinct().ToList();
  8943. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8944. }
  8945. var countryLabel = string.Empty;
  8946. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8947. if (countryData.Any())
  8948. {
  8949. countryLabel = string.Join("、", countryData);
  8950. }
  8951. dic.Add("ReturnCodeAir", returnCodeLabel);
  8952. dic.Add("VisitStartDate", "-");
  8953. dic.Add("VisitEndDate", "-");
  8954. dic.Add("Day", "0");
  8955. dic.Add("VisitCountry", countryLabel);
  8956. dic.Add("ClientUnit", "-");
  8957. designer.SetDataSource("ClientUnit", "-");
  8958. designer.SetDataSource("VisitCountry", countryLabel);
  8959. designer.SetDataSource("Group", "-");
  8960. designer.SetDataSource("ClientUnitTitle", "-");
  8961. designer.SetDataSource("Name", "-");
  8962. designer.SetDataSource("VisitStartDate", "-");
  8963. designer.SetDataSource("Day", "0");
  8964. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8965. designer.SetDataSource("ReturnCodeAir", "-");
  8966. int startIndex = 10;
  8967. const int startIndexcopy = 10;
  8968. if (dac2.Count == dac3.Count)//国家 币种 金额
  8969. {
  8970. for (int i = 0; i < dac2.Count; i++)
  8971. {
  8972. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8973. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8974. }
  8975. }
  8976. DataTable dtdac1 = new DataTable();
  8977. List<string> place = new List<string>();
  8978. dtdac1.Columns.AddRange(new DataColumn[] {
  8979. new DataColumn(){ ColumnName = "city"},
  8980. new DataColumn(){ ColumnName = "curr"},
  8981. new DataColumn(){ ColumnName = "criterion"},
  8982. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8983. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8984. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8985. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8986. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8987. });
  8988. DataTable dtdac2 = new DataTable();
  8989. dtdac2.Columns.AddRange(new DataColumn[] {
  8990. new DataColumn(){ ColumnName = "city"},
  8991. new DataColumn(){ ColumnName = "curr"},
  8992. new DataColumn(){ ColumnName = "criterion"},
  8993. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8994. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8995. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8996. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8997. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8998. });
  8999. dtdac1.TableName = "tb1";
  9000. dtdac2.TableName = "tb2";
  9001. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9002. foreach (var item in dac1)
  9003. {
  9004. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9005. if (place.Contains(item.Place))
  9006. {
  9007. continue;
  9008. }
  9009. DataRow row = dtdac1.NewRow();
  9010. row["city"] = item.Place;
  9011. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9012. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9013. row["curr"] = currency;
  9014. row["rate"] = rate.ToString("#0.0000");
  9015. row["criterion"] = item.Cost.ToString("#0.00");
  9016. row["number"] = 1;
  9017. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9018. //row["costRMB"] = rbmPrice;
  9019. dtdac1.Rows.Add(row);
  9020. place.Add(item.Place);
  9021. }
  9022. place = new List<string>();
  9023. foreach (var item in dac2)
  9024. {
  9025. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9026. if (place.Contains(item.Place))
  9027. {
  9028. continue;
  9029. }
  9030. DataRow row = dtdac2.NewRow();
  9031. row["city"] = item.Place;
  9032. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9033. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9034. row["curr"] = currency;
  9035. row["rate"] = rate.ToString("#0.0000");
  9036. row["criterion"] = item.Cost.ToString("#0.00");
  9037. row["number"] = 1;
  9038. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9039. //row["cost"] = item.SubTotal;
  9040. //row["costRMB"] = rbmPrice;
  9041. dtdac2.Rows.Add(row);
  9042. place.Add(item.Place);
  9043. //dac2totalPrice += rbmPrice;
  9044. }
  9045. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9046. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9047. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9048. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9049. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9050. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9051. string cell4Str1 = string.Empty;
  9052. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9053. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9054. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9055. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9056. string cellStr = $" 5.其他费用(";
  9057. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9058. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9059. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9060. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9061. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9062. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9063. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9064. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9065. foreach (var otherInfo in dac5)
  9066. {
  9067. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9068. }
  9069. #endregion
  9070. if (cellStr.Length > 8)
  9071. {
  9072. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9073. }
  9074. cellStr += ")";
  9075. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9076. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9077. decimal pxFee = dac4.Sum(it => it.Cost);
  9078. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9079. string celllastStr1 = "";
  9080. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9081. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9082. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9083. celllastStr1 += $",国际旅费 元";
  9084. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9085. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9086. designer.SetDataSource("cell4Str", cell4Str);
  9087. designer.SetDataSource("cellStr", cellStr);
  9088. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9089. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9090. designer.SetDataSource("celllastStr", celllastStr);
  9091. Workbook wb = designer.Workbook;
  9092. var sheet = wb.Worksheets[0];
  9093. //绑定datatable数据集
  9094. designer.SetDataSource(dtdac1);
  9095. designer.SetDataSource(dtdac2);
  9096. designer.Process();
  9097. var rowStart = dtdac1.Rows.Count;
  9098. while (rowStart > 0)
  9099. {
  9100. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9101. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9102. startIndex++;
  9103. rowStart--;
  9104. }
  9105. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9106. startIndex += 1; //总计行
  9107. rowStart = dtdac2.Rows.Count;
  9108. while (rowStart > 0)
  9109. {
  9110. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9111. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9112. startIndex++;
  9113. rowStart--;
  9114. }
  9115. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9116. wb.CalculateFormula(true);
  9117. //模板文件名
  9118. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9119. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9120. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9121. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9122. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9123. }
  9124. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9125. {
  9126. //获取模板
  9127. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9128. //载入模板
  9129. Document doc = new Document(tempPath);
  9130. DocumentBuilder builder = new DocumentBuilder(doc);
  9131. Dictionary<string, string> dic = new Dictionary<string, string>();
  9132. dic.Add("GroupName", "-");
  9133. dic.Add("ClientUnit", "-");
  9134. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9135. //string missionLeaderJob = "";//负责人job
  9136. //int groupNumber = 0; //团人数
  9137. dic.Add("MissionLeader", "-"); //团负责人
  9138. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9139. dic.Add("GroupNumber", "0"); //团人数
  9140. dic.Add("Day", "0");
  9141. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9142. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9143. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9144. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9145. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9146. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9147. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9148. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9149. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9150. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9151. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9152. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9153. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9154. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9155. //其他费用
  9156. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9157. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9158. //其他费用合计
  9159. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9160. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9161. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9162. //公务舱合计
  9163. //国际旅费
  9164. //string outsideJJ = "";
  9165. //string allPriceJJ = "";
  9166. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9167. {
  9168. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9169. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9170. }
  9171. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9172. {
  9173. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9174. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9175. }
  9176. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9177. {
  9178. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9179. dic.Add("AirFeeTotal", airFeeTotalStr);
  9180. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9181. dic.Add("FeeTotal", feeTotalStr);
  9182. }
  9183. foreach (var key in dic.Keys)
  9184. {
  9185. builder.MoveToBookmark(key);
  9186. builder.Write(dic[key]);
  9187. }
  9188. //模板文件名
  9189. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9190. strFileName = CommonFun.ValidFileName(strFileName);
  9191. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9192. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9193. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9194. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9195. }
  9196. }
  9197. else if (dto.ExportType == 2) //表格
  9198. {
  9199. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9200. }
  9201. else if (dto.ExportType == 3)
  9202. {
  9203. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9204. }
  9205. return Ok(JsonView(400, "只可导出明细表!", ""));
  9206. }
  9207. catch (Exception ex)
  9208. {
  9209. return Ok(JsonView(400, ex.Message, ""));
  9210. }
  9211. }
  9212. /// <summary>
  9213. /// 获取三公费用标准city
  9214. /// </summary>
  9215. /// <param name="placeData"></param>
  9216. /// <param name="nationalTravelFeeId"></param>
  9217. /// <returns></returns>
  9218. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9219. {
  9220. string _city = string.Empty;
  9221. if (!placeData.Any()) return _city;
  9222. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9223. if (data == null) return _city;
  9224. string country = data.Country;
  9225. string city = data.City;
  9226. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9227. else _city = city;
  9228. return _city;
  9229. }
  9230. /// <summary>
  9231. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9232. /// </summary>
  9233. /// <returns></returns>
  9234. [HttpPost]
  9235. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9237. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9238. {
  9239. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9240. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9241. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9242. if (_view.Code == 0)
  9243. {
  9244. return Ok(JsonView(true, "操作成功"));
  9245. }
  9246. return Ok(JsonView(false, "操作失败"));
  9247. }
  9248. /// <summary>
  9249. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9250. /// </summary>
  9251. /// <returns></returns>
  9252. [HttpPost]
  9253. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9255. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9256. {
  9257. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9258. if (data.Code != 0)
  9259. {
  9260. return Ok(JsonView(false, data.Msg));
  9261. }
  9262. return Ok(JsonView(true, "操作成功!", data.Data));
  9263. }
  9264. /// <summary>
  9265. /// 三公其他费用草稿 删除
  9266. /// </summary>
  9267. /// <param name="dto"></param>
  9268. /// <returns></returns>
  9269. [HttpPost]
  9270. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9271. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9272. {
  9273. var jw = JsonView(false, "删除失败!");
  9274. var data = new Grp_DayOtherPriceDraft()
  9275. {
  9276. Id = dto.Id,
  9277. IsDel = 1,
  9278. DeleteUserId = dto.DeleteUserId,
  9279. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9280. };
  9281. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9282. if (del > 0)
  9283. {
  9284. jw.Code = 200;
  9285. jw.Msg = "删除成功!";
  9286. }
  9287. return Ok(jw);
  9288. }
  9289. /// <summary>
  9290. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9291. /// </summary>
  9292. /// <returns></returns>
  9293. [HttpPost]
  9294. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9295. {
  9296. var jw = JsonView(false);
  9297. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9298. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9299. jw.Code = StatusCodes.Status200OK;
  9300. jw.Msg = "操作成功!";
  9301. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9302. return Ok(jw);
  9303. }
  9304. /// <summary>
  9305. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9306. /// </summary>
  9307. /// <param name="dto"></param>
  9308. /// <returns></returns>
  9309. [HttpPost]
  9310. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9311. {
  9312. int userId = dto.UserId,
  9313. portId = dto.PortType,
  9314. groupId = dto.GroupId,
  9315. draftId = dto.DraftId;
  9316. _portTypeData.Add(1);
  9317. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9318. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9319. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9320. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9321. _sqlSugar.BeginTran();
  9322. try
  9323. {
  9324. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9325. if (draftDatas == null)
  9326. {
  9327. _sqlSugar.RollbackTran();
  9328. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9329. }
  9330. //验证可覆盖已有数据 两边创建人需为同一人;
  9331. int draftCreateUserId = draftDatas.CreateUserId,
  9332. formalCreateUserId = 0;
  9333. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9334. if (formalData != null)
  9335. {
  9336. formalCreateUserId = formalData.CreateUserId;
  9337. if (draftCreateUserId != formalCreateUserId)
  9338. {
  9339. _sqlSugar.RollbackTran();
  9340. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9341. }
  9342. }
  9343. //默认添加查看、编辑权限(创建人、自己)
  9344. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9345. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9346. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9347. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9348. newExterData.DiId = groupId;
  9349. newExterData.CreateUserId = userId;
  9350. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9351. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9352. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9353. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9354. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9355. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9356. //数据如果存在执行删除
  9357. if (enterExitCostInfo != null)
  9358. {
  9359. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9360. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9361. .Where(x => x.Id == enterExitCostInfo.Id)
  9362. .ExecuteCommand();
  9363. _sqlSugar.Updateable<Grp_DayAndCost>()
  9364. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9365. .Where(x => x.DiId == groupId)
  9366. .ExecuteCommand();
  9367. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9368. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9369. .Where(x => x.Diid == groupId)
  9370. .ExecuteCommand();
  9371. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9372. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9373. .Where(x => x.GroupId == groupId)
  9374. .ExecuteCommand();
  9375. }
  9376. //执行insert
  9377. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9378. if (insertId < 1)
  9379. {
  9380. _sqlSugar.RollbackTran();
  9381. return Ok(JsonView(false, "草稿数据导入失败!"));
  9382. }
  9383. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9384. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9385. #region 默认添加权限
  9386. #endregion
  9387. _sqlSugar.CommitTran();
  9388. //执行操作之后
  9389. //生成默认文件pdf并且通知人员
  9390. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9391. {
  9392. DiId = groupId,
  9393. ExportType = 1,
  9394. SubTypeId = 1005
  9395. }, "pdf");
  9396. //发送通知
  9397. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9398. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9399. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9400. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9401. //汇率信息记录
  9402. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9403. return Ok(JsonView(true));
  9404. }
  9405. catch (Exception ex)
  9406. {
  9407. _sqlSugar.RollbackTran();
  9408. return Ok(JsonView(false, ex.Message));
  9409. }
  9410. }
  9411. #endregion
  9412. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9413. /// <summary>
  9414. /// 获取币种基础数据(含逻辑处理)
  9415. /// </summary>
  9416. /// <returns></returns>
  9417. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9418. {
  9419. return await GeneralMethod.EnterExitCostInitRate();
  9420. }
  9421. /// <summary>
  9422. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9423. /// </summary>
  9424. /// <returns></returns>
  9425. [HttpPost]
  9426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9427. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9428. {
  9429. //验证城市归属并给默认值
  9430. int provinceId = dto.ProvinceId;
  9431. if (provinceId < 1) provinceId = 122;
  9432. var dataSource = await _sqlSugar
  9433. .Queryable<Sys_SetData>()
  9434. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9435. .ToListAsync();
  9436. var fileTypes = new List<EecSetDataInfoView>();
  9437. //三公费用-Word明细类型
  9438. var wordTypeData = dataSource
  9439. .Where(it => it.STid == 72)
  9440. .Select(x => new EecSetDataInfoView
  9441. {
  9442. ParentId = 1,
  9443. Id = x.Id,
  9444. Name = x.Name
  9445. })
  9446. .ToArray();
  9447. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9448. var excelTypeData = dataSource
  9449. .Where(it => it.STid == 73)
  9450. .Select(x => new EecSetDataInfoView
  9451. {
  9452. ParentId = 2,
  9453. Id = x.Id,
  9454. Name = x.Name
  9455. })
  9456. .ToArray();
  9457. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9458. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9459. fileTypes.Add(groupNameList);
  9460. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9461. //默认币种显示
  9462. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9463. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9464. return Ok(JsonView(true, "查询成功!", new
  9465. {
  9466. FileTypeData = fileTypes,
  9467. CurrencyInit = _currencyInfos,
  9468. viewPermissionData = viewPermissionData
  9469. }));
  9470. }
  9471. /// <summary>
  9472. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9473. /// </summary>
  9474. /// <returns></returns>
  9475. [HttpPost]
  9476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9477. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9478. {
  9479. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9480. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9481. RefAsync<int> total = 0;
  9482. int diId = 0;
  9483. var status = int.TryParse(dto.GroupName, out diId);
  9484. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9485. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9486. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9487. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9488. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9489. .OrderByDescending(x => x.VisitStartDate)
  9490. .Select(x => new EnterExitCostMobileGroupView()
  9491. {
  9492. Id = x.Id,
  9493. GroupName = x.TeamName,
  9494. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9495. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9496. ProvinceId = x.CityId
  9497. })
  9498. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9499. //处理省份Id
  9500. if (data.Any())
  9501. {
  9502. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9503. if (provCityDatas.Any())
  9504. {
  9505. foreach (var item in data)
  9506. {
  9507. var provinceId = item.ProvinceId;
  9508. var isDefualtVal = true;
  9509. if (provinceId > 0)
  9510. {
  9511. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9512. if (parentId != null)
  9513. {
  9514. isDefualtVal = false;
  9515. item.ProvinceId = (int)parentId;
  9516. }
  9517. }
  9518. if (isDefualtVal)
  9519. {
  9520. item.ProvinceId = 122; //默认四川
  9521. }
  9522. }
  9523. }
  9524. }
  9525. //处理是否显示
  9526. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9527. {
  9528. foreach (var item in data)
  9529. {
  9530. item.IsView = true;
  9531. }
  9532. }
  9533. return Ok(JsonView(true, "查询成功!", data, total));
  9534. }
  9535. /// <summary>
  9536. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9537. /// </summary>
  9538. /// <returns></returns>
  9539. [HttpPost]
  9540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9541. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9542. {
  9543. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9544. RefAsync<int> total = 0;
  9545. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9546. .Where(x => x.IsDel == 0 && x.STid == 66)
  9547. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9548. .Select(x => new
  9549. {
  9550. id = x.Id,
  9551. name = x.Name,
  9552. remark = x.Remark,
  9553. })
  9554. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9555. return Ok(JsonView(true, "查询成功!", data, total));
  9556. }
  9557. /// <summary>
  9558. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9559. /// </summary>
  9560. /// <returns></returns>
  9561. [HttpPost]
  9562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9563. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9564. {
  9565. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9566. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9567. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9568. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9569. var groupOtherRateData = groupRateData.TeamRates;
  9570. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9571. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9572. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9573. groupOtherRateData = groupOtherRateData
  9574. .Select(x => new TeamRateDescAddCurrencyIdView
  9575. {
  9576. CurrencyId = x.CurrencyId,
  9577. CurrencyName = x.CurrencyName,
  9578. CurrencyCode = x.CurrencyCode,
  9579. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9580. }).ToList();
  9581. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9582. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9583. }
  9584. /// <summary>
  9585. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9586. /// </summary>
  9587. /// <returns></returns>
  9588. [HttpPost]
  9589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9590. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9591. {
  9592. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9593. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9594. var tipsData = new List<int>() { 1, 2, 3 };
  9595. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9596. if (dto.TipsType == 1)
  9597. {
  9598. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9599. }
  9600. else if (dto.TipsType == 2)
  9601. {
  9602. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9603. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9604. }
  9605. else if (dto.TipsType == 3)
  9606. {
  9607. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9608. return Ok(JsonView(true, "查询成功!", airData));
  9609. }
  9610. return Ok(JsonView(false));
  9611. }
  9612. /// <summary>
  9613. /// 团组模块 - 出入境国家费用标准-移动端 List
  9614. /// </summary>
  9615. /// <returns></returns>
  9616. [HttpPost]
  9617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9618. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9619. {
  9620. Stopwatch sw = new Stopwatch();
  9621. sw.Start();
  9622. int provinceId = dto.ProvinceId;
  9623. if (provinceId < 1) provinceId = 122; // 默认四川
  9624. RefAsync<int> total = 0;
  9625. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9626. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9627. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9628. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9629. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9630. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9631. .Select((ntf, sd, u, sd1) => new
  9632. {
  9633. Id = ntf.Id,
  9634. Area = $"{ntf.Country}-{ntf.City}",
  9635. Currency = ntf.Currency,
  9636. CurrencyCode = sd.Name,
  9637. CurrencyName = sd.Remark,
  9638. RoomCost = ntf.RoomCost,
  9639. FoodCost = ntf.FoodCost,
  9640. PublicCost = ntf.PublicCost,
  9641. TrainCost = ntf.TrainCost,
  9642. LastUpdateUserId = ntf.LastUpdateUserId,
  9643. LastUpdateUserName = u.CnName,
  9644. LastUpdateTime = ntf.LastUpdateTime
  9645. })
  9646. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9647. sw.Stop();
  9648. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9649. }
  9650. /// <summary>
  9651. /// 团组模块 - 出入境费用-移动端 - Info
  9652. /// </summary>
  9653. /// <returns></returns>
  9654. [HttpPost]
  9655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9656. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9657. {
  9658. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9659. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9660. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9661. return Ok(data);
  9662. }
  9663. /// <summary>
  9664. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9665. /// </summary>
  9666. /// <returns></returns>
  9667. [HttpPost]
  9668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9669. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9670. {
  9671. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9672. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9673. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9674. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9675. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9676. mobileInfo.DiId = dto.DiId;
  9677. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9678. if (eecInfo == null) return Ok(mobileInfo);
  9679. //验证查看权限
  9680. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9681. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9682. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9683. mobileInfo.IsAssignPerm = isSet;
  9684. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9685. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9686. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9687. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9688. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9689. {
  9690. SubId = dac.Id,
  9691. DiId = dac.DiId,
  9692. Type = dac.Type,
  9693. Days = dac.Days,
  9694. NationalTravelFeeId = dac.NationalTravelFeeId,
  9695. Arae = $"{ntf.Country}-{ntf.City}",
  9696. Cost = dac.Cost,
  9697. Currency = dac.Currency,
  9698. CurrencyName = sd.Name,
  9699. SubTotal = dac.SubTotal,
  9700. })
  9701. .ToList();
  9702. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9703. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9704. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9705. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9706. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9707. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9708. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9709. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9710. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9711. //其他款项
  9712. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9713. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9714. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9715. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9716. .OrderBy((dop, sd1, sd2) => dop.Index)
  9717. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9718. {
  9719. SubId = dop.Id,
  9720. DiId = dop.Diid,
  9721. Index = dop.Index,
  9722. SetDataId = dop.SetDataId,
  9723. SetDataName = sd1.Name,
  9724. Cost = dop.Cost,
  9725. Currency = dop.Currency,
  9726. CurrencyName = sd2.Remark,
  9727. SubTotal = dop.SubTotal,
  9728. Remark = dop.Remark,
  9729. })
  9730. .ToArray();
  9731. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9732. return Ok(mobileInfo);
  9733. }
  9734. /// <summary>
  9735. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9736. /// </summary>
  9737. /// <returns></returns>
  9738. [HttpPost]
  9739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9740. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9741. {
  9742. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9743. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9744. //验证查看权限
  9745. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9746. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9747. var userIds = await _sqlSugar
  9748. .Queryable<Grp_EnterExitCostPermission>()
  9749. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9750. .Select(x => x.UserId)
  9751. .ToArrayAsync();
  9752. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9753. var perUsersView = new List<dynamic>();
  9754. foreach (var item in perUsers)
  9755. {
  9756. bool isView1 = false;
  9757. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9758. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9759. }
  9760. return Ok(JsonView(perUsersView));
  9761. }
  9762. /// <summary>
  9763. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9764. /// </summary>
  9765. /// <returns></returns>
  9766. [HttpPost]
  9767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9768. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9769. {
  9770. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9771. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9772. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9773. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9774. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9775. //验证查看权限
  9776. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9777. //if (!isView) return Ok(JsonView(false, msg));
  9778. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9779. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9780. var subType = dto.SubType;
  9781. if (subType == 1) //1:境内费用
  9782. {
  9783. var oneData = new ChoiceOneMobileSubInfoView()
  9784. {
  9785. Id = eecInfo.Id,
  9786. ChoiceOne = eecInfo.ChoiceOne,
  9787. ChoiceOneTotalCost = eecInfo.InsidePay,
  9788. Visa = eecInfo.Visa,
  9789. VisaRemark = eecInfo.VisaRemark,
  9790. YiMiao = eecInfo.YiMiao,
  9791. HeSuan = eecInfo.HeSuan,
  9792. Service = eecInfo.Service,
  9793. Ticket = eecInfo.Ticket,
  9794. Safe = eecInfo.Safe,
  9795. FirstItemRemark = eecInfo.FirstItemRemark
  9796. };
  9797. return Ok(JsonView(oneData));
  9798. }
  9799. else if (subType == 2) //2:国际旅费
  9800. {
  9801. var twoData = new ChoiceTwoMobileSubInfoView()
  9802. {
  9803. Id = eecInfo.Id,
  9804. ChoiceTwoJJ = eecInfo.SumJJC,
  9805. OutsideJJPay = eecInfo.OutsideJJPay,
  9806. ChoiceTwoGW = eecInfo.SumGWC,
  9807. OutsideGWPay = eecInfo.OutsideGWPay,
  9808. ChoiceTwoTD = eecInfo.SumTDC,
  9809. OutsideTDPay = eecInfo.OutsideTDPay,
  9810. AirJJ = eecInfo.AirJJ,
  9811. AirGW = eecInfo.AirGW,
  9812. AirTD = eecInfo.AirTD,
  9813. CityTranffic = eecInfo.CityTranffic,
  9814. TwoItemRemark = eecInfo.TwoItemRemark
  9815. };
  9816. return Ok(JsonView(twoData));
  9817. }
  9818. else if (subType == 3) //3:住宿费
  9819. {
  9820. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9821. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9822. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9823. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9824. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9825. {
  9826. SubId = dac.Id,
  9827. DiId = dac.DiId,
  9828. Type = dac.Type,
  9829. Days = dac.Days,
  9830. NationalTravelFeeId = dac.NationalTravelFeeId,
  9831. Arae = $"{ntf.Country}-{ntf.City}",
  9832. Cost = dac.Cost,
  9833. Currency = dac.Currency,
  9834. CurrencyName = sd.Name,
  9835. SubTotal = dac.SubTotal,
  9836. })
  9837. .ToArray();
  9838. var data = new ChoiceMobileSubInfo3To6View()
  9839. {
  9840. ParentId = eecInfo.Id,
  9841. Choice = eecInfo.ChoiceThree,
  9842. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9843. Details = dayAndCostDatas
  9844. };
  9845. return Ok(JsonView(data));
  9846. }
  9847. else if (subType == 4) //4:伙食费
  9848. {
  9849. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9850. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9851. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9852. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9853. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9854. {
  9855. SubId = dac.Id,
  9856. DiId = dac.DiId,
  9857. Type = dac.Type,
  9858. Days = dac.Days,
  9859. NationalTravelFeeId = dac.NationalTravelFeeId,
  9860. Arae = $"{ntf.Country}-{ntf.City}",
  9861. Cost = dac.Cost,
  9862. Currency = dac.Currency,
  9863. CurrencyName = sd.Name,
  9864. SubTotal = dac.SubTotal,
  9865. })
  9866. .ToArray();
  9867. var data = new ChoiceMobileSubInfo3To6View()
  9868. {
  9869. ParentId = eecInfo.Id,
  9870. Choice = eecInfo.ChoiceFour,
  9871. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9872. Details = dayAndCostDatas
  9873. };
  9874. return Ok(JsonView(data));
  9875. }
  9876. else if (subType == 5) //5:公杂费
  9877. {
  9878. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9879. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9880. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9881. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9882. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9883. {
  9884. SubId = dac.Id,
  9885. DiId = dac.DiId,
  9886. Type = dac.Type,
  9887. Days = dac.Days,
  9888. NationalTravelFeeId = dac.NationalTravelFeeId,
  9889. Arae = $"{ntf.Country}-{ntf.City}",
  9890. Cost = dac.Cost,
  9891. Currency = dac.Currency,
  9892. CurrencyName = sd.Name,
  9893. SubTotal = dac.SubTotal,
  9894. })
  9895. .ToArray();
  9896. var data = new ChoiceMobileSubInfo3To6View()
  9897. {
  9898. ParentId = eecInfo.Id,
  9899. Choice = eecInfo.ChoiceFive,
  9900. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9901. Details = dayAndCostDatas
  9902. };
  9903. return Ok(JsonView(data));
  9904. }
  9905. else if (subType == 6) //6:培训费
  9906. {
  9907. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9908. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9909. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9910. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9911. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9912. {
  9913. SubId = dac.Id,
  9914. DiId = dac.DiId,
  9915. Type = dac.Type,
  9916. Days = dac.Days,
  9917. NationalTravelFeeId = dac.NationalTravelFeeId,
  9918. Arae = $"{ntf.Country}-{ntf.City}",
  9919. Cost = dac.Cost,
  9920. Currency = dac.Currency,
  9921. CurrencyName = sd.Name,
  9922. SubTotal = dac.SubTotal,
  9923. })
  9924. .ToArray();
  9925. var data = new ChoiceMobileSubInfo3To6View()
  9926. {
  9927. ParentId = eecInfo.Id,
  9928. Choice = eecInfo.ChoiceSix,
  9929. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9930. Details = dayAndCostDatas
  9931. };
  9932. return Ok(JsonView(data));
  9933. }
  9934. else if (subType == 7) //7:其他
  9935. {
  9936. //其他款项
  9937. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9938. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9939. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9940. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9941. .OrderBy((dop, sd1, sd2) => dop.Index)
  9942. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9943. {
  9944. SubId = dop.Id,
  9945. DiId = dop.Diid,
  9946. Index = dop.Index,
  9947. SetDataId = dop.SetDataId,
  9948. SetDataName = sd1.Name,
  9949. Cost = dop.Cost,
  9950. Currency = dop.Currency,
  9951. CurrencyName = sd2.Name,
  9952. SubTotal = dop.SubTotal,
  9953. Remark = dop.Remark,
  9954. })
  9955. .ToArray();
  9956. var data = new ChoiceSevenMobileSubInfoView()
  9957. {
  9958. ParentId = eecInfo.Id,
  9959. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9960. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9961. Details = otherData
  9962. };
  9963. return Ok(JsonView(data));
  9964. }
  9965. return Ok(JsonView(false));
  9966. }
  9967. #region op
  9968. ///// <summary>
  9969. ///// 移动端更新费用消息通知
  9970. ///// </summary>
  9971. ///// <param name="diid"></param>
  9972. ///// <param name="id"></param>
  9973. ///// <param name="currUserId"></param>
  9974. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9975. //{
  9976. // try
  9977. // {
  9978. // ////生成默认文件pdf并且通知人员
  9979. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9980. // //{
  9981. // // DiId = diid,
  9982. // // ExportType = 1,
  9983. // // SubTypeId = 1005
  9984. // //}, "pdf");
  9985. // ////发送通知
  9986. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9987. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9988. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9989. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9990. // ////汇率信息记录
  9991. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9992. // }
  9993. // catch (Exception ex)
  9994. // {
  9995. // //记录日志
  9996. // throw;
  9997. // }
  9998. //}
  9999. /// <summary>
  10000. /// 验证出入境费用数据是否存在
  10001. /// 不存在添加
  10002. /// </summary>
  10003. /// <param name="diId"></param>
  10004. /// <param name="currUserId"></param>
  10005. /// <returns></returns>
  10006. /// <exception cref="CustomException"></exception>
  10007. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10008. {
  10009. var parentId = 0;
  10010. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10011. if (info != null)
  10012. {
  10013. parentId = info.Id;
  10014. }
  10015. else
  10016. {
  10017. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10018. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10019. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10020. parentId = addId;
  10021. }
  10022. return parentId;
  10023. }
  10024. /// <summary>
  10025. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10026. /// </summary>
  10027. /// <returns></returns>
  10028. [HttpPost]
  10029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10030. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10031. {
  10032. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10033. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10034. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10035. //验证编辑权限
  10036. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10037. //if (!isEdit) return Ok(JsonView(false, msg));
  10038. var permissions = new List<Grp_EnterExitCostPermission>();
  10039. foreach (var userId in dto.UserIds)
  10040. {
  10041. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10042. }
  10043. if (permissions.Any())
  10044. {
  10045. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10046. {
  10047. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10048. }
  10049. _sqlSugar.BeginTran();
  10050. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10051. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10052. if (result < 1)
  10053. {
  10054. _sqlSugar.RollbackTran();
  10055. return Ok(JsonView(false));
  10056. }
  10057. _sqlSugar.CommitTran();
  10058. return Ok(JsonView(true));
  10059. }
  10060. return Ok(JsonView(false));
  10061. }
  10062. /// <summary>
  10063. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10064. /// </summary>
  10065. /// <returns></returns>
  10066. [HttpPost]
  10067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10068. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10069. {
  10070. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10071. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10072. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10073. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10074. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10075. int id = dto.Id;
  10076. if (id <= 0) //add
  10077. {
  10078. //int provinceId = dto.ProvinceId;
  10079. int groupId = dto.DiId;
  10080. //if (provinceId < 1) provinceId = 122;
  10081. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10082. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10083. if (add < 1) return Ok(JsonView(false));
  10084. id = add;
  10085. }
  10086. else //update
  10087. {
  10088. ////验证编辑权限
  10089. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10090. //if (!isEdit) return Ok(JsonView(false, msg));
  10091. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10092. if (upd < 1) return Ok(JsonView(false));
  10093. }
  10094. #region 汇率变更时更改币种相关费用
  10095. var opDayCosts = new List<Grp_DayAndCost>();
  10096. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10097. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10098. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10099. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10100. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10101. .Select((dac, sd) => new
  10102. {
  10103. dac.Id,
  10104. dac.DiId,
  10105. CurrencyCode = sd.Name,
  10106. dac.Cost
  10107. })
  10108. .ToList();
  10109. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10110. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10111. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10112. .Select((dop, sd) => new
  10113. {
  10114. dop.Id,
  10115. dop.Diid,
  10116. CurrencyCode = sd.Name,
  10117. dop.Cost
  10118. })
  10119. .ToList();
  10120. if (dayCosts.Count > 0)
  10121. {
  10122. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10123. foreach (var dc in new_dayCosts)
  10124. {
  10125. var thisCurrency = dc.Key.ToUpper();
  10126. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10127. if (thisRate == 0.00M) continue;
  10128. foreach (var dcSub in dc)
  10129. {
  10130. opDayCosts.Add(new Grp_DayAndCost()
  10131. {
  10132. Id = dcSub.Id,
  10133. DiId = dcSub.DiId,
  10134. Cost = dcSub.Cost,
  10135. SubTotal = dcSub.Cost * thisRate,
  10136. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10137. });
  10138. }
  10139. }
  10140. if (opDayCosts.Count > 0)
  10141. {
  10142. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10143. }
  10144. }
  10145. if (dayOtherCosts.Count > 0)
  10146. {
  10147. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10148. foreach (var dc in new_dayOtherCosts)
  10149. {
  10150. var thisCurrency = dc.Key.ToUpper();
  10151. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10152. if (thisRate == 0.00M) continue;
  10153. foreach (var dcSub in dc)
  10154. {
  10155. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10156. {
  10157. Id = dcSub.Id,
  10158. Diid = dcSub.Diid,
  10159. Cost = dcSub.Cost,
  10160. SubTotal = dcSub.Cost * thisRate,
  10161. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10162. });
  10163. }
  10164. }
  10165. if (opDayOtherCosts.Count > 0)
  10166. {
  10167. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10168. }
  10169. }
  10170. #endregion
  10171. //消息通知
  10172. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10173. //汇率信息记录
  10174. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10175. return Ok(JsonView(new { parentId = id }));
  10176. }
  10177. /// <summary>
  10178. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10179. /// </summary>
  10180. /// <returns></returns>
  10181. [HttpPost]
  10182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10183. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10184. {
  10185. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10186. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10187. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10188. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10189. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10190. int id = dto.Id;
  10191. if (id <= 0) //add
  10192. {
  10193. checkboxInfo.CreateUserId = dto.CurrUserId;
  10194. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10195. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10196. if (add < 1) return Ok(JsonView(false));
  10197. }
  10198. else //update
  10199. {
  10200. ////验证编辑权限
  10201. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10202. //if (!isEdit) return Ok(JsonView(false, msg));
  10203. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10204. .UpdateColumns(x => new
  10205. {
  10206. x.ChoiceOne,
  10207. x.ChoiceTwo,
  10208. x.SumJJC,
  10209. x.SumGWC,
  10210. x.SumTDC,
  10211. x.ChoiceThree,
  10212. x.ChoiceFour,
  10213. x.ChoiceFive,
  10214. x.ChoiceSix,
  10215. x.OtherExpenses_Checked
  10216. })
  10217. .Where(x => x.Id == id)
  10218. .ExecuteCommandAsync();
  10219. if (upd < 1) return Ok(JsonView(false));
  10220. }
  10221. return Ok(JsonView(new { parentId = id }));
  10222. }
  10223. /// <summary>
  10224. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10225. /// </summary>
  10226. /// <returns></returns>
  10227. [HttpPost]
  10228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10229. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10230. {
  10231. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10232. // if (provinceId < 1) provinceId = 122;
  10233. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10234. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10235. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10236. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10237. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10238. var checkboxInfo = new Grp_EnterExitCost()
  10239. {
  10240. Id = id,
  10241. //ProvinceId = provinceId,
  10242. DiId = diId,
  10243. CreateUserId = currUserId
  10244. };
  10245. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10246. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10247. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10248. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10249. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10250. if (id <= 0) //add
  10251. {
  10252. checkboxInfo.CreateUserId = dto.CurrUserId;
  10253. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10254. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10255. if (add < 1) return Ok(JsonView(false));
  10256. }
  10257. else //update
  10258. {
  10259. ////验证编辑权限
  10260. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10261. //if (!isEdit) return Ok(JsonView(false, msg));
  10262. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10263. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10264. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10265. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10266. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10267. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10268. .Where(x => x.Id == id)
  10269. .ExecuteCommandAsync();
  10270. if (upd < 1) return Ok(JsonView(false));
  10271. }
  10272. return Ok(JsonView(new { parentId = id }));
  10273. }
  10274. /// <summary>
  10275. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10276. /// </summary>
  10277. /// <returns></returns>
  10278. [HttpPost]
  10279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10280. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10281. {
  10282. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10283. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10284. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10285. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10286. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10287. info.FirstItemRemark = dto.FirstItemRemark;
  10288. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10289. int id = dto.Id;
  10290. if (id <= 0) //add
  10291. {
  10292. info.CreateUserId = dto.CurrUserId;
  10293. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10294. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10295. if (add < 1) return Ok(JsonView(false));
  10296. id = add;
  10297. }
  10298. else //update
  10299. {
  10300. ////验证编辑权限
  10301. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10302. //if (!isEdit) return Ok(JsonView(false, msg));
  10303. var upd = await _sqlSugar.Updateable(info)
  10304. .UpdateColumns(x => new
  10305. {
  10306. x.ChoiceOne,
  10307. x.InsidePay,
  10308. x.VisaRemark,
  10309. x.Visa,
  10310. x.Service,
  10311. x.Safe,
  10312. x.Ticket,
  10313. x.HeSuan,
  10314. x.YiMiao,
  10315. x.FirstItemRemark
  10316. })
  10317. .Where(x => x.Id == id)
  10318. .ExecuteCommandAsync();
  10319. if (upd < 1) return Ok(JsonView(false));
  10320. }
  10321. //消息通知
  10322. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10323. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10324. }
  10325. /// <summary>
  10326. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10327. /// </summary>
  10328. /// <returns></returns>
  10329. [HttpPost]
  10330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10331. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10332. {
  10333. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10334. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10335. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10336. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10337. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10338. info.DiId = dto.DiId;
  10339. //info.ProvinceId = dto.ProvinceId;
  10340. info.OutsideJJPay = dto.OutsideJJPay;
  10341. info.OutsideGWPay = dto.OutsideGWPay;
  10342. info.OutsideTDPay = dto.OutsideTDPay;
  10343. info.AirJJ = dto.AirJJ;
  10344. info.AirGW = dto.AirGW;
  10345. info.AirTD = dto.AirTD;
  10346. info.CityTranffic = dto.CityTranffic;
  10347. info.TwoItemRemark = dto.TwoItemRemark;
  10348. info.SumJJC = dto.ChoiceTwoJJ;
  10349. info.SumGWC = dto.ChoiceTwoGW;
  10350. info.SumTDC = dto.ChoiceTwoTD;
  10351. int id = dto.Id;
  10352. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10353. if (id <= 0) //add
  10354. {
  10355. info.CreateUserId = dto.CurrUserId;
  10356. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10357. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10358. if (addId <= 0) return Ok(JsonView(false));
  10359. id = addId;
  10360. }
  10361. else //update
  10362. {
  10363. ////验证编辑权限
  10364. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10365. //if (!isEdit) return Ok(JsonView(false, msg));
  10366. var upd = await _sqlSugar.Updateable(info)
  10367. .UpdateColumns(x => new
  10368. {
  10369. x.SumJJC,
  10370. x.OutsideJJPay,
  10371. x.SumGWC,
  10372. x.OutsideGWPay,
  10373. x.SumTDC,
  10374. x.OutsideTDPay,
  10375. x.AirJJ,
  10376. x.AirGW,
  10377. x.AirTD,
  10378. x.CityTranffic,
  10379. x.TwoItemRemark
  10380. })
  10381. .Where(x => x.Id == id)
  10382. .ExecuteCommandAsync();
  10383. if (upd < 1) return Ok(JsonView(false));
  10384. }
  10385. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10386. gwcItemTotal = info.AirGW + info.CityTranffic;
  10387. tdcItemTotal = info.AirTD + info.CityTranffic;
  10388. //消息通知
  10389. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10390. return Ok(JsonView(new
  10391. {
  10392. parentId = id,
  10393. choiceTwoJJ = dto.ChoiceTwoJJ,
  10394. jjcItemTotal = jjcItemTotal,
  10395. choiceTwoGW = dto.ChoiceTwoGW,
  10396. gwcItemTotal = gwcItemTotal,
  10397. choiceTwoTD = dto.ChoiceTwoTD,
  10398. tdcItemTotal = tdcItemTotal
  10399. }));
  10400. }
  10401. /// <summary>
  10402. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10403. /// </summary>
  10404. /// <returns></returns>
  10405. [HttpPost]
  10406. [ApiExplorerSettings(IgnoreApi = true)]
  10407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10408. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10409. {
  10410. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10411. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10412. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10413. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10414. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10415. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10416. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10417. var infos = infos1.Select(x => new Grp_DayAndCost
  10418. {
  10419. Id = x.Id,
  10420. DiId = dto.DiId,
  10421. Type = dto.FeeType,
  10422. Days = x.Days,
  10423. NationalTravelFeeId = x.NationalTravelFeeId,
  10424. Cost = x.Cost,
  10425. Currency = x.Currency,
  10426. SubTotal = x.SubTotal,
  10427. CreateUserId = dto.CurrUserId
  10428. })
  10429. .ToList();
  10430. var adds = infos.Where(x => x.Id <= 0).ToList();
  10431. var upds = infos.Where(x => x.Id > 0).ToList();
  10432. if (adds.Count > 0)
  10433. {
  10434. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10435. if (add < 1) return Ok(JsonView(false));
  10436. }
  10437. if (upds.Count > 0)
  10438. {
  10439. var upd = await _sqlSugar.Updateable(adds)
  10440. .UpdateColumns(x => new
  10441. {
  10442. x.Days,
  10443. x.NationalTravelFeeId,
  10444. x.Cost,
  10445. x.Currency,
  10446. x.SubTotal
  10447. })
  10448. .WhereColumns(x => new { x.Id })
  10449. .ExecuteCommandAsync();
  10450. if (upd < 1) return Ok(JsonView(false));
  10451. }
  10452. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10453. //消息通知
  10454. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10455. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10456. return Ok(JsonView(new { itemTotal = itemTotal }));
  10457. }
  10458. /// <summary>
  10459. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10460. /// </summary>
  10461. /// <returns></returns>
  10462. [HttpPost]
  10463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10464. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10465. {
  10466. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10467. int subId = dto.SubId, feeType = dto.FeeType;
  10468. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10469. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10470. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10471. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10472. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10473. subInfo.Id = subId;
  10474. subInfo.DiId = dto.DiId;
  10475. if (feeType == 3) subInfo.Type = 1;
  10476. else if (feeType == 4) subInfo.Type = 2;
  10477. else if (feeType == 5) subInfo.Type = 3;
  10478. else if (feeType == 6) subInfo.Type = 4;
  10479. subInfo.CreateUserId = dto.CurrUserId;
  10480. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10481. if (parentId < 1) return Ok(JsonView(false));
  10482. //子表op
  10483. if (subId < 1)
  10484. {
  10485. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10486. if (subAdd < 1) return Ok(JsonView(false));
  10487. }
  10488. else
  10489. {
  10490. ////验证编辑权限
  10491. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10492. //if (!isEdit) return Ok(JsonView(false, msg));
  10493. var subUpd = await _sqlSugar.Updateable(subInfo)
  10494. .UpdateColumns(x => new
  10495. {
  10496. x.Days,
  10497. x.NationalTravelFeeId,
  10498. x.Cost,
  10499. x.Currency,
  10500. x.SubTotal
  10501. })
  10502. .WhereColumns(x => new { x.Id })
  10503. .ExecuteCommandAsync();
  10504. if (subUpd < 1) return Ok(JsonView(false));
  10505. }
  10506. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10507. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10508. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10509. }
  10510. /// <summary>
  10511. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10512. /// </summary>
  10513. /// <returns></returns>
  10514. [HttpPost]
  10515. [ApiExplorerSettings(IgnoreApi = true)]
  10516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10517. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10518. {
  10519. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10520. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10521. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10522. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10523. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10524. {
  10525. Id = x.Id,
  10526. Diid = dto.DiId,
  10527. SetDataId = x.SetDataId,
  10528. Index = x.Index,
  10529. Cost = x.Cost,
  10530. Currency = x.Currency,
  10531. SubTotal = x.SubTotal,
  10532. CreateUserId = dto.CurrUserId,
  10533. Remark = x.Remark
  10534. }).ToList();
  10535. var adds = infos.Where(x => x.Id <= 0).ToList();
  10536. var upds = infos.Where(x => x.Id > 0).ToList();
  10537. if (adds.Count > 0)
  10538. {
  10539. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10540. if (add < 1) return Ok(JsonView(false));
  10541. }
  10542. if (upds.Count > 0)
  10543. {
  10544. var upd = await _sqlSugar.Updateable(adds)
  10545. .UpdateColumns(x => new
  10546. {
  10547. x.Index,
  10548. x.SetDataId,
  10549. x.Cost,
  10550. x.Currency,
  10551. x.SubTotal,
  10552. x.Remark
  10553. })
  10554. .WhereColumns(x => new { x.Id })
  10555. .ExecuteCommandAsync();
  10556. if (upd < 1) return Ok(JsonView(false));
  10557. }
  10558. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10559. //消息通知
  10560. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10561. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10562. return Ok(JsonView(new { itemTotal = itemTotal }));
  10563. }
  10564. /// <summary>
  10565. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10566. /// </summary>
  10567. /// <returns></returns>
  10568. [HttpPost]
  10569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10570. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10571. {
  10572. int subId = dto.SubId;
  10573. int diId = dto.Diid;
  10574. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10575. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10576. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10577. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10578. subInfo.Id = subId;
  10579. subInfo.Diid = dto.Diid;
  10580. subInfo.CreateUserId = dto.CurrUserId;
  10581. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10582. if (parentId < 1) return Ok(JsonView(false));
  10583. #region 子表op
  10584. if (subId < 1)//add
  10585. {
  10586. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10587. if (subAdd < 1) return Ok(JsonView(false));
  10588. }
  10589. else //upd
  10590. {
  10591. ////验证编辑权限
  10592. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10593. //if (!isEdit) return Ok(JsonView(false, msg));
  10594. var subUpd = await _sqlSugar.Updateable(subInfo)
  10595. .UpdateColumns(x => new
  10596. {
  10597. x.Index,
  10598. x.SetDataId,
  10599. x.Cost,
  10600. x.Currency,
  10601. x.SubTotal,
  10602. x.Remark
  10603. })
  10604. .WhereColumns(x => new { x.Id })
  10605. .ExecuteCommandAsync();
  10606. if (subUpd < 1) return Ok(JsonView(false));
  10607. }
  10608. #endregion
  10609. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10610. //消息通知
  10611. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10612. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10613. }
  10614. /// <summary>
  10615. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10616. /// </summary>
  10617. /// <returns></returns>
  10618. [HttpPost]
  10619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10620. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10621. {
  10622. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10623. if (data.Code != 0)
  10624. {
  10625. return Ok(JsonView(false, data.Msg));
  10626. }
  10627. return Ok(JsonView(true, "操作成功!", data.Data));
  10628. }
  10629. /// <summary>
  10630. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10631. /// </summary>
  10632. /// <param name="dto"></param>
  10633. /// <returns></returns>
  10634. [HttpPost]
  10635. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10636. {
  10637. var data = new Grp_DayOtherPrice()
  10638. {
  10639. Id = dto.Id,
  10640. IsDel = 1,
  10641. DeleteUserId = dto.DeleteUserId,
  10642. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10643. };
  10644. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10645. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10646. return Ok(JsonView(false, "删除失败!"));
  10647. }
  10648. #endregion
  10649. #endregion
  10650. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10651. /// <summary>
  10652. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10653. /// </summary>
  10654. /// <returns></returns>
  10655. [HttpGet]
  10656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10657. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10658. {
  10659. var provData = await _groupRepository.ProvinceBasicSource();
  10660. return Ok(JsonView(true, "查询成功!", provData));
  10661. }
  10662. /// <summary>
  10663. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10664. /// </summary>
  10665. /// <returns></returns>
  10666. [HttpPost]
  10667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10668. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10669. {
  10670. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10671. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10672. RefAsync<int> total = 0;
  10673. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10674. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10675. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10676. .Select(x => new
  10677. {
  10678. Id = x.Id,
  10679. DraftName = x.DraftName,
  10680. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10681. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10682. .Any()
  10683. })
  10684. .OrderByDescending(x => x.Id)
  10685. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10686. return Ok(JsonView(true, "查询成功!", data, total));
  10687. }
  10688. /// <summary>
  10689. /// 出入境费用-草稿 移动端
  10690. /// 获取币种基础数据(含逻辑处理)
  10691. /// </summary>
  10692. /// <returns></returns>
  10693. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10694. {
  10695. return await GeneralMethod.EnterExitCostInitRate();
  10696. }
  10697. /// <summary>
  10698. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10699. /// </summary>
  10700. /// <returns></returns>
  10701. [HttpPost]
  10702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10703. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10704. {
  10705. //验证城市归属并给默认值
  10706. int provinceId = dto.ProvinceId;
  10707. if (provinceId < 1) provinceId = 122;
  10708. var dataSource = await _sqlSugar
  10709. .Queryable<Sys_SetData>()
  10710. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10711. .ToListAsync();
  10712. //三公费用-Word明细类型
  10713. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10714. .Select(x => new SetDataInfoView
  10715. {
  10716. Id = x.Id,
  10717. Name = x.Name,
  10718. Remark = x.Remark
  10719. })
  10720. .ToList();
  10721. //三公费用-Excel明细类型
  10722. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10723. .Select(x => new SetDataInfoView
  10724. {
  10725. Id = x.Id,
  10726. Name = x.Name,
  10727. Remark = x.Remark
  10728. })
  10729. .ToList();
  10730. //默认币种显示
  10731. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10732. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10733. return Ok(JsonView(true, "查询成功!", new
  10734. {
  10735. WordTypeData = wordTypeData,
  10736. ExcelTypeData = excelTypeData,
  10737. CurrencyInit = _currencyInfos,
  10738. viewPermissionData = viewPermissionData
  10739. }));
  10740. }
  10741. /// <summary>
  10742. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10743. /// </summary>
  10744. /// <returns></returns>
  10745. [HttpPost]
  10746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10747. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10748. {
  10749. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10750. RefAsync<int> total = 0;
  10751. int diId = 0;
  10752. var status = int.TryParse(dto.GroupName, out diId);
  10753. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10754. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10755. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10756. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10757. .OrderByDescending(x => x.VisitStartDate)
  10758. .Select(x => new
  10759. {
  10760. Id = x.Id,
  10761. GroupName = x.TeamName
  10762. })
  10763. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10764. return Ok(JsonView(true, "查询成功!", data, total));
  10765. }
  10766. /// <summary>
  10767. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10768. /// </summary>
  10769. /// <returns></returns>
  10770. [HttpPost]
  10771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10772. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10773. {
  10774. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10775. RefAsync<int> total = 0;
  10776. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10777. .Where(x => x.IsDel == 0 && x.STid == 66)
  10778. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10779. .Select(x => new
  10780. {
  10781. id = x.Id,
  10782. name = x.Name,
  10783. remark = x.Remark,
  10784. })
  10785. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10786. return Ok(JsonView(true, "查询成功!", data, total));
  10787. }
  10788. /// <summary>
  10789. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10790. /// </summary>
  10791. /// <returns></returns>
  10792. [HttpPost]
  10793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10794. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10795. {
  10796. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10797. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10798. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10799. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10800. var groupOtherRateData = groupRateData.TeamRates;
  10801. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10802. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10803. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10804. groupOtherRateData = groupOtherRateData
  10805. .Select(x => new TeamRateDescAddCurrencyIdView
  10806. {
  10807. CurrencyId = x.CurrencyId,
  10808. CurrencyName = x.CurrencyName,
  10809. CurrencyCode = x.CurrencyCode,
  10810. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10811. }).ToList();
  10812. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10813. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10814. }
  10815. /// <summary>
  10816. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10817. /// </summary>
  10818. /// <returns></returns>
  10819. [HttpPost]
  10820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10821. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10822. {
  10823. int portType = dto.PortType;
  10824. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10825. var tipsData = new List<int>() { 1, 2, 3 };
  10826. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10827. if (dto.TipsType == 1)
  10828. {
  10829. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10830. }
  10831. else if (dto.TipsType == 2)
  10832. {
  10833. if (portType == 2)
  10834. {
  10835. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10836. }
  10837. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10838. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10839. .Select(x => x.NationalTravelFeeId)
  10840. .Distinct()
  10841. .ToListAsync();
  10842. if (portType == 2)
  10843. {
  10844. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10845. }
  10846. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10847. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10848. .Select(x => x.Country)
  10849. .Distinct()
  10850. .ToArrayAsync();
  10851. if (portType == 2)
  10852. {
  10853. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10854. }
  10855. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10856. return Ok(JsonView(true, "查询成功!", new
  10857. {
  10858. totalAmt = totalAmt,
  10859. remark = remark
  10860. }));
  10861. }
  10862. else if (dto.TipsType == 3)
  10863. {
  10864. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10865. }
  10866. return Ok(JsonView(false));
  10867. }
  10868. /// <summary>
  10869. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10870. /// </summary>
  10871. /// <returns></returns>
  10872. [HttpPost]
  10873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10874. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10875. {
  10876. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10877. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10878. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10879. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10880. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10881. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10882. var info = new Grp_EnterExitCostDraft()
  10883. {
  10884. ProvinceId = dto.ProvinceId,
  10885. DraftName = dto.DraftName,
  10886. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10887. CreateUserId = dto.CurrUserId
  10888. };
  10889. _sqlSugar.BeginTran();
  10890. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10891. if (draftId < 1)
  10892. {
  10893. _sqlSugar.RollbackTran();
  10894. return Ok(JsonView(false, "草稿创建失败!"));
  10895. }
  10896. //添加默认权限
  10897. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10898. _sqlSugar.CommitTran();
  10899. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10900. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10901. mobileInfo.Id = draftId;
  10902. mobileInfo.DraftName = dto.DraftName;
  10903. mobileInfo.Currencys = rateInfos;
  10904. mobileInfo.IsAssignPerm = assignPerm;
  10905. return Ok(JsonView(mobileInfo));
  10906. }
  10907. /// <summary>
  10908. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10909. /// </summary>
  10910. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10911. /// <summary>
  10912. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10913. /// </summary>
  10914. /// <returns></returns>
  10915. [HttpPost]
  10916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10917. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10918. {
  10919. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10920. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10921. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10922. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10923. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10924. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10925. //验证查看编辑权限
  10926. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10927. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10928. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10929. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10930. mobileInfo.IsAssignPerm = assignPerm;
  10931. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10932. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10933. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10934. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10935. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10936. {
  10937. ParentId = dac.ParentId,
  10938. SubId = dac.Id,
  10939. Type = dac.Type,
  10940. Days = dac.Days,
  10941. NationalTravelFeeId = dac.NationalTravelFeeId,
  10942. Arae = $"{ntf.Country}-{ntf.City}",
  10943. Cost = dac.Cost,
  10944. Currency = dac.Currency,
  10945. CurrencyName = sd.Name,
  10946. SubTotal = dac.SubTotal,
  10947. })
  10948. .ToList();
  10949. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10950. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10951. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10952. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10953. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10954. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10955. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10956. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10957. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10958. //其他款项
  10959. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10960. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10961. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10962. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10963. .OrderBy((dop, sd1, sd2) => dop.Index)
  10964. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10965. {
  10966. ParentId = dop.ParentId,
  10967. SubId = dop.Id,
  10968. Index = dop.Index,
  10969. SetDataId = dop.SetDataId,
  10970. SetDataName = sd1.Name,
  10971. Cost = dop.Cost,
  10972. Currency = dop.Currency,
  10973. CurrencyName = sd2.Remark,
  10974. SubTotal = dop.SubTotal,
  10975. Remark = dop.Remark,
  10976. })
  10977. .ToArray();
  10978. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10979. return Ok(mobileInfo);
  10980. }
  10981. /// <summary>
  10982. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10983. /// </summary>
  10984. /// <returns></returns>
  10985. [HttpPost]
  10986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10987. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10988. {
  10989. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10990. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10991. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10992. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10993. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10994. //验证查看编辑权限
  10995. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10996. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10997. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10998. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10999. var subType = dto.SubType;
  11000. if (subType == 1) //1:境内费用
  11001. {
  11002. var oneData = new ChoiceOneMobileSubInfoView()
  11003. {
  11004. Id = eecInfo.Id,
  11005. ChoiceOne = eecInfo.ChoiceOne,
  11006. ChoiceOneTotalCost = eecInfo.InsidePay,
  11007. Visa = eecInfo.Visa,
  11008. VisaRemark = eecInfo.VisaRemark,
  11009. YiMiao = eecInfo.YiMiao,
  11010. HeSuan = eecInfo.HeSuan,
  11011. Service = eecInfo.Service,
  11012. Ticket = eecInfo.Ticket,
  11013. Safe = eecInfo.Safe,
  11014. FirstItemRemark = eecInfo.FirstItemRemark
  11015. };
  11016. return Ok(JsonView(oneData));
  11017. }
  11018. else if (subType == 2) //2:国际旅费
  11019. {
  11020. var twoData = new ChoiceTwoMobileSubInfoView()
  11021. {
  11022. Id = eecInfo.Id,
  11023. ChoiceTwoJJ = eecInfo.SumJJC,
  11024. OutsideJJPay = eecInfo.OutsideJJPay,
  11025. ChoiceTwoGW = eecInfo.SumGWC,
  11026. OutsideGWPay = eecInfo.OutsideGWPay,
  11027. ChoiceTwoTD = eecInfo.SumTDC,
  11028. OutsideTDPay = eecInfo.OutsideTDPay,
  11029. AirJJ = eecInfo.AirJJ,
  11030. AirGW = eecInfo.AirGW,
  11031. AirTD = eecInfo.AirTD,
  11032. CityTranffic = eecInfo.CityTranffic,
  11033. TwoItemRemark = eecInfo.TwoItemRemark
  11034. };
  11035. return Ok(JsonView(twoData));
  11036. }
  11037. else if (subType == 3) //3:住宿费
  11038. {
  11039. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11040. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11041. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11042. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11043. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11044. {
  11045. ParentId = dac.ParentId,
  11046. SubId = dac.Id,
  11047. Type = dac.Type,
  11048. Days = dac.Days,
  11049. NationalTravelFeeId = dac.NationalTravelFeeId,
  11050. Arae = $"{ntf.Country}-{ntf.City}",
  11051. Cost = dac.Cost,
  11052. Currency = dac.Currency,
  11053. CurrencyName = sd.Name,
  11054. SubTotal = dac.SubTotal,
  11055. })
  11056. .ToArray();
  11057. var data = new ChoiceDraftMobileSubInfo3To6View()
  11058. {
  11059. ParentId = eecInfo.Id,
  11060. Choice = eecInfo.ChoiceThree,
  11061. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11062. Details = dayAndCostDatas
  11063. };
  11064. return Ok(JsonView(data));
  11065. }
  11066. else if (subType == 4) //4:伙食费
  11067. {
  11068. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11069. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11070. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11071. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11072. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11073. {
  11074. ParentId = dac.ParentId,
  11075. SubId = dac.Id,
  11076. Type = dac.Type,
  11077. Days = dac.Days,
  11078. NationalTravelFeeId = dac.NationalTravelFeeId,
  11079. Arae = $"{ntf.Country}-{ntf.City}",
  11080. Cost = dac.Cost,
  11081. Currency = dac.Currency,
  11082. CurrencyName = sd.Name,
  11083. SubTotal = dac.SubTotal,
  11084. })
  11085. .ToArray();
  11086. var data = new ChoiceDraftMobileSubInfo3To6View()
  11087. {
  11088. ParentId = eecInfo.Id,
  11089. Choice = eecInfo.ChoiceFour,
  11090. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11091. Details = dayAndCostDatas
  11092. };
  11093. return Ok(JsonView(data));
  11094. }
  11095. else if (subType == 5) //5:公杂费
  11096. {
  11097. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11098. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11099. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11100. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11101. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11102. {
  11103. ParentId = dac.ParentId,
  11104. SubId = dac.Id,
  11105. Type = dac.Type,
  11106. Days = dac.Days,
  11107. NationalTravelFeeId = dac.NationalTravelFeeId,
  11108. Arae = $"{ntf.Country}-{ntf.City}",
  11109. Cost = dac.Cost,
  11110. Currency = dac.Currency,
  11111. CurrencyName = sd.Name,
  11112. SubTotal = dac.SubTotal,
  11113. })
  11114. .ToArray();
  11115. var data = new ChoiceDraftMobileSubInfo3To6View()
  11116. {
  11117. ParentId = eecInfo.Id,
  11118. Choice = eecInfo.ChoiceFive,
  11119. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11120. Details = dayAndCostDatas
  11121. };
  11122. return Ok(JsonView(data));
  11123. }
  11124. else if (subType == 6) //6:培训费
  11125. {
  11126. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11127. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11128. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11129. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11130. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11131. {
  11132. ParentId = dac.ParentId,
  11133. SubId = dac.Id,
  11134. Type = dac.Type,
  11135. Days = dac.Days,
  11136. NationalTravelFeeId = dac.NationalTravelFeeId,
  11137. Arae = $"{ntf.Country}-{ntf.City}",
  11138. Cost = dac.Cost,
  11139. Currency = dac.Currency,
  11140. CurrencyName = sd.Name,
  11141. SubTotal = dac.SubTotal,
  11142. })
  11143. .ToArray();
  11144. var data = new ChoiceDraftMobileSubInfo3To6View()
  11145. {
  11146. ParentId = eecInfo.Id,
  11147. Choice = eecInfo.ChoiceSix,
  11148. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11149. Details = dayAndCostDatas
  11150. };
  11151. return Ok(JsonView(data));
  11152. }
  11153. else if (subType == 7) //7:其他
  11154. {
  11155. //其他款项
  11156. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11157. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11158. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11159. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11160. .OrderBy((dop, sd1, sd2) => dop.Index)
  11161. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11162. {
  11163. ParentId = dop.ParentId,
  11164. SubId = dop.Id,
  11165. Index = dop.Index,
  11166. SetDataId = dop.SetDataId,
  11167. SetDataName = sd1.Name,
  11168. Cost = dop.Cost,
  11169. Currency = dop.Currency,
  11170. CurrencyName = sd2.Name,
  11171. SubTotal = dop.SubTotal,
  11172. Remark = dop.Remark,
  11173. })
  11174. .ToArray();
  11175. var data = new ChoiceSevenDraftMobileSubInfoView()
  11176. {
  11177. ParentId = eecInfo.Id,
  11178. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11179. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11180. Details = otherData
  11181. };
  11182. return Ok(JsonView(data));
  11183. }
  11184. return Ok(JsonView(false));
  11185. }
  11186. #region op
  11187. ///// <summary>
  11188. ///// 移动端更新费用消息通知
  11189. ///// </summary>
  11190. ///// <param name="draftId"></param>
  11191. ///// <param name="id"></param>
  11192. ///// <param name="currUserId"></param>
  11193. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11194. //{
  11195. // try
  11196. // {
  11197. // ////生成默认文件pdf并且通知人员
  11198. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11199. // //{
  11200. // // DiId = draftId,
  11201. // // ExportType = 1,
  11202. // // SubTypeId = 1005
  11203. // //}, "pdf");
  11204. // ////发送通知
  11205. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11206. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11207. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11208. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11209. // ////汇率信息记录
  11210. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11211. // }
  11212. // catch (Exception ex)
  11213. // {
  11214. // //记录日志
  11215. // throw;
  11216. // }
  11217. //}
  11218. /// <summary>
  11219. /// 验证出入境费用数据是否存在
  11220. /// 不存在添加
  11221. /// </summary>
  11222. /// <param name="draftId"></param>
  11223. /// <param name="currUserId"></param>
  11224. /// <returns></returns>
  11225. /// <exception cref="CustomException"></exception>
  11226. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11227. {
  11228. var parentId = 0;
  11229. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11230. if (info != null) parentId = info.Id;
  11231. else
  11232. {
  11233. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11234. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11235. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11236. parentId = addId;
  11237. }
  11238. return parentId;
  11239. }
  11240. /// <summary>
  11241. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11242. /// </summary>
  11243. /// <returns></returns>
  11244. [HttpPost]
  11245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11246. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11247. {
  11248. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11249. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11250. //验证查看权限
  11251. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11252. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11253. var userIds = await _sqlSugar
  11254. .Queryable<Grp_EnterExitCostDraftPermission>()
  11255. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11256. .Select(x => x.UserId)
  11257. .ToArrayAsync();
  11258. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11259. var perUsersView = new List<dynamic>();
  11260. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11261. var viewPermissionData = new List<PermissionViewUserview>();
  11262. if (feeBasePerm.Any())
  11263. {
  11264. foreach (var item in feeBasePerm)
  11265. {
  11266. if (item.Users.Any())
  11267. {
  11268. viewPermissionData.AddRange(item.Users);
  11269. }
  11270. }
  11271. }
  11272. foreach (var item in perUsers)
  11273. {
  11274. bool isView1 = false;
  11275. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11276. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11277. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11278. }
  11279. return Ok(JsonView(perUsersView));
  11280. }
  11281. /// <summary>
  11282. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11283. /// </summary>
  11284. /// <returns></returns>
  11285. [HttpPost]
  11286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11287. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11288. {
  11289. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11290. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11291. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11292. //验证查看编辑权限
  11293. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11294. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11295. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11296. foreach (var userId in dto.UserIds)
  11297. {
  11298. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11299. }
  11300. if (permissions.Any())
  11301. {
  11302. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11303. {
  11304. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11305. }
  11306. _sqlSugar.BeginTran();
  11307. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11308. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11309. if (result < 1)
  11310. {
  11311. _sqlSugar.RollbackTran();
  11312. return Ok(JsonView(false));
  11313. }
  11314. _sqlSugar.CommitTran();
  11315. return Ok(JsonView(true));
  11316. }
  11317. return Ok(JsonView(false));
  11318. }
  11319. /// <summary>
  11320. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11321. /// </summary>
  11322. /// <returns></returns>
  11323. [HttpPost]
  11324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11325. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11326. {
  11327. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11328. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11329. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11330. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11331. int id = dto.DraftId;
  11332. if (id <= 0) //add
  11333. {
  11334. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11335. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11336. if (add < 1) return Ok(JsonView(false));
  11337. id = add;
  11338. }
  11339. else //update
  11340. {
  11341. //验证查看编辑权限
  11342. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11343. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11344. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11345. if (upd < 1) return Ok(JsonView(false));
  11346. }
  11347. return Ok(JsonView(new { parentId = id }));
  11348. }
  11349. /// <summary>
  11350. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11351. /// </summary>
  11352. /// <returns></returns>
  11353. [HttpPost]
  11354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11355. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11356. {
  11357. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11358. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11359. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11360. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11361. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11362. int id = dto.DraftId;
  11363. if (id <= 0) //add
  11364. {
  11365. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11366. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11367. if (add < 1) return Ok(JsonView(false));
  11368. id = add;
  11369. }
  11370. else //update
  11371. {
  11372. //验证查看编辑权限
  11373. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11374. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11375. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11376. if (upd < 1) return Ok(JsonView(false));
  11377. }
  11378. #region 汇率变更时更改币种相关费用
  11379. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11380. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11381. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11382. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11383. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11384. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11385. .Select((dac, sd) => new
  11386. {
  11387. dac.Id,
  11388. dac.ParentId,
  11389. CurrencyCode = sd.Name,
  11390. dac.Cost
  11391. })
  11392. .ToList();
  11393. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11394. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11395. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11396. .Select((dop, sd) => new
  11397. {
  11398. dop.Id,
  11399. dop.ParentId,
  11400. CurrencyCode = sd.Name,
  11401. dop.Cost
  11402. })
  11403. .ToList();
  11404. if (dayCosts.Count > 0)
  11405. {
  11406. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11407. foreach (var dc in new_dayCosts)
  11408. {
  11409. var thisCurrency = dc.Key.ToUpper();
  11410. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11411. if (thisRate == 0.00M) continue;
  11412. foreach (var dcSub in dc)
  11413. {
  11414. opDayCosts.Add(new Grp_DayAndCostDraft()
  11415. {
  11416. Id = dcSub.Id,
  11417. ParentId = dcSub.ParentId,
  11418. Cost = dcSub.Cost,
  11419. SubTotal = dcSub.Cost * thisRate,
  11420. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11421. });
  11422. }
  11423. }
  11424. if (opDayCosts.Count > 0)
  11425. {
  11426. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11427. }
  11428. }
  11429. if (dayOtherCosts.Count > 0)
  11430. {
  11431. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11432. foreach (var dc in new_dayOtherCosts)
  11433. {
  11434. var thisCurrency = dc.Key.ToUpper();
  11435. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11436. if (thisRate == 0.00M) continue;
  11437. foreach (var dcSub in dc)
  11438. {
  11439. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11440. {
  11441. Id = dcSub.Id,
  11442. ParentId = dcSub.ParentId,
  11443. Cost = dcSub.Cost,
  11444. SubTotal = dcSub.Cost * thisRate,
  11445. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11446. });
  11447. }
  11448. }
  11449. if (opDayOtherCosts.Count > 0)
  11450. {
  11451. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11452. }
  11453. }
  11454. #endregion
  11455. ////消息通知
  11456. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11457. ////汇率信息记录
  11458. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11459. return Ok(JsonView(new { parentId = id }));
  11460. }
  11461. /// <summary>
  11462. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11463. /// </summary>
  11464. /// <returns></returns>
  11465. [HttpPost]
  11466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11467. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11468. {
  11469. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11470. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11471. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11472. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11473. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11474. int id = dto.DraftId;
  11475. if (id <= 0) //add
  11476. {
  11477. checkboxInfo.ProvinceId = dto.ProvinceId;
  11478. checkboxInfo.CreateUserId = dto.CurrUserId;
  11479. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11480. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11481. if (add < 1) return Ok(JsonView(false));
  11482. }
  11483. else //update
  11484. {
  11485. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11486. .UpdateColumns(x => new
  11487. {
  11488. x.ChoiceOne,
  11489. x.ChoiceTwo,
  11490. x.SumJJC,
  11491. x.SumGWC,
  11492. x.SumTDC,
  11493. x.ChoiceThree,
  11494. x.ChoiceFour,
  11495. x.ChoiceFive,
  11496. x.ChoiceSix,
  11497. x.OtherExpenses_Checked
  11498. })
  11499. .Where(x => x.Id == id)
  11500. .ExecuteCommandAsync();
  11501. if (upd < 1) return Ok(JsonView(false));
  11502. }
  11503. return Ok(JsonView(new { parentId = id }));
  11504. }
  11505. /// <summary>
  11506. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11507. /// </summary>
  11508. /// <returns></returns>
  11509. [HttpPost]
  11510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11511. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11512. {
  11513. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11514. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11515. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11516. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11517. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11518. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11519. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11520. var checkboxInfo = new Grp_EnterExitCostDraft()
  11521. {
  11522. Id = draftId,
  11523. ProvinceId = dto.ProvinceId,
  11524. CreateUserId = currUserId
  11525. };
  11526. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11527. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11528. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11529. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11530. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11531. if (draftId <= 0) //add
  11532. {
  11533. checkboxInfo.CreateUserId = dto.CurrUserId;
  11534. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11535. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11536. if (add < 1) return Ok(JsonView(false));
  11537. }
  11538. else //update
  11539. {
  11540. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11541. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11542. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11543. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11544. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11545. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11546. .Where(x => x.Id == draftId)
  11547. .ExecuteCommandAsync();
  11548. if (upd < 1) return Ok(JsonView(false));
  11549. }
  11550. return Ok(JsonView(new { parentId = draftId }));
  11551. }
  11552. /// <summary>
  11553. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11554. /// </summary>
  11555. /// <returns></returns>
  11556. [HttpPost]
  11557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11558. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11559. {
  11560. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11561. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11562. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11563. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11564. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11565. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11566. info.ProvinceId = dto.ProvinceId;
  11567. info.FirstItemRemark = dto.FirstItemRemark;
  11568. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11569. if (id <= 0) //add
  11570. {
  11571. info.CreateUserId = dto.CurrUserId;
  11572. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11573. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11574. if (add < 1) return Ok(JsonView(false));
  11575. id = add;
  11576. }
  11577. else //update
  11578. {
  11579. var upd = await _sqlSugar.Updateable(info)
  11580. .UpdateColumns(x => new
  11581. {
  11582. x.ChoiceOne,
  11583. x.InsidePay,
  11584. x.VisaRemark,
  11585. x.Visa,
  11586. x.Service,
  11587. x.Safe,
  11588. x.Ticket,
  11589. x.HeSuan,
  11590. x.YiMiao,
  11591. x.FirstItemRemark
  11592. })
  11593. .Where(x => x.Id == id)
  11594. .ExecuteCommandAsync();
  11595. if (upd < 1) return Ok(JsonView(false));
  11596. }
  11597. ////消息通知
  11598. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11599. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11600. }
  11601. /// <summary>
  11602. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11603. /// </summary>
  11604. /// <returns></returns>
  11605. [HttpPost]
  11606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11607. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11608. {
  11609. int id = dto.DraftId;
  11610. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11611. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11612. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11613. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11614. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11615. info.ProvinceId = dto.ProvinceId;
  11616. info.OutsideJJPay = dto.OutsideJJPay;
  11617. info.OutsideGWPay = dto.OutsideGWPay;
  11618. info.OutsideTDPay = dto.OutsideTDPay;
  11619. info.AirJJ = dto.AirJJ;
  11620. info.AirGW = dto.AirGW;
  11621. info.AirTD = dto.AirTD;
  11622. info.CityTranffic = dto.CityTranffic;
  11623. info.TwoItemRemark = dto.TwoItemRemark;
  11624. info.SumJJC = dto.ChoiceTwoJJ;
  11625. info.SumGWC = dto.ChoiceTwoGW;
  11626. info.SumTDC = dto.ChoiceTwoTD;
  11627. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11628. if (id <= 0) //add
  11629. {
  11630. info.CreateUserId = dto.CurrUserId;
  11631. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11632. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11633. if (addId <= 0) return Ok(JsonView(false));
  11634. id = addId;
  11635. }
  11636. else //update
  11637. {
  11638. var upd = await _sqlSugar.Updateable(info)
  11639. .UpdateColumns(x => new
  11640. {
  11641. x.SumJJC,
  11642. x.OutsideJJPay,
  11643. x.SumGWC,
  11644. x.OutsideGWPay,
  11645. x.SumTDC,
  11646. x.OutsideTDPay,
  11647. x.AirJJ,
  11648. x.AirGW,
  11649. x.AirTD,
  11650. x.CityTranffic,
  11651. x.TwoItemRemark
  11652. })
  11653. .Where(x => x.Id == id)
  11654. .ExecuteCommandAsync();
  11655. if (upd < 1) return Ok(JsonView(false));
  11656. }
  11657. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11658. gwcItemTotal = info.AirGW + info.CityTranffic;
  11659. tdcItemTotal = info.AirTD + info.CityTranffic;
  11660. ////消息通知
  11661. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11662. return Ok(JsonView(new
  11663. {
  11664. parentId = id,
  11665. choiceTwoJJ = dto.ChoiceTwoJJ,
  11666. jjcItemTotal = jjcItemTotal,
  11667. choiceTwoGW = dto.ChoiceTwoGW,
  11668. gwcItemTotal = gwcItemTotal,
  11669. choiceTwoTD = dto.ChoiceTwoTD,
  11670. tdcItemTotal = tdcItemTotal
  11671. }));
  11672. }
  11673. /// <summary>
  11674. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11675. /// </summary>
  11676. /// <returns></returns>
  11677. [HttpPost]
  11678. [ApiExplorerSettings(IgnoreApi = true)]
  11679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11680. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11681. {
  11682. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11683. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11684. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11685. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11686. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11687. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11688. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11689. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11690. {
  11691. Id = x.Id,
  11692. ParentId = dto.DraftId,
  11693. Type = dto.FeeType,
  11694. Days = x.Days,
  11695. NationalTravelFeeId = x.NationalTravelFeeId,
  11696. Cost = x.Cost,
  11697. Currency = x.Currency,
  11698. SubTotal = x.SubTotal,
  11699. CreateUserId = dto.CurrUserId
  11700. })
  11701. .ToList();
  11702. var adds = infos.Where(x => x.Id <= 0).ToList();
  11703. var upds = infos.Where(x => x.Id > 0).ToList();
  11704. if (adds.Count > 0)
  11705. {
  11706. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11707. if (add < 1) return Ok(JsonView(false));
  11708. }
  11709. if (upds.Count > 0)
  11710. {
  11711. var upd = await _sqlSugar.Updateable(adds)
  11712. .UpdateColumns(x => new
  11713. {
  11714. x.Days,
  11715. x.NationalTravelFeeId,
  11716. x.Cost,
  11717. x.Currency,
  11718. x.SubTotal
  11719. })
  11720. .WhereColumns(x => new { x.Id })
  11721. .ExecuteCommandAsync();
  11722. if (upd < 1) return Ok(JsonView(false));
  11723. }
  11724. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11725. ////消息通知
  11726. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11727. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11728. return Ok(JsonView(new { itemTotal = itemTotal }));
  11729. }
  11730. /// <summary>
  11731. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11732. /// </summary>
  11733. /// <returns></returns>
  11734. [HttpPost]
  11735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11736. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11737. {
  11738. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11739. int subId = dto.SubId, feeType = dto.FeeType;
  11740. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11741. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11742. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11743. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11744. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11745. subInfo.Id = subId;
  11746. subInfo.ParentId = dto.DraftId;
  11747. if (feeType == 3) subInfo.Type = 1;
  11748. else if (feeType == 4) subInfo.Type = 2;
  11749. else if (feeType == 5) subInfo.Type = 3;
  11750. else if (feeType == 6) subInfo.Type = 4;
  11751. subInfo.CreateUserId = dto.CurrUserId;
  11752. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11753. if (parentId < 1) return Ok(JsonView(false));
  11754. //子表op
  11755. if (subId < 1)
  11756. {
  11757. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11758. if (subAdd < 1) return Ok(JsonView(false));
  11759. }
  11760. else
  11761. {
  11762. var subUpd = await _sqlSugar.Updateable(subInfo)
  11763. .UpdateColumns(x => new
  11764. {
  11765. x.Days,
  11766. x.NationalTravelFeeId,
  11767. x.Cost,
  11768. x.Currency,
  11769. x.SubTotal
  11770. })
  11771. .WhereColumns(x => new { x.Id })
  11772. .ExecuteCommandAsync();
  11773. if (subUpd < 1) return Ok(JsonView(false));
  11774. }
  11775. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11776. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11777. }
  11778. /// <summary>
  11779. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11780. /// </summary>
  11781. /// <returns></returns>
  11782. [HttpPost]
  11783. [ApiExplorerSettings(IgnoreApi = true)]
  11784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11785. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11786. {
  11787. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11788. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11789. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11790. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11791. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11792. {
  11793. Id = x.Id,
  11794. ParentId = dto.DraftId,
  11795. SetDataId = x.SetDataId,
  11796. Index = x.Index,
  11797. Cost = x.Cost,
  11798. Currency = x.Currency,
  11799. SubTotal = x.SubTotal,
  11800. CreateUserId = dto.CurrUserId,
  11801. Remark = x.Remark
  11802. }).ToList();
  11803. var adds = infos.Where(x => x.Id <= 0).ToList();
  11804. var upds = infos.Where(x => x.Id > 0).ToList();
  11805. if (adds.Count > 0)
  11806. {
  11807. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11808. if (add < 1) return Ok(JsonView(false));
  11809. }
  11810. if (upds.Count > 0)
  11811. {
  11812. var upd = await _sqlSugar.Updateable(adds)
  11813. .UpdateColumns(x => new
  11814. {
  11815. x.Index,
  11816. x.SetDataId,
  11817. x.Cost,
  11818. x.Currency,
  11819. x.SubTotal,
  11820. x.Remark
  11821. })
  11822. .WhereColumns(x => new { x.Id })
  11823. .ExecuteCommandAsync();
  11824. if (upd < 1) return Ok(JsonView(false));
  11825. }
  11826. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11827. //消息通知
  11828. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11829. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11830. return Ok(JsonView(new { itemTotal = itemTotal }));
  11831. }
  11832. /// <summary>
  11833. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11834. /// </summary>
  11835. /// <returns></returns>
  11836. [HttpPost]
  11837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11838. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11839. {
  11840. int subId = dto.SubId, id = dto.DraftId;
  11841. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11842. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11843. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11844. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11845. subInfo.Id = subId;
  11846. subInfo.ParentId = id;
  11847. subInfo.CreateUserId = dto.CurrUserId;
  11848. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11849. if (parentId < 1) return Ok(JsonView(false));
  11850. #region 子表op
  11851. if (subId < 1)//add
  11852. {
  11853. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11854. if (subAdd < 1) return Ok(JsonView(false));
  11855. }
  11856. else //upd
  11857. {
  11858. var subUpd = await _sqlSugar.Updateable(subInfo)
  11859. .UpdateColumns(x => new
  11860. {
  11861. x.Index,
  11862. x.SetDataId,
  11863. x.Cost,
  11864. x.Currency,
  11865. x.SubTotal,
  11866. x.Remark
  11867. })
  11868. .WhereColumns(x => new { x.Id })
  11869. .ExecuteCommandAsync();
  11870. if (subUpd < 1) return Ok(JsonView(false));
  11871. }
  11872. #endregion
  11873. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11874. ////消息通知
  11875. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11876. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11877. }
  11878. /// <summary>
  11879. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11880. /// </summary>
  11881. /// <returns></returns>
  11882. [HttpPost]
  11883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11884. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11885. {
  11886. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11887. if (data.Code != 0)
  11888. {
  11889. return Ok(JsonView(false, data.Msg));
  11890. }
  11891. return Ok(JsonView(true, "操作成功!", data.Data));
  11892. }
  11893. /// <summary>
  11894. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11895. /// </summary>
  11896. /// <param name="dto"></param>
  11897. /// <returns></returns>
  11898. [HttpPost]
  11899. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11900. {
  11901. var data = new Grp_DayOtherPriceDraft()
  11902. {
  11903. Id = dto.Id,
  11904. IsDel = 1,
  11905. DeleteUserId = dto.DeleteUserId,
  11906. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11907. };
  11908. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11909. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11910. return Ok(JsonView(false, "删除失败!"));
  11911. }
  11912. #endregion
  11913. #endregion
  11914. #region 团组经理模块 出入境费用报价表
  11915. /// <summary>
  11916. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11917. /// </summary>
  11918. /// <returns></returns>
  11919. [HttpPost]
  11920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11921. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11922. {
  11923. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11924. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11925. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11926. initRates.Insert(0, cnyInfo);
  11927. liveRates.Insert(0, cnyInfo);
  11928. return Ok(JsonView(true, "查询成功!", new
  11929. {
  11930. InitRates = initRates,
  11931. LiveRates = liveRates
  11932. }));
  11933. }
  11934. /// <summary>
  11935. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11936. /// </summary>
  11937. /// <returns></returns>
  11938. [HttpPost]
  11939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11940. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11941. {
  11942. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11943. }
  11944. /// <summary>
  11945. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11946. /// </summary>
  11947. /// <returns></returns>
  11948. [HttpPost]
  11949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11950. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11951. {
  11952. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11953. }
  11954. /// <summary>
  11955. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11956. /// </summary>
  11957. /// <returns></returns>
  11958. [HttpPost]
  11959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11960. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11961. {
  11962. int groupId = dto.DiId,
  11963. currUserId = dto.CurrUserId;
  11964. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11965. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11966. //验证报价数据是否存在
  11967. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11968. if (isNull != null)
  11969. {
  11970. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11971. if (!info1.Rates.Any())
  11972. {
  11973. var rates = await GeneralMethod.EnterExitCostInitRate();
  11974. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11975. info1.Rates = rates.ToArray();
  11976. }
  11977. return Ok(JsonView(info1));
  11978. }
  11979. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11980. result.GroupId = groupId;
  11981. //处理报价名称
  11982. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11983. if (groupInfo != null)
  11984. {
  11985. var visitCountry = groupInfo.VisitCountry;
  11986. if (!string.IsNullOrEmpty(visitCountry))
  11987. {
  11988. string quoteName = string.Empty;
  11989. if (visitCountry.Contains("|"))
  11990. {
  11991. var countrys = visitCountry.Split("|");
  11992. quoteName = string.Join("、", countrys);
  11993. }
  11994. else quoteName = visitCountry;
  11995. quoteName += $"团组报价表";
  11996. result.Name = quoteName;
  11997. }
  11998. }
  11999. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12000. if (info.Code != StatusCodes.Status200OK)
  12001. {
  12002. if (!result.Rates.Any())
  12003. {
  12004. var rates = await GeneralMethod.EnterExitCostInitRate();
  12005. result.Rates = rates.ToArray();
  12006. }
  12007. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12008. }
  12009. var infoView = info.Data as EnterExitCostInfoView;
  12010. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12011. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12012. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12013. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12014. var eecRates = infoView.Currencys;
  12015. //默认添加人名币
  12016. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12017. {
  12018. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12019. }
  12020. //处理团组人数
  12021. int pplNum = 1;
  12022. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12023. var views = new List<QuoteSubItemInfo>();
  12024. #region 数据填充
  12025. var intTravelCosts = new List<QuoteSubItemInfo>();
  12026. #region 机票费用 1354
  12027. int intTravelIndex = 1;
  12028. if (infoView.SumJJC == 1)
  12029. {
  12030. intTravelCosts.Add(new QuoteSubItemInfo
  12031. {
  12032. ItemId = 1354,
  12033. Index = intTravelIndex,
  12034. FeeName = "经济舱",
  12035. UnitPrice = infoView.AirJJ,
  12036. Currency = "CNY",
  12037. Quantity = 1,
  12038. PplNum = 1,
  12039. TotalAmt = infoView.AirJJ,
  12040. Remark = "",
  12041. });
  12042. intTravelIndex++;
  12043. }
  12044. if (infoView.SumGWC == 1)
  12045. {
  12046. intTravelCosts.Add(new QuoteSubItemInfo
  12047. {
  12048. ItemId = 1354,
  12049. Index = intTravelIndex,
  12050. FeeName = "公务舱",
  12051. UnitPrice = infoView.AirGW,
  12052. Currency = "CNY",
  12053. Quantity = 1,
  12054. PplNum = 1,
  12055. TotalAmt = infoView.AirGW,
  12056. Remark = "",
  12057. });
  12058. intTravelIndex++;
  12059. }
  12060. if (infoView.SumTDC == 1)
  12061. {
  12062. intTravelCosts.Add(new QuoteSubItemInfo
  12063. {
  12064. ItemId = 1354,
  12065. Index = intTravelIndex,
  12066. FeeName = "头等舱",
  12067. UnitPrice = infoView.AirTD,
  12068. Currency = "CNY",
  12069. Quantity = 1,
  12070. PplNum = 1,
  12071. TotalAmt = infoView.AirTD,
  12072. Remark = "",
  12073. });
  12074. intTravelIndex++;
  12075. }
  12076. intTravelCosts.Add(new QuoteSubItemInfo
  12077. {
  12078. ItemId = 1354,
  12079. Index = intTravelIndex,
  12080. FeeName = "城市间交通费用",
  12081. UnitPrice = infoView.CityTranffic,
  12082. Currency = "CNY",
  12083. Quantity = 1,
  12084. PplNum = pplNum,
  12085. TotalAmt = infoView.CityTranffic * pplNum,
  12086. Remark = "",
  12087. });
  12088. views.AddRange(intTravelCosts);
  12089. #endregion
  12090. var accomCosts = new List<QuoteSubItemInfo>();
  12091. #region 住宿费 1355
  12092. if (infoView.QuarterageData.Any())
  12093. {
  12094. int accomIndex = 1;
  12095. int accomItemTypeId = 1355;
  12096. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12097. foreach (var item in groupData)
  12098. {
  12099. string feeName = string.Empty;
  12100. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12101. if (countryInfo != null)
  12102. {
  12103. feeName = countryInfo.Country;
  12104. var city = countryInfo.City;
  12105. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12106. {
  12107. feeName += $"-{city}";
  12108. }
  12109. }
  12110. var hotelInfo = item.FirstOrDefault();
  12111. if (hotelInfo == null) continue;
  12112. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12113. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12114. int quantity = item.ToList().Count;
  12115. accomCosts.Add(new QuoteSubItemInfo
  12116. {
  12117. ItemId = accomItemTypeId,
  12118. Index = accomIndex,
  12119. FeeName = feeName,
  12120. UnitPrice = hotelInfo.Cost,
  12121. Currency = thisCurrency,
  12122. Quantity = quantity,
  12123. PplNum = pplNum,
  12124. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12125. Remark = "",
  12126. });
  12127. accomIndex++;
  12128. }
  12129. views.AddRange(accomCosts);
  12130. }
  12131. #endregion
  12132. var mealCosts = new List<QuoteSubItemInfo>();
  12133. #region 餐饮费 1356
  12134. if (infoView.BoardWagesData.Any())
  12135. {
  12136. var mealIndex = 1;
  12137. int mealItemTypeId = 1356;
  12138. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12139. foreach (var item in groupData)
  12140. {
  12141. string feeName = string.Empty;
  12142. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12143. if (countryInfo != null)
  12144. {
  12145. feeName = countryInfo.Country;
  12146. var city = countryInfo.City;
  12147. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12148. {
  12149. feeName += $"-{city}";
  12150. }
  12151. }
  12152. var mealInfo = item.FirstOrDefault();
  12153. if (mealInfo == null) continue;
  12154. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12155. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12156. int quantity = item.ToList().Count;
  12157. mealCosts.Add(new QuoteSubItemInfo
  12158. {
  12159. ItemId = mealItemTypeId,
  12160. Index = mealIndex,
  12161. FeeName = feeName,
  12162. UnitPrice = mealInfo.Cost,
  12163. Currency = thisCurrency,
  12164. Quantity = quantity,
  12165. PplNum = pplNum,
  12166. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12167. Remark = "",
  12168. });
  12169. mealIndex++;
  12170. }
  12171. views.AddRange(mealCosts);
  12172. }
  12173. #endregion
  12174. var miscCosts = new List<QuoteSubItemInfo>();
  12175. #region 公杂费 1364
  12176. if (infoView.MiscellaneousFeeData.Any())
  12177. {
  12178. var miscIndex = 1;
  12179. int miscItemTypeId = 1364;
  12180. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12181. foreach (var item in groupData)
  12182. {
  12183. string feeName = string.Empty;
  12184. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12185. if (countryInfo != null)
  12186. {
  12187. feeName = countryInfo.Country;
  12188. var city = countryInfo.City;
  12189. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12190. {
  12191. feeName += $"-{city}";
  12192. }
  12193. }
  12194. var miscInfo = item.FirstOrDefault();
  12195. if (miscInfo == null) continue;
  12196. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12197. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12198. int quantity = item.ToList().Count;
  12199. miscCosts.Add(new QuoteSubItemInfo
  12200. {
  12201. ItemId = miscItemTypeId,
  12202. Index = miscIndex,
  12203. FeeName = feeName,
  12204. UnitPrice = miscInfo.Cost,
  12205. Currency = thisCurrency,
  12206. Quantity = quantity,
  12207. PplNum = pplNum,
  12208. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12209. Remark = "",
  12210. });
  12211. miscIndex++;
  12212. }
  12213. views.AddRange(miscCosts);
  12214. }
  12215. #endregion
  12216. #region 签证+保险 1362
  12217. int visaInsIndex = 1;
  12218. int visaInsItemTypeId = 1362;
  12219. if (infoView.Visa > 0)
  12220. {
  12221. views.Add(new QuoteSubItemInfo()
  12222. {
  12223. ItemId = visaInsItemTypeId,
  12224. Index = visaInsIndex,
  12225. FeeName = $"签证",
  12226. UnitPrice = infoView.Visa,
  12227. Currency = $"CNY",
  12228. Quantity = 1,
  12229. PplNum = pplNum,
  12230. TotalAmt = infoView.Visa * pplNum,
  12231. Remark = "",
  12232. });
  12233. visaInsIndex++;
  12234. }
  12235. if (infoView.Safe > 0)
  12236. {
  12237. views.Add(new QuoteSubItemInfo()
  12238. {
  12239. ItemId = visaInsItemTypeId,
  12240. Index = visaInsIndex,
  12241. FeeName = $"保险",
  12242. UnitPrice = infoView.Safe,
  12243. Currency = $"CNY",
  12244. Quantity = 1,
  12245. PplNum = pplNum,
  12246. TotalAmt = infoView.Safe * pplNum,
  12247. Remark = "",
  12248. });
  12249. }
  12250. #endregion
  12251. #region 服务费 1363
  12252. int serviceFeeIndex = 1;
  12253. int serviceFeeItemTypeId = 1363;
  12254. if (infoView.Service > 0)
  12255. {
  12256. views.Add(new QuoteSubItemInfo()
  12257. {
  12258. ItemId = serviceFeeItemTypeId,
  12259. Index = serviceFeeIndex,
  12260. FeeName = $"服务费",
  12261. UnitPrice = infoView.Service,
  12262. Currency = $"CNY",
  12263. Quantity = 1,
  12264. PplNum = pplNum,
  12265. TotalAmt = infoView.Service * pplNum,
  12266. Remark = "",
  12267. });
  12268. }
  12269. #endregion
  12270. #endregion
  12271. if (result.FeeItems.Any())
  12272. {
  12273. result.FeeItems.Select(x =>
  12274. {
  12275. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12276. if (feeInfos.Any()) x.Infos = feeInfos;
  12277. return x;
  12278. }
  12279. ).OrderBy(x => x.Index)
  12280. .ToList();
  12281. if (!result.Rates.Any())
  12282. {
  12283. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12284. else
  12285. {
  12286. var rates = await GeneralMethod.EnterExitCostInitRate();
  12287. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12288. result.Rates = rates.ToArray();
  12289. }
  12290. }
  12291. }
  12292. return Ok(JsonView(result));
  12293. }
  12294. /// <summary>
  12295. /// 团组模块 - 出入境费用报价表 - Info
  12296. /// </summary>
  12297. /// <returns></returns>
  12298. [HttpPost]
  12299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12300. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12301. {
  12302. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12303. if (!info.Rates.Any())
  12304. {
  12305. var rates = await GeneralMethod.EnterExitCostInitRate();
  12306. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12307. info.Rates = rates.ToArray();
  12308. }
  12309. return Ok(JsonView(info));
  12310. }
  12311. /// <summary>
  12312. /// 团组模块 - 出入境费用报价表 - OP
  12313. /// </summary>
  12314. /// <returns></returns>
  12315. [HttpPost]
  12316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12317. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12318. {
  12319. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12320. }
  12321. /// <summary>
  12322. /// 团组模块 - 出入境费用报价表 - 删除 项
  12323. /// </summary>
  12324. /// <returns></returns>
  12325. [HttpPost]
  12326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12327. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12328. {
  12329. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12330. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12331. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12332. }
  12333. /// <summary>
  12334. /// 团组模块 - 出入境费用报价表 - 导出
  12335. /// </summary>
  12336. /// <returns></returns>
  12337. [HttpPost]
  12338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12339. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12340. {
  12341. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12342. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12343. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12344. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12345. var rates = info.Rates;
  12346. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12347. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12348. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12349. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12350. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12351. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12352. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12353. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12354. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12355. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12356. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12357. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12358. //获取模板
  12359. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12360. var designer = new WorkbookDesigner();
  12361. designer.Workbook = new Workbook(tempPath);
  12362. designer.SetDataSource("QuoteName", info.Name);
  12363. designer.SetDataSource("CompanyTitle", "公司名称");
  12364. designer.SetDataSource("CompanyLabel", "");
  12365. #region 国际旅费
  12366. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12367. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12368. {
  12369. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12370. var label = new StringBuilder();
  12371. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12372. if (infos.Any())
  12373. {
  12374. label.Append(infos.Sum(x => x.PplNum));
  12375. label.Append("人全程机票:");
  12376. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12377. label.AppendLine("元");
  12378. }
  12379. foreach (var item in intTravelCosts.Infos)
  12380. {
  12381. label.Append(item.FeeName);
  12382. label.Append(":");
  12383. label.Append(item.UnitPrice.TruncDecimals(2));
  12384. label.Append("元/人*");
  12385. label.Append(item.PplNum);
  12386. label.AppendLine("人");
  12387. }
  12388. if (label.HasValue())
  12389. {
  12390. label.Append("\r\n以上小计:");
  12391. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12392. label.Append("元");
  12393. }
  12394. designer.SetDataSource("IntTravelLabel", label.ToString());
  12395. }
  12396. #endregion
  12397. #region 住宿费
  12398. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12399. if (accomCosts != null && accomCosts.Infos.Any())
  12400. {
  12401. string currencyName = string.Empty,
  12402. countryName = string.Empty;
  12403. decimal rate = 1.0000M;
  12404. var label = new StringBuilder();
  12405. label.AppendLine("全程五星酒店,每人1间房");
  12406. foreach (var item in accomCosts.Infos)
  12407. {
  12408. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12409. string name = string.Empty, thisCountryName = string.Empty;
  12410. if (item.FeeName.Contains('-'))
  12411. {
  12412. var feeName = item.FeeName.Split('-');
  12413. thisCountryName = feeName[0];
  12414. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12415. name = feeName[1];
  12416. }
  12417. else name = item.FeeName;
  12418. string thisFeeName = string.Empty;
  12419. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12420. else thisFeeName = $"\r\n{name}:";
  12421. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12422. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12423. rate = rateInfo?.Rate ?? 1.0000M;
  12424. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12425. label.AppendLine(subLabel);
  12426. }
  12427. if (label.HasValue())
  12428. {
  12429. //以上小计:52440元(美金汇率:7.5 )
  12430. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12431. label.AppendLine(subLabel);
  12432. }
  12433. designer.SetDataSource("AccomLabel", label.ToString());
  12434. }
  12435. #endregion
  12436. #region 餐饮费
  12437. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12438. if (mealCosts != null && mealCosts.Infos.Any())
  12439. {
  12440. string currencyName = string.Empty;
  12441. decimal rate = 1.0000M;
  12442. var label = new StringBuilder();
  12443. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12444. foreach (var item in mealCosts.Infos)
  12445. {
  12446. string name = string.Empty;
  12447. if (item.FeeName.Contains('-'))
  12448. {
  12449. var feeName = item.FeeName.Split('-');
  12450. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12451. }
  12452. else name = $"\r\n{item.FeeName}:";
  12453. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12454. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12455. rate = rateInfo?.Rate ?? 1.0000M;
  12456. label.Append(name);
  12457. label.Append(item.UnitPrice.TruncDecimals(2));
  12458. label.Append(currencyName);
  12459. label.Append("/天*");
  12460. label.Append(item.Quantity.ToString("#0"));
  12461. label.Append('*');
  12462. label.Append(item.PplNum);
  12463. label.Append("人\r\n");
  12464. }
  12465. if (label.HasValue())
  12466. {
  12467. label.Append("\r\n以上小计:");
  12468. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12469. label.Append("元\r\n(");
  12470. label.Append("汇率:");
  12471. label.Append(rate.TruncDecimals(4));
  12472. label.Append(')');
  12473. }
  12474. designer.SetDataSource("MealLabel", label.ToString());
  12475. }
  12476. #endregion
  12477. #region 车辆安排
  12478. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12479. if (vehArranges != null && vehArranges.Infos.Any())
  12480. {
  12481. string currencyName = string.Empty;
  12482. //decimal rate = 1.0000M;
  12483. var label = new StringBuilder();
  12484. foreach (var item in vehArranges.Infos)
  12485. {
  12486. label.AppendLine();
  12487. label.AppendLine();
  12488. label.Append(item.FeeName);
  12489. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12490. }
  12491. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12492. }
  12493. #endregion
  12494. #region 邀请函发放对象
  12495. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12496. designer.SetDataSource("InviteToContent", "");
  12497. #endregion
  12498. #region 邀请函费
  12499. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12500. var is_label = new StringBuilder();
  12501. if (inviteCosts != null && inviteCosts.Infos.Any())
  12502. {
  12503. string currencyName = string.Empty;
  12504. decimal rate = 1.0000M;
  12505. foreach (var item in inviteCosts.Infos)
  12506. {
  12507. //乌兹别克斯坦:2000美金
  12508. currencyName = item.Currency;
  12509. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12510. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12511. is_label.AppendLine(label);
  12512. }
  12513. if (is_label.HasValue())
  12514. {
  12515. //以上小计:28500元(美金汇率:7.5)
  12516. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12517. is_label.AppendLine(label);
  12518. }
  12519. }
  12520. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12521. #endregion
  12522. #region 邀请函发放时间
  12523. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12524. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12525. #endregion
  12526. #region 公务活动(含翻译)
  12527. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12528. var oa_label = new StringBuilder();
  12529. if (officialActs != null && officialActs.Infos.Any())
  12530. {
  12531. string currencyName = string.Empty;
  12532. decimal rate = 1.0000M;
  12533. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12534. foreach (var item in officialActs.Infos)
  12535. {
  12536. //乌兹别克斯坦:1000美金/场
  12537. currencyName = item.Currency;
  12538. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12539. string label_remark = string.Empty;
  12540. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12541. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12542. }
  12543. label_content += "*总费用中未含超出公务活动价格";
  12544. //8场公务活动(以上小计:60000元)
  12545. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12546. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12547. oa_label.AppendLine(label_title);
  12548. oa_label.AppendLine(label_content);
  12549. }
  12550. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12551. #endregion
  12552. #region 签证+保险
  12553. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12554. var vi_label = new StringBuilder();
  12555. if (visaIns != null && visaIns.Infos.Any())
  12556. {
  12557. foreach (var item in visaIns.Infos)
  12558. {
  12559. //签证:500元/人
  12560. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12561. vi_label.AppendLine(label);
  12562. }
  12563. if (vi_label.HasValue())
  12564. {
  12565. //以上小计:6000元
  12566. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12567. vi_label.AppendLine(label);
  12568. }
  12569. }
  12570. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12571. #endregion
  12572. #region 服务费
  12573. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12574. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12575. #endregion
  12576. #region 公杂费
  12577. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12578. var pm_label = new StringBuilder();
  12579. if (pubMiscs != null && pubMiscs.Infos.Any())
  12580. {
  12581. string currencyName = string.Empty,
  12582. countryName = string.Empty;
  12583. decimal rate = 1.0000M;
  12584. foreach (var item in pubMiscs.Infos)
  12585. {
  12586. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12587. string name = string.Empty, thisCountryName = string.Empty;
  12588. if (item.FeeName.Contains('-'))
  12589. {
  12590. var feeName = item.FeeName.Split('-');
  12591. thisCountryName = feeName[0];
  12592. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12593. name = feeName[1];
  12594. }
  12595. else name = item.FeeName;
  12596. string thisFeeName = string.Empty;
  12597. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12598. else thisFeeName = $"\r\n{name}:";
  12599. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12600. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12601. rate = rateInfo?.Rate ?? 1.0000M;
  12602. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12603. pm_label.AppendLine(label);
  12604. }
  12605. if (pm_label.HasValue())
  12606. {
  12607. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12608. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12609. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12610. pm_label.AppendLine(string.Format("部分发放成员"));
  12611. }
  12612. }
  12613. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12614. #endregion
  12615. #region 税费
  12616. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12617. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12618. #endregion
  12619. #region 合计(单位:元)
  12620. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12621. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12622. #endregion
  12623. #region 汇率 Remark
  12624. var rate_label = new StringBuilder();
  12625. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12626. foreach (var item in rateGroups)
  12627. {
  12628. //美元汇率按\r\n1:7.5
  12629. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12630. rate_label.AppendLine(label);
  12631. }
  12632. designer.SetDataSource("RateLabel", rate_label.ToString());
  12633. #endregion
  12634. designer.Process();
  12635. //文件名
  12636. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12637. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12638. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12639. return Ok(JsonView(true, "成功", url));
  12640. }
  12641. #endregion
  12642. #region 签证费用录入
  12643. /// <summary>
  12644. /// 根据diid查询签证费用列表
  12645. /// </summary>
  12646. /// <param name="dto"></param>
  12647. /// <returns></returns>
  12648. [HttpPost]
  12649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12650. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12651. {
  12652. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12653. if (groupData.Code != 0)
  12654. {
  12655. return Ok(JsonView(false, groupData.Msg));
  12656. }
  12657. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12658. }
  12659. /// <summary>
  12660. /// 根据签证费用Id查询单条数据及c表数据
  12661. /// </summary>
  12662. /// <param name="dto"></param>
  12663. /// <returns></returns>
  12664. [HttpPost]
  12665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12666. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12667. {
  12668. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12669. if (groupData.Code != 0)
  12670. {
  12671. return Ok(JsonView(false, groupData.Msg));
  12672. }
  12673. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12674. }
  12675. /// <summary>
  12676. /// 签证费用删除
  12677. /// </summary>
  12678. /// <param name="dto"></param>
  12679. /// <returns></returns>
  12680. [HttpPost]
  12681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12682. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12683. {
  12684. _sqlSugar.BeginTran();
  12685. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12686. if (!res)
  12687. {
  12688. _sqlSugar.RollbackTran();
  12689. return Ok(JsonView(false, "删除失败"));
  12690. }
  12691. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12692. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12693. .SetColumns(a => new Grp_CreditCardPayment()
  12694. {
  12695. IsDel = 1,
  12696. DeleteUserId = dto.DeleteUserId,
  12697. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12698. })
  12699. .ExecuteCommand();
  12700. if (resSub < 1)
  12701. {
  12702. _sqlSugar.RollbackTran();
  12703. return Ok(JsonView(false, "删除失败"));
  12704. }
  12705. _sqlSugar.CommitTran();
  12706. return Ok(JsonView(true, "删除成功!"));
  12707. }
  12708. /// <summary>
  12709. /// 签证费用录入下拉框初始化
  12710. /// </summary>
  12711. /// <returns></returns>
  12712. [HttpPost]
  12713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12714. public async Task<IActionResult> VisaPriceAddSelect()
  12715. {
  12716. //支付方式
  12717. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12718. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12719. //币种
  12720. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12721. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12722. //乘客类型
  12723. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12724. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12725. //卡类型
  12726. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12727. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12728. //代办费类型
  12729. var agencyFeeTypeData = new List<dynamic>() {
  12730. new { id = 0 , Text = "未选择" },
  12731. new { id = 1 , Text = "小公务" },
  12732. new { id = 2 , Text = "大公务" },
  12733. };
  12734. //签证费用标准国家Data
  12735. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12736. var data = new
  12737. {
  12738. Payment = _Payment,
  12739. CurrencyList = _CurrencyList,
  12740. PassengerType = _PassengerType,
  12741. BankCard = _BankCard,
  12742. AgencyFeeType = agencyFeeTypeData,
  12743. CountryFeeData = visaCountryFeeData
  12744. };
  12745. return Ok(JsonView(true, "查询成功!", data));
  12746. }
  12747. /// <summary>
  12748. /// 签证费用录入操作(Status:1.新增,2.修改)
  12749. /// </summary>
  12750. /// <param name="dto"></param>
  12751. /// <returns></returns>
  12752. [HttpPost]
  12753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12754. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12755. {
  12756. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12757. if (groupData.Code != 0)
  12758. {
  12759. return Ok(JsonView(false, groupData.Msg));
  12760. }
  12761. #region 应用推送
  12762. try
  12763. {
  12764. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12765. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12766. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12767. //2024-10-21 新增LZ UID
  12768. var userIds = new List<int>() { 21 };
  12769. string title = $"系统通知";
  12770. string content = "";
  12771. var diId = dto.DiId;
  12772. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12773. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12774. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12775. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12776. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12777. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12778. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12779. }
  12780. catch (Exception ex)
  12781. {
  12782. }
  12783. #endregion
  12784. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12785. }
  12786. #endregion
  12787. #region 签证提成录入
  12788. /// <summary>
  12789. /// 签证提成录入
  12790. /// 基础数据
  12791. /// </summary>
  12792. /// <returns></returns>
  12793. [HttpGet]
  12794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12795. public async Task<IActionResult> VisaCommissionInit()
  12796. {
  12797. return Ok(await _visaCommissionRep.Init());
  12798. }
  12799. /// <summary>
  12800. /// 签证提成录入
  12801. /// Item
  12802. /// </summary>
  12803. /// <param name="_dto"></param>
  12804. /// <returns></returns>
  12805. [HttpPost]
  12806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12807. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12808. {
  12809. var validator = new VisaCommissionItemDtoValidator();
  12810. var validatorRes = await validator.ValidateAsync(_dto);
  12811. if (!validatorRes.IsValid)
  12812. {
  12813. var sb = new StringBuilder();
  12814. foreach (var item in validatorRes.Errors)
  12815. {
  12816. sb.AppendLine(item.ErrorMessage);
  12817. }
  12818. return Ok(JsonView(false, sb.ToString()));
  12819. }
  12820. return Ok(await _visaCommissionRep.Item(_dto));
  12821. }
  12822. /// <summary>
  12823. /// 签证提成录入
  12824. /// Save
  12825. /// </summary>
  12826. /// <param name="_dto"></param>
  12827. /// <returns></returns>
  12828. [HttpPost]
  12829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12830. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12831. {
  12832. //参数验证
  12833. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12834. foreach (var item in _dto.Items)
  12835. {
  12836. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12837. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12838. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12839. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12840. }
  12841. return Ok(await _visaCommissionRep.Save(_dto));
  12842. }
  12843. /// <summary>
  12844. /// 签证提成录入
  12845. /// Create
  12846. /// </summary>
  12847. /// <param name="_dto"></param>
  12848. /// <returns></returns>
  12849. [HttpPost]
  12850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12851. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12852. {
  12853. var validator = new VisaCommissionCreateDtoValidator();
  12854. var validatorRes = await validator.ValidateAsync(_dto);
  12855. if (!validatorRes.IsValid)
  12856. {
  12857. var sb = new StringBuilder();
  12858. foreach (var item in validatorRes.Errors)
  12859. {
  12860. sb.AppendLine(item.ErrorMessage);
  12861. }
  12862. return Ok(JsonView(false, sb.ToString()));
  12863. }
  12864. return Ok(await _visaCommissionRep.Create(_dto));
  12865. }
  12866. /// <summary>
  12867. /// 签证提成录入
  12868. /// Put(编辑)
  12869. /// </summary>
  12870. /// <param name="id"></param>
  12871. /// <param name="_dto"></param>
  12872. /// <returns></returns>
  12873. [HttpPut]
  12874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12875. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12876. {
  12877. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12878. var validator = new VisaCommissionCreateDtoValidator();
  12879. var validatorRes = await validator.ValidateAsync(_dto);
  12880. if (!validatorRes.IsValid)
  12881. {
  12882. var sb = new StringBuilder();
  12883. foreach (var item in validatorRes.Errors)
  12884. {
  12885. sb.AppendLine(item.ErrorMessage);
  12886. }
  12887. return Ok(JsonView(false, sb.ToString()));
  12888. }
  12889. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12890. }
  12891. /// <summary>
  12892. /// 签证提成录入
  12893. /// Del
  12894. /// </summary>
  12895. /// <param name="id"></param>
  12896. /// <param name="currUserId"></param>
  12897. /// <returns></returns>
  12898. [HttpPost]
  12899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12900. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12901. {
  12902. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12903. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12904. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12905. }
  12906. #endregion
  12907. #region op费用录入
  12908. /// <summary>
  12909. /// 根据diid查询op费用列表
  12910. /// </summary>
  12911. /// <param name="dto"></param>
  12912. /// <returns></returns>
  12913. [HttpPost]
  12914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12915. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12916. {
  12917. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12918. if (groupData.Code != 0)
  12919. {
  12920. return Ok(JsonView(false, groupData.Msg));
  12921. }
  12922. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12923. }
  12924. /// <summary>
  12925. /// 根据op费用Id查询单条数据及c表数据
  12926. /// </summary>
  12927. /// <param name="dto"></param>
  12928. /// <returns></returns>
  12929. [HttpPost]
  12930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12931. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12932. {
  12933. try
  12934. {
  12935. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12936. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12937. var data = new
  12938. {
  12939. CarTouristGuideGround = _groupData,
  12940. CreditCardPayment = _creditCardPayment
  12941. };
  12942. return Ok(JsonView(true, "查询成功!", data));
  12943. }
  12944. catch (Exception ex)
  12945. {
  12946. return Ok(JsonView(false, "程序错误!"));
  12947. }
  12948. }
  12949. /// <summary>
  12950. /// op费用删除
  12951. /// </summary>
  12952. /// <param name="dto"></param>
  12953. /// <returns></returns>
  12954. [HttpPost]
  12955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12956. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12957. {
  12958. try
  12959. {
  12960. _sqlSugar.BeginTran();
  12961. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12962. if (!res)
  12963. {
  12964. return Ok(JsonView(false, "删除失败"));
  12965. }
  12966. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12967. {
  12968. IsDel = 1,
  12969. DeleteUserId = dto.DeleteUserId,
  12970. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12971. }).ExecuteCommandAsync();
  12972. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12973. {
  12974. IsDel = 1,
  12975. DeleteUserId = dto.DeleteUserId,
  12976. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12977. }).ExecuteCommandAsync();
  12978. #region 删除超支相关数据
  12979. //删除导入的超支数据
  12980. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12981. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12982. {
  12983. IsDel = 1,
  12984. DeleteUserId = dto.DeleteUserId,
  12985. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12986. }).ExecuteCommand();
  12987. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12988. {
  12989. IsDel = 1,
  12990. DeleteUserId = dto.DeleteUserId,
  12991. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12992. }).ExecuteCommand();
  12993. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12994. {
  12995. IsDel = 1,
  12996. DeleteUserId = dto.DeleteUserId,
  12997. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12998. }).ExecuteCommand();
  12999. #endregion
  13000. _sqlSugar.CommitTran();
  13001. return Ok(JsonView(true, "删除成功!"));
  13002. }
  13003. catch (Exception ex)
  13004. {
  13005. _sqlSugar.RollbackTran();
  13006. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13007. }
  13008. }
  13009. /// <summary>
  13010. /// op费用录入操作(Status:1.新增,2.修改)
  13011. /// </summary>
  13012. /// <param name="dto"></param>
  13013. /// <returns></returns>
  13014. [HttpPost]
  13015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13016. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13017. {
  13018. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13019. if (groupData.Code != 0)
  13020. {
  13021. return Ok(JsonView(false, groupData.Msg));
  13022. }
  13023. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13024. }
  13025. /// <summary>
  13026. /// 填写费用详细页面初始化绑定
  13027. /// </summary>
  13028. /// <param name="dto"></param>
  13029. /// <returns></returns>
  13030. [HttpPost]
  13031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13032. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13033. {
  13034. try
  13035. {
  13036. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13037. if (groupData.Code != 0)
  13038. {
  13039. return Ok(JsonView(false, groupData.Msg));
  13040. }
  13041. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13042. }
  13043. catch (Exception ex)
  13044. {
  13045. return Ok(JsonView(false, ex.Message));
  13046. }
  13047. }
  13048. /// <summary>
  13049. /// 根据op费用Id查询详细数据
  13050. /// </summary>
  13051. /// <param name="dto"></param>
  13052. /// <returns></returns>
  13053. [HttpPost]
  13054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13055. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13056. {
  13057. try
  13058. {
  13059. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13060. if (groupData.Code != 0)
  13061. {
  13062. return Ok(JsonView(false, groupData.Msg));
  13063. }
  13064. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13065. }
  13066. catch (Exception ex)
  13067. {
  13068. return Ok(JsonView(false, ex.Message));
  13069. }
  13070. }
  13071. /// <summary>
  13072. /// OP费用录入填写详情
  13073. /// </summary>
  13074. /// <param name="dto"></param>
  13075. /// <returns></returns>
  13076. [HttpPost]
  13077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13078. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13079. {
  13080. try
  13081. {
  13082. #region 参数校验
  13083. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13084. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13085. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13086. #endregion
  13087. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13088. if (groupData.Code != 0)
  13089. {
  13090. return Ok(JsonView(false, groupData.Msg));
  13091. }
  13092. //自动审核
  13093. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13094. #region 应用推送
  13095. try
  13096. {
  13097. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13098. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13099. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13100. //2024-10-21 新增LZ UID
  13101. var userIds = new List<int>() { 21 };
  13102. string title = $"系统通知";
  13103. var diId = dto.DiId;
  13104. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13105. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13106. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13107. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13108. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13109. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13110. }
  13111. catch (Exception ex)
  13112. {
  13113. }
  13114. #endregion
  13115. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13116. }
  13117. catch (Exception ex)
  13118. {
  13119. return Ok(JsonView(false, ex.Message));
  13120. }
  13121. }
  13122. /// <summary>
  13123. /// 获取三公详细所有城市
  13124. /// </summary>
  13125. /// <returns></returns>
  13126. [HttpGet]
  13127. public IActionResult OpCarCityResult()
  13128. {
  13129. var jw = JsonView(false);
  13130. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13131. {
  13132. x.Id,
  13133. x.Country,
  13134. x.City,
  13135. }).ToList();
  13136. if (data.Count > 0)
  13137. {
  13138. jw = JsonView(true, "获取成功!", data);
  13139. }
  13140. else
  13141. {
  13142. jw.Msg = "城市数据为空!";
  13143. jw.Data = Array.Empty<string>();
  13144. }
  13145. return Ok(jw);
  13146. }
  13147. /// <summary>
  13148. /// 导出地接费用明细
  13149. /// </summary>
  13150. /// <param name="dto"></param>
  13151. /// <returns></returns>
  13152. [HttpPost]
  13153. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13154. {
  13155. var jw = JsonView(false);
  13156. if (dto.Diid < 1)
  13157. {
  13158. jw.Msg = "请输入正确的diid!";
  13159. return Ok(jw);
  13160. }
  13161. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13162. if (group == null)
  13163. {
  13164. jw.Msg = "未找到团组信息!";
  13165. return Ok(jw);
  13166. }
  13167. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13168. if (localGuideArr.Count == 0)
  13169. {
  13170. jw.Msg = "该团组暂无地接信息!";
  13171. return Ok(jw);
  13172. }
  13173. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13174. var overspendSoure = new Dictionary<int, int>
  13175. {
  13176. { 91, 982 }, //车
  13177. { 92 , 1059} ,//导游
  13178. { 994 , 1073}, //翻译
  13179. { 988 , 1074 }, //早餐
  13180. { 93 , 1075 }, //午餐
  13181. { 989 , 1076 }, //晚餐
  13182. };
  13183. var Zips = new Dictionary<string, Stream>();
  13184. foreach (var groupArr in localGroup)
  13185. {
  13186. var keyValue = groupArr.Key;
  13187. if (int.TryParse(keyValue, out int cityid))
  13188. {
  13189. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13190. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13191. }
  13192. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13193. foreach (var item in groupArr)
  13194. {
  13195. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13196. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13197. new Grp_CarTouristGuideGroundReservationsContentExtend
  13198. {
  13199. Count = a.Count,
  13200. CreateTime = a.CreateTime,
  13201. CreateUserId = a.CreateUserId,
  13202. CTGGRId = a.CTGGRId,
  13203. Currency = a.Currency,
  13204. DatePrice = a.DatePrice,
  13205. DeleteTime = a.DeleteTime,
  13206. DeleteUserId = a.DeleteUserId,
  13207. DiId = a.DiId,
  13208. Id = a.Id,
  13209. IsDel = a.IsDel,
  13210. Price = a.Price,
  13211. PriceContent = a.PriceContent,
  13212. Remark = a.Remark,
  13213. SId = a.SId,
  13214. SidName = b.Name,
  13215. Units = a.Units,
  13216. }
  13217. ).ToList();
  13218. if (content.Count > 0)
  13219. {
  13220. contentArr.Add(content);
  13221. }
  13222. }
  13223. //open excel
  13224. //set excel
  13225. //save excel
  13226. try
  13227. {
  13228. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13229. IWorkbook workbook;
  13230. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13231. {
  13232. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13233. }
  13234. else
  13235. {
  13236. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13237. }
  13238. ISheet sheet = workbook.GetSheetAt(0);
  13239. var rowStartIndex = 2;
  13240. var clounmCount = 10;
  13241. var initStyleRow = sheet.GetRow(2);
  13242. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13243. //var overspendArrDetail =
  13244. var existsId = new List<CarCompare>();
  13245. var lastElem = arr.Last();
  13246. var thisSid = -1;
  13247. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13248. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13249. {
  13250. Name = "未知币种!",
  13251. Remark = "未知币种!",
  13252. };
  13253. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13254. Action cloneRowFn = () =>
  13255. {
  13256. rowStartIndex++;
  13257. var cloneRow = sheet.CreateRow(rowStartIndex);
  13258. // 复制样式
  13259. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13260. {
  13261. ICell sourceCell = initStyleRow.GetCell(i);
  13262. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13263. // 确保单元格存在样式
  13264. if (sourceCell.CellStyle != null)
  13265. {
  13266. targetCell.CellStyle = sourceCell.CellStyle;
  13267. }
  13268. }
  13269. };
  13270. var mergeRow = () =>
  13271. {
  13272. for (int i = 2; i < sheet.LastRowNum; i++)
  13273. {
  13274. var row = sheet.GetRow(i);
  13275. var cellFirst = row.GetCell(0);
  13276. var thisIndex = i + 1;
  13277. while (thisIndex < sheet.LastRowNum)
  13278. {
  13279. var nextRow = sheet.GetRow(thisIndex);
  13280. var nextCellFirst = nextRow.GetCell(0);
  13281. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13282. {
  13283. thisIndex++;
  13284. }
  13285. else
  13286. {
  13287. break;
  13288. }
  13289. }
  13290. thisIndex--;
  13291. if (thisIndex != i)
  13292. {
  13293. //合并row
  13294. var cellRangeAddress = new CellRangeAddress(
  13295. i, // 起始行索引(0-based)
  13296. thisIndex, // 结束行索引(0-based)
  13297. 0, // 起始列索引(0-based)
  13298. 0 // 结束列索引(0-based)
  13299. );
  13300. sheet.AddMergedRegion(cellRangeAddress);
  13301. i = thisIndex;
  13302. }
  13303. }
  13304. };
  13305. var chaoshiNumber = 0;
  13306. var totalNumber = 0.00M;
  13307. string lastStr = "";
  13308. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13309. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13310. {
  13311. b.IsAuditGM,
  13312. x.Id,
  13313. x.Area,
  13314. b.PayPercentage,
  13315. b.PayMoney,
  13316. }).ToList();
  13317. string yesPayment = "", noPayment = "";
  13318. foreach (var item in queryCarArrByCityAndDiid)
  13319. {
  13320. if (item.IsAuditGM == 1)
  13321. {
  13322. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13323. }
  13324. else
  13325. {
  13326. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13327. }
  13328. }
  13329. lastStr = yesPayment + noPayment;
  13330. foreach (var item in arr)
  13331. {
  13332. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13333. {
  13334. if (thisSid != item.SId)
  13335. {
  13336. if (thisSid == -1)
  13337. {
  13338. thisSid = item.SId;
  13339. }
  13340. else
  13341. {
  13342. //合并小计行
  13343. //创建合并区域的实例
  13344. var cellRangeAddress = new CellRangeAddress(
  13345. rowStartIndex, // 起始行索引(0-based)
  13346. rowStartIndex, // 结束行索引(0-based)
  13347. 0, // 起始列索引(0-based)
  13348. 3 // 结束列索引(0-based)
  13349. );
  13350. sheet.AddMergedRegion(cellRangeAddress);
  13351. var CellStyle = workbook.CreateCellStyle();
  13352. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13353. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13354. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13355. for (int i = 0; i <= clounmCount; i++)
  13356. {
  13357. if (i > 6)
  13358. {
  13359. var CellStyle1 = workbook.CreateCellStyle();
  13360. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13361. IFont Font = workbook.CreateFont(); // 创建字体
  13362. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13363. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13364. CellStyle1.SetFont(Font);
  13365. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13366. }
  13367. else
  13368. {
  13369. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13370. }
  13371. }
  13372. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13373. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13374. //超时合计
  13375. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13376. //超时数
  13377. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13378. //超时合计费用
  13379. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13380. thisSid = item.SId;
  13381. cloneRowFn();
  13382. chaoshiNumber = 0;
  13383. totalNumber = 0;
  13384. }
  13385. }
  13386. IRow row = sheet.GetRow(rowStartIndex);
  13387. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13388. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13389. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13390. if (isOpenOverspendSoure)
  13391. {
  13392. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13393. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13394. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13395. }
  13396. for (int i = 0; i <= clounmCount; i++)
  13397. {
  13398. var cell = row.GetCell(i);
  13399. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13400. if (cell == null)
  13401. {
  13402. cell = row.CreateCell(i);
  13403. }
  13404. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13405. fontRed.CloneStyleFrom(cell.CellStyle);
  13406. IFont Font = workbook.CreateFont(); // 创建字体
  13407. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13408. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13409. fontRed.SetFont(Font);
  13410. byte[] rgb = new byte[3] { 255, 242, 204 };
  13411. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13412. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13413. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13414. if (workbook is XSSFWorkbook)
  13415. {
  13416. BackgroundColor255_242_204.FillForegroundColor = 0;
  13417. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13418. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13419. }
  13420. else
  13421. {
  13422. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13423. }
  13424. if (i == 1 || i > 6)
  13425. {
  13426. if (i > 6)
  13427. {
  13428. fontRed.FillForegroundColor = 0;
  13429. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13430. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13431. }
  13432. cell.CellStyle = fontRed;
  13433. }
  13434. if (i > 2 && i < 7)
  13435. {
  13436. cell.CellStyle = BackgroundColor255_242_204;
  13437. }
  13438. cell.SetCellValue(setCellValue); //写入单元格
  13439. }
  13440. if (overspendSoure.ContainsKey(thisSid))
  13441. {
  13442. var overspendId = overspendSoure[thisSid];
  13443. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13444. }
  13445. cloneRowFn();
  13446. existsId.Add(new CarCompare
  13447. {
  13448. DataPrice = item.DatePrice.ObjToDate(),
  13449. Sid = item.SId
  13450. });
  13451. }
  13452. if (item.Equals(lastElem))
  13453. {
  13454. //合并小计行
  13455. //创建合并区域的实例
  13456. var cellRangeAddress = new CellRangeAddress(
  13457. rowStartIndex, // 起始行索引(0-based)
  13458. rowStartIndex, // 结束行索引(0-based)
  13459. 0, // 起始列索引(0-based)
  13460. 3 // 结束列索引(0-based)
  13461. );
  13462. sheet.AddMergedRegion(cellRangeAddress);
  13463. var CellStyle = workbook.CreateCellStyle();
  13464. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13465. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13466. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13467. for (int i = 0; i <= clounmCount; i++)
  13468. {
  13469. if (i > 6)
  13470. {
  13471. var CellStyle1 = workbook.CreateCellStyle();
  13472. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13473. IFont Font = workbook.CreateFont(); // 创建字体
  13474. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13475. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13476. CellStyle1.SetFont(Font);
  13477. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13478. }
  13479. else
  13480. {
  13481. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13482. }
  13483. }
  13484. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13485. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13486. //超时合计
  13487. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13488. //超时数
  13489. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13490. //超时合计费用
  13491. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13492. cloneRowFn();
  13493. // 创建合并区域的实例
  13494. cellRangeAddress = new CellRangeAddress(
  13495. rowStartIndex, // 起始行索引(0-based)
  13496. rowStartIndex, // 结束行索引(0-based)
  13497. 0, // 起始列索引(0-based)
  13498. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13499. );
  13500. // 添加合并区域
  13501. sheet.AddMergedRegion(cellRangeAddress);
  13502. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13503. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13504. }
  13505. }
  13506. mergeRow();
  13507. // 保存修改后的Excel文件到新文件
  13508. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13509. // new FileStream(newFilePath, FileMode.CreateNew)
  13510. using (var stream = new MemoryStream())
  13511. {
  13512. workbook.Write(stream, true);
  13513. stream.Flush();
  13514. stream.Seek(0, SeekOrigin.Begin);
  13515. var memoryStream = new MemoryStream();
  13516. stream.CopyTo(memoryStream);
  13517. memoryStream.Seek(0, SeekOrigin.Begin);
  13518. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13519. }
  13520. workbook.Close();
  13521. workbook.Dispose();
  13522. }
  13523. catch (Exception ex)
  13524. {
  13525. jw.Msg = "出现异常!" + ex.Message;
  13526. return Ok(jw);
  13527. }
  13528. }
  13529. if (Zips.Count > 0)
  13530. {
  13531. var io = new IOOperatorHelper();
  13532. var byts = io.ConvertZipStream(Zips);
  13533. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13534. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13535. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13536. }
  13537. else
  13538. {
  13539. jw.Msg = "暂无生成文件!";
  13540. }
  13541. return Ok(jw);
  13542. }
  13543. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13544. {
  13545. string outStr = string.Empty;
  13546. switch (i)
  13547. {
  13548. case 0:
  13549. outStr = arr[0].SidName;
  13550. break;
  13551. case 1:
  13552. outStr = arr[0].DataPriceStr;
  13553. break;
  13554. case 2:
  13555. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13556. break;
  13557. case 4:
  13558. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13559. break;
  13560. case 7:
  13561. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13562. {
  13563. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13564. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13565. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13566. }
  13567. break;
  13568. case 8:
  13569. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13570. {
  13571. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13572. }
  13573. break;
  13574. case 9:
  13575. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13576. {
  13577. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13578. }
  13579. break;
  13580. case 10:
  13581. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13582. {
  13583. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13584. }
  13585. break;
  13586. }
  13587. return outStr;
  13588. }
  13589. #region OP行程单
  13590. /// <summary>
  13591. /// OP行程单初始化
  13592. /// </summary>
  13593. /// <param name="dto"></param>
  13594. /// <returns></returns>
  13595. [HttpPost]
  13596. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13597. {
  13598. var jw = JsonView(false);
  13599. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13600. var group = groupList.First();
  13601. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13602. if (group == null)
  13603. {
  13604. jw.Msg = "暂无团组!";
  13605. return Ok(jw);
  13606. }
  13607. group = groupList.Find(x => x.Id == diid);
  13608. if (group == null)
  13609. {
  13610. jw.Msg = "请输入正确的团组ID!";
  13611. return Ok(jw);
  13612. }
  13613. string city = string.Empty;
  13614. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13615. if (blackCode.Count > 0)
  13616. {
  13617. var black = blackCode.First();
  13618. black.BlackCode = black.BlackCode ?? "";
  13619. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13620. if (blackSp.Length > 0)
  13621. {
  13622. try
  13623. {
  13624. var cityArrCode = new List<string>(20);
  13625. foreach (var item in blackSp)
  13626. {
  13627. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13628. var IndexSelect = itemSp[2];
  13629. var cityArrCodeLength = cityArrCode.Count - 1;
  13630. var startCity = IndexSelect.Substring(0, 3);
  13631. if (cityArrCodeLength > 0)
  13632. {
  13633. var arrEndCity = cityArrCode[cityArrCodeLength];
  13634. if (arrEndCity != startCity)
  13635. {
  13636. cityArrCode.Add(startCity.ToUpper());
  13637. }
  13638. }
  13639. else
  13640. {
  13641. cityArrCode.Add(startCity.ToUpper());
  13642. }
  13643. var endCity = IndexSelect.Substring(3, 3);
  13644. cityArrCode.Add(endCity.ToUpper());
  13645. }
  13646. var cityThree = string.Empty;
  13647. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13648. cityThree = cityThree.TrimEnd(',');
  13649. if (string.IsNullOrWhiteSpace(cityThree))
  13650. {
  13651. throw new
  13652. Exception("error");
  13653. }
  13654. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13655. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13656. foreach (var item in cityArrCode)
  13657. {
  13658. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13659. if (find != null)
  13660. {
  13661. city += find.City + "/";
  13662. }
  13663. else
  13664. {
  13665. city += item + "三字码未收入/";
  13666. }
  13667. }
  13668. city = city.TrimEnd('/');
  13669. }
  13670. catch (Exception e)
  13671. {
  13672. city = "黑屏代码格式不正确!";
  13673. }
  13674. }
  13675. }
  13676. else
  13677. {
  13678. city = "未录入黑屏代码";
  13679. }
  13680. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13681. {
  13682. Date = x.Date,
  13683. Days = x.Days,
  13684. Diffgroup = x.Diffgroup,
  13685. Diid = x.Diid,
  13686. Traffic_First = x.Traffic_First,
  13687. Traffic_Second = x.Traffic_Second,
  13688. Trip = x.Trip,
  13689. WeekDay = x.WeekDay,
  13690. Id = x.Id
  13691. }).ToList();
  13692. jw.Data = new
  13693. {
  13694. groupList = groupList.Select(x => new
  13695. {
  13696. x.Id,
  13697. x.TeamName,
  13698. x.TourCode
  13699. }).ToList(),
  13700. groupInfo = new
  13701. {
  13702. group.VisitDays,
  13703. group.TourCode,
  13704. group.VisitPNumber,
  13705. group.TeamName,
  13706. city
  13707. },
  13708. OpTravelList
  13709. };
  13710. jw.Code = 200;
  13711. jw.Msg = "操作成功!";
  13712. return Ok(jw);
  13713. }
  13714. /// <summary>
  13715. /// 删除团组行程单
  13716. /// </summary>
  13717. /// <returns></returns>
  13718. [HttpPost]
  13719. public IActionResult DelTravel(DelOpTravelDto dto)
  13720. {
  13721. var jw = JsonView(false);
  13722. if (dto.UserId <= 0 || dto.Diid <= 0)
  13723. {
  13724. jw.Msg = "请输入正确的参数!";
  13725. return Ok(jw);
  13726. }
  13727. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13728. .SetColumns(x => new Grp_TravelList
  13729. {
  13730. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13731. DeleteUserId = dto.UserId,
  13732. IsDel = 1,
  13733. }).ExecuteCommand();
  13734. jw = JsonView(true);
  13735. return Ok(jw);
  13736. }
  13737. /// <summary>
  13738. /// 行程单保存
  13739. /// </summary>
  13740. /// <returns></returns>
  13741. [HttpPost]
  13742. public IActionResult TravelSave(TravelSaveDto dto)
  13743. {
  13744. var jw = JsonView(false);
  13745. if (dto.Arr.Count > 0)
  13746. {
  13747. try
  13748. {
  13749. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13750. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13751. .ToList();
  13752. _sqlSugar.BeginTran();
  13753. foreach (var item in dto.Arr)
  13754. {
  13755. if (item.Id == 0)
  13756. {
  13757. throw new Exception("请传入正确的Id");
  13758. }
  13759. //比较上一次的差异
  13760. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13761. if (findTravel != null)
  13762. {
  13763. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13764. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13765. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13766. }
  13767. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13768. .SetColumns(x => new Grp_TravelList
  13769. {
  13770. Trip = item.Trip
  13771. }).ExecuteCommand();
  13772. }
  13773. _sqlSugar.CommitTran();
  13774. jw = JsonView(true);
  13775. }
  13776. catch (Exception ex)
  13777. {
  13778. _sqlSugar.RollbackTran();
  13779. jw.Msg = "程序异常!" + ex.Message;
  13780. }
  13781. }
  13782. else
  13783. {
  13784. jw.Msg = "请传入正确的参数!";
  13785. }
  13786. return Ok(jw);
  13787. }
  13788. private static string CheckStr(string original, string changed)
  13789. {
  13790. // 创建diff_match_patch对象
  13791. var dmp = new diff_match_patch();
  13792. // 计算差异
  13793. List<Diff> diffs = dmp.diff_main(original, changed);
  13794. // 清理和合并差异
  13795. dmp.diff_cleanupSemantic(diffs);
  13796. // 使用StringBuilder构建最终的字符串
  13797. var finalString = new StringBuilder();
  13798. // 输出差异结果,并构建变动后的字符串
  13799. foreach (Diff diff in diffs)
  13800. {
  13801. switch (diff.operation)
  13802. {
  13803. case Operation.EQUAL:
  13804. // 相等的部分,直接添加到最终字符串
  13805. finalString.Append(diff.text);
  13806. break;
  13807. case Operation.INSERT:
  13808. // 插入的部分,添加标记并添加到最终字符串
  13809. finalString.Append("[++]" + diff.text + "[++]");
  13810. break;
  13811. case Operation.DELETE:
  13812. // 删除的部分,不添加到最终字符串
  13813. //finalString.Append("[++]" + diff.text + "[++]");
  13814. break;
  13815. }
  13816. }
  13817. // 输出变动后的字符串
  13818. return finalString.ToString();
  13819. }
  13820. private class tagContent
  13821. {
  13822. public DateTime Date { get; set; }
  13823. public string StartTag { get; set; }
  13824. public string EndTag { get; set; }
  13825. public string Content { get; set; }
  13826. public static int tagLength { get { return 3; } }
  13827. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13828. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13829. public bool IsFinally { get; set; }
  13830. }
  13831. private static List<string> ExtractContentBetweenTags(string input, string tag)
  13832. {
  13833. var results = new List<string>();
  13834. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13835. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13836. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13837. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13838. string[] strValueArr = new string[1];
  13839. foreach (System.Text.RegularExpressions.Match match in matches)
  13840. {
  13841. var strValue = match.Groups[1].Value;
  13842. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13843. }
  13844. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13845. return results;
  13846. }
  13847. /// <summary>
  13848. /// 导出行程单
  13849. /// </summary>
  13850. /// <param name="dto"></param>
  13851. /// <returns></returns>
  13852. [HttpPost]
  13853. public IActionResult ExportTravel(ExportTravelDto dto)
  13854. {
  13855. var jw = JsonView(false);
  13856. jw.Data = "";
  13857. int diid = 0;
  13858. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13859. if (Find == null)
  13860. {
  13861. jw.Msg = "请选择正确的团组!";
  13862. return Ok(jw);
  13863. }
  13864. else
  13865. {
  13866. diid = Find.Id;
  13867. }
  13868. //数据源
  13869. var _travelList = new List<Grp_TravelList>();
  13870. DataTable dtBlack = null;
  13871. try
  13872. {
  13873. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13874. }
  13875. catch (Exception)
  13876. {
  13877. jw.Msg = "机票黑屏代码有误!";
  13878. return Ok(jw);
  13879. }
  13880. string CityStr = string.Empty;
  13881. if (dtBlack.Rows.Count == 0)
  13882. {
  13883. jw.Msg = "机票黑屏代码有误!";
  13884. return Ok(jw);
  13885. }
  13886. else
  13887. {
  13888. foreach (DataRow row in dtBlack.Rows)
  13889. {
  13890. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13891. {
  13892. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13893. return Ok(jw);
  13894. }
  13895. }
  13896. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13897. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13898. }
  13899. // 指定的文字
  13900. var targetTextDic = new Dictionary<string, List<string>>();
  13901. //创建数据源Table
  13902. var dtSource = new DataTable();
  13903. dtSource.Columns.Add("Days", typeof(string));
  13904. dtSource.Columns.Add("Date", typeof(string));
  13905. dtSource.Columns.Add("Week", typeof(string));
  13906. dtSource.Columns.Add("Traffic", typeof(string));
  13907. dtSource.Columns.Add("Trip", typeof(string));
  13908. //获取数据,放到datatable
  13909. foreach (var item in _travelList)
  13910. {
  13911. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13912. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13913. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13914. .Replace("[++]", string.Empty);
  13915. DataRow dr = dtSource.NewRow();
  13916. dr["Days"] = item.Days;
  13917. dr["Date"] = item.Date;
  13918. dr["Week"] = item.WeekDay;
  13919. dr["Traffic"] = item.Traffic_First
  13920. + "\r\n"
  13921. + item.Traffic_Second;
  13922. dr["Trip"] = item.Trip;
  13923. dtSource.Rows.Add(dr);
  13924. }
  13925. var dic = new Dictionary<string, string>
  13926. {
  13927. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  13928. { "City", CityStr },
  13929. { "Days", Find.VisitDays.ToString() },
  13930. { "DeleCode", Find.TourCode },
  13931. { "Pnum", Find.VisitPNumber.ToString() }
  13932. };
  13933. //模板路径
  13934. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13935. //载入模板
  13936. Document doc = null;
  13937. DocumentBuilder builder = null;
  13938. try
  13939. {
  13940. //载入模板
  13941. doc = new Document(tempPath);
  13942. builder = new DocumentBuilder(doc);
  13943. }
  13944. catch (Exception)
  13945. {
  13946. jw.Msg = "模板位置不存在!";
  13947. return Ok(jw);
  13948. }
  13949. foreach (var key in dic.Keys)
  13950. {
  13951. Bookmark bookmark = doc.Range.Bookmarks[key];
  13952. if (bookmark != null)
  13953. {
  13954. builder.MoveToBookmark(key);
  13955. builder.Write(dic[key]);
  13956. }
  13957. }
  13958. //获取word里所有表格
  13959. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13960. //获取所填表格的序数
  13961. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13962. try
  13963. {
  13964. //循环赋值
  13965. for (int i = 0; i < dtSource.Rows.Count; i++)
  13966. {
  13967. builder.MoveToCell(0, i + 1, 0, 0);
  13968. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13969. builder.MoveToCell(0, i + 1, 1, 0);
  13970. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13971. builder.MoveToCell(0, i + 1, 2, 0);
  13972. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13973. var trip = dtSource.Rows[i]["Trip"].ToString();
  13974. builder.MoveToCell(0, i + 1, 3, 0);
  13975. builder.Write(trip);
  13976. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13977. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13978. // 获取特定索引的段落
  13979. Paragraph paragraph = (Paragraph)paragraphs[0];
  13980. Run run = paragraph.Runs[0];
  13981. Aspose.Words.Font font = run.Font;
  13982. font.Name = "黑体";
  13983. //设置双休红色
  13984. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13985. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13986. paragraph = (Paragraph)paragraphs[1];
  13987. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13988. {
  13989. run = paragraph.Runs[0];
  13990. font = run.Font;
  13991. font.Color = Color.Red;
  13992. }
  13993. }
  13994. }
  13995. catch (Exception ex)
  13996. {
  13997. }
  13998. //删除多余行
  13999. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14000. {
  14001. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14002. }
  14003. var targetTextList = new List<string>();
  14004. // 遍历文档中的表格
  14005. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14006. {
  14007. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14008. {
  14009. var cellIndex = 0;
  14010. foreach (Cell cell in row.Cells)
  14011. {
  14012. if (cellIndex == 1 && row.Cells.Count == 4)
  14013. {
  14014. foreach (var target in targetTextDic.Keys)
  14015. {
  14016. if (cell.GetText().Contains(target))
  14017. {
  14018. targetTextList = targetTextDic[target];
  14019. break;
  14020. }
  14021. }
  14022. }
  14023. // 遍历单元格中的所有段落
  14024. foreach (Paragraph paragraph in cell.Paragraphs)
  14025. {
  14026. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14027. var runs = new List<Run>();
  14028. foreach (Run run in paragraph.Runs)
  14029. {
  14030. runs.Add(run);
  14031. }
  14032. foreach (Run run in runs)
  14033. {
  14034. foreach (var targetText in targetTextList)
  14035. {
  14036. // 检查文字是否包含指定文字
  14037. if (run.Text.Contains(targetText))
  14038. {
  14039. // 将包含的部分设置为红色
  14040. HighlightText(run, targetText, Color.Red);
  14041. }
  14042. }
  14043. }
  14044. }
  14045. cellIndex++;
  14046. }
  14047. }
  14048. }
  14049. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14050. if (!Directory.Exists(savePath))
  14051. {
  14052. try
  14053. {
  14054. Directory.CreateDirectory(savePath);
  14055. }
  14056. catch
  14057. {
  14058. }
  14059. }
  14060. string path = savePath + Find.TeamName + "出访日程";
  14061. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14062. try
  14063. {
  14064. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14065. string postfix = ".docx";
  14066. if (dto.IsPDF == 1)
  14067. {
  14068. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14069. postfix = ".pdf";
  14070. }
  14071. doc.Save(path + postfix, saveFormat);
  14072. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14073. }
  14074. catch (Exception)
  14075. {
  14076. jw = JsonView(false);
  14077. }
  14078. return Ok(jw);
  14079. }
  14080. /// <summary>
  14081. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14082. /// </summary>
  14083. /// <param name="num"></param>
  14084. /// <returns></returns>
  14085. static string GetNum(string num)
  14086. {
  14087. string str = "";
  14088. switch (num)
  14089. {
  14090. case "1":
  14091. str = "一";
  14092. break;
  14093. case "2":
  14094. str = "二";
  14095. break;
  14096. case "3":
  14097. str = "三";
  14098. break;
  14099. case "4":
  14100. str = "四";
  14101. break;
  14102. case "5":
  14103. str = "五";
  14104. break;
  14105. case "6":
  14106. str = "六";
  14107. break;
  14108. case "7":
  14109. str = "七";
  14110. break;
  14111. case "8":
  14112. str = "八";
  14113. break;
  14114. case "9":
  14115. str = "九";
  14116. break;
  14117. case "10":
  14118. str = "十";
  14119. break;
  14120. case "11":
  14121. str = "十一";
  14122. break;
  14123. case "12":
  14124. str = "十二";
  14125. break;
  14126. case "一":
  14127. str = "1";
  14128. break;
  14129. case "二":
  14130. str = "2";
  14131. break;
  14132. case "三":
  14133. str = "3";
  14134. break;
  14135. case "四":
  14136. str = "4";
  14137. break;
  14138. case "五":
  14139. str = "5";
  14140. break;
  14141. case "六":
  14142. str = "6";
  14143. break;
  14144. case "七":
  14145. str = "7";
  14146. break;
  14147. case "八":
  14148. str = "8";
  14149. break;
  14150. case "九":
  14151. str = "9";
  14152. break;
  14153. case "十":
  14154. str = "10";
  14155. break;
  14156. case "十一":
  14157. str = "11";
  14158. break;
  14159. case "十二":
  14160. str = "12";
  14161. break;
  14162. }
  14163. return str;
  14164. }
  14165. /// <summary>
  14166. /// 高亮包含指定文字的部分
  14167. /// </summary>
  14168. /// <param name="run"></param>
  14169. /// <param name="targetText"></param>
  14170. /// <param name="color"></param>
  14171. static void HighlightText(Run run, string targetText, Color color)
  14172. {
  14173. string text = run.Text;
  14174. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14175. if (startIndex >= 0)
  14176. {
  14177. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14178. // 前部分
  14179. if (startIndex > 0)
  14180. {
  14181. Run beforeRun = (Run)run.Clone(true);
  14182. beforeRun.Text = text.Substring(0, startIndex);
  14183. parentParagraph.InsertBefore(beforeRun, run);
  14184. }
  14185. // 匹配部分
  14186. Run matchRun = (Run)run.Clone(true);
  14187. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14188. matchRun.Font.Color = color;
  14189. parentParagraph.InsertBefore(matchRun, run);
  14190. // 后部分
  14191. if (startIndex + targetText.Length < text.Length)
  14192. {
  14193. Run afterRun = (Run)run.Clone(true);
  14194. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14195. parentParagraph.InsertBefore(afterRun, run);
  14196. }
  14197. // 删除原始Run
  14198. run.Remove();
  14199. }
  14200. }
  14201. #endregion
  14202. #endregion
  14203. #region 团组成本
  14204. /// <summary>
  14205. /// 团组成本数据初始化
  14206. /// </summary>
  14207. /// <param name="dto"></param>
  14208. /// <returns></returns>
  14209. [HttpPost]
  14210. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14211. {
  14212. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14213. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14214. WHEN COUNT(*) >= 0 THEN 'True'
  14215. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14216. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14217. ").ToList(); //团组列表
  14218. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14219. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14220. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14221. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14222. if (groupinfoValue != null)
  14223. {
  14224. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14225. var spArr = new string[1] { countryArr };
  14226. if (countryArr.Contains("|"))
  14227. {
  14228. spArr = countryArr.Split("|");
  14229. }
  14230. else if (countryArr.Contains("、"))
  14231. {
  14232. spArr = countryArr.Split("、");
  14233. }
  14234. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14235. {
  14236. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14237. if (dbQueryCountry != null)
  14238. {
  14239. visaCountryInfoArr.Add(dbQueryCountry);
  14240. }
  14241. }
  14242. }
  14243. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14244. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14245. #region 屏蔽黑屏代码生成
  14246. //var create = _GroupCostRepository.
  14247. // CreateGroupCostByBlackCode(dto.Diid);
  14248. //if (groupCost.Count == 0 && create.Code == 0)
  14249. //{
  14250. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14251. //}
  14252. #endregion
  14253. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14254. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14255. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14256. groupCostMap = groupCostMap.Select(x =>
  14257. {
  14258. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14259. {
  14260. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14261. }
  14262. return x;
  14263. }).ToList();
  14264. //GroupCostParameter.Add(new
  14265. // Grp_GroupCostParameter());
  14266. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14267. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14268. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14269. return Ok(JsonView(new
  14270. {
  14271. groupList,
  14272. groupInfo,
  14273. groupChecks,
  14274. groupCost = groupCostMap,
  14275. hotelNumber,
  14276. GroupCostParameter = GroupCostParameterMap,
  14277. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14278. {
  14279. x.VisaCountry,
  14280. x.VisaPrice,
  14281. x.Id,
  14282. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14283. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14284. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14285. x.VisaTime, // 一般签证时间
  14286. x.PettyBusinessAgencyFee, //小公务代办费
  14287. x.GrandBusinessAgencyFee //大公务代办费
  14288. }).ToList(),
  14289. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14290. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14291. hotelIsTrue,
  14292. groupModuleOperators
  14293. }));
  14294. }
  14295. /// <summary>
  14296. /// 团组成本信息保存
  14297. /// </summary>
  14298. /// <param name="dto"></param>
  14299. /// <returns></returns>
  14300. [HttpPost]
  14301. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14302. {
  14303. if (dto.Diid <= 0 || dto.Userid <= 0)
  14304. {
  14305. return Ok(JsonView(false));
  14306. }
  14307. JsonView jw = null;
  14308. bool isTrue = false;
  14309. #region 复制团组成本
  14310. //if (dto.Diid == 2581)
  14311. //{
  14312. // dto.Diid = 2599;
  14313. // dto.CheckBoxs.ForEach(x =>
  14314. // {
  14315. // x.Diid = 2599;
  14316. // });
  14317. // dto.GroupCosts.ForEach(x =>
  14318. // {
  14319. // x.Diid = 2599;
  14320. // });
  14321. // dto.CostTypeHotelNumbers.ForEach(x =>
  14322. // {
  14323. // x.Diid = 2599;
  14324. // });
  14325. // dto.GroupCostParameters.ForEach(x =>
  14326. // {
  14327. // x.DiId = 2599;
  14328. // });
  14329. //}
  14330. #endregion
  14331. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14332. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14333. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14334. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14335. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14336. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14337. try
  14338. {
  14339. _sqlSugar.BeginTran();
  14340. isTrue = await _GroupCostRepository.
  14341. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14342. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14343. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14344. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14345. _sqlSugar.CommitTran();
  14346. jw = JsonView(true, "保存成功!", isTrue);
  14347. }
  14348. catch (Exception)
  14349. {
  14350. _sqlSugar.RollbackTran();
  14351. jw = JsonView(false);
  14352. }
  14353. return Ok(jw);
  14354. }
  14355. /// <summary>
  14356. /// 复制团组成本信息
  14357. /// </summary>
  14358. /// <param name="dto"></param>
  14359. /// <returns></returns>
  14360. [HttpPost]
  14361. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14362. {
  14363. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14364. {
  14365. return Ok(JsonView(false, "参数有误!"));
  14366. }
  14367. #region 复制团组成本
  14368. dto.Diid = dto.ToGroupId;
  14369. dto.CheckBoxs.ForEach(x =>
  14370. {
  14371. x.Diid = dto.ToGroupId;
  14372. });
  14373. dto.GroupCosts.ForEach(x =>
  14374. {
  14375. x.Diid = dto.ToGroupId;
  14376. });
  14377. dto.CostTypeHotelNumbers.ForEach(x =>
  14378. {
  14379. x.Diid = dto.ToGroupId;
  14380. });
  14381. dto.GroupCostParameters.ForEach(x =>
  14382. {
  14383. x.DiId = dto.ToGroupId;
  14384. });
  14385. #endregion
  14386. JsonView jw = null;
  14387. bool isTrue = false;
  14388. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14389. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14390. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14391. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14392. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14393. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14394. try
  14395. {
  14396. _sqlSugar.BeginTran();
  14397. isTrue = await _GroupCostRepository.
  14398. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14399. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14400. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14401. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14402. _sqlSugar.CommitTran();
  14403. jw = JsonView(true, "保存成功!", isTrue);
  14404. }
  14405. catch (Exception)
  14406. {
  14407. _sqlSugar.RollbackTran();
  14408. jw = JsonView(false);
  14409. }
  14410. return Ok(jw);
  14411. }
  14412. /// <summary>
  14413. /// 司兼导数据
  14414. /// </summary>
  14415. /// <param name="dto"></param>
  14416. /// <returns></returns>
  14417. [HttpPost]
  14418. public IActionResult GetCarGuides(CarGuidesDto dto)
  14419. {
  14420. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14421. return Ok(JsonView(true, "获取成功!", Data));
  14422. }
  14423. /// <summary>
  14424. /// 导游数据
  14425. /// </summary>
  14426. /// <param name="dto"></param>
  14427. /// <returns></returns>
  14428. [HttpPost]
  14429. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14430. {
  14431. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14432. // 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
  14433. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14434. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14435. return Ok(JsonView(true, "获取成功!", Data));
  14436. }
  14437. /// <summary>
  14438. /// 成本车数据
  14439. /// </summary>
  14440. /// <param name="dto"></param>
  14441. /// <returns></returns>
  14442. [HttpPost]
  14443. public IActionResult GetCarInfo(CarGuidesDto dto)
  14444. {
  14445. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14446. return Ok(JsonView(true, "获取成功!", Data));
  14447. }
  14448. /// <summary>
  14449. /// 景点数据
  14450. /// </summary>
  14451. /// <param name="dto"></param>
  14452. /// <returns></returns>
  14453. [HttpPost]
  14454. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14455. {
  14456. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14457. return Ok(JsonView(true, "获取成功!", Data));
  14458. }
  14459. /// <summary>
  14460. /// 成本通知
  14461. /// </summary>
  14462. /// <param name="dto"></param>
  14463. /// <returns></returns>
  14464. [HttpPost]
  14465. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14466. {
  14467. if (dto.Diid < 0)
  14468. {
  14469. return Ok(JsonView(false));
  14470. }
  14471. JsonView jw;
  14472. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14473. if (GroupCostParameter != null)
  14474. {
  14475. int IsShare = 0;
  14476. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14477. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14478. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14479. string msg = string.Empty;
  14480. if (isTrue)
  14481. {
  14482. if (IsShare == 0)
  14483. {
  14484. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14485. }
  14486. else
  14487. {
  14488. #region 企微通知对应岗位用户
  14489. try
  14490. {
  14491. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14492. }
  14493. catch (Exception)
  14494. {
  14495. }
  14496. #endregion
  14497. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14498. }
  14499. jw = JsonView(isTrue, msg, new { IsShare });
  14500. }
  14501. else
  14502. {
  14503. msg = "修改失败!";
  14504. jw = JsonView(isTrue, msg);
  14505. }
  14506. }
  14507. else
  14508. {
  14509. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14510. }
  14511. return Ok(jw);
  14512. }
  14513. /// <summary>
  14514. /// 导出报价单
  14515. /// </summary>
  14516. /// <param name="dto"></param>
  14517. /// <returns></returns>
  14518. [HttpPost]
  14519. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14520. {
  14521. if (dto.Diid == 0)
  14522. {
  14523. return Ok(JsonView(false, "请传递团组id"));
  14524. }
  14525. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14526. if (deleInfo.Code != 0)
  14527. {
  14528. return Ok(JsonView(false, "团组信息查询失败!"));
  14529. }
  14530. var di = deleInfo.Data as DelegationInfoWebView;
  14531. if (di != null)
  14532. {
  14533. di.TeamName = di.TeamName.Replace("|", "、");
  14534. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14535. //文件名
  14536. string strFileName = di.TeamName + "-收款账单.doc";
  14537. //获取模板
  14538. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14539. //载入模板
  14540. Document doc = new Document(tmppath);
  14541. decimal TotalPrice = 0.00M;
  14542. string itemStr = string.Empty;
  14543. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14544. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14545. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14546. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14547. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14548. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14549. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14550. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14551. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14552. foreach (var cost in groupCostType)
  14553. {
  14554. var List = cost.ToList();
  14555. if (cost.Key == "A")
  14556. {
  14557. foreach (var ListItem in List)
  14558. {
  14559. if (ListItem.number > 0)
  14560. {
  14561. if (ListItem.code.Contains("TBR"))
  14562. {
  14563. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14564. }
  14565. else
  14566. {
  14567. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14568. }
  14569. TotalPrice += (ListItem.number * ListItem.price);
  14570. }
  14571. }
  14572. }
  14573. else
  14574. {
  14575. itemStr = itemStr.Insert(0, "A段\r\n");
  14576. itemStr += "B段\r\n";
  14577. foreach (var ListItem in List)
  14578. {
  14579. if (ListItem.number > 0)
  14580. {
  14581. if (ListItem.code.Contains("TBR"))
  14582. {
  14583. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14584. }
  14585. else
  14586. {
  14587. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14588. }
  14589. TotalPrice += (ListItem.number * ListItem.price);
  14590. }
  14591. }
  14592. }
  14593. }
  14594. #region 替换Word模板书签内容
  14595. Dictionary<string, string> marks = new Dictionary<string, string>();
  14596. marks.Add("To", di.ClientUnit);//付款方
  14597. marks.Add("ToTel", di.TellPhone);//付款方电话
  14598. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14599. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14600. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14601. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14602. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14603. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14604. marks.Add("PayItemContent", itemStr);//详细信息
  14605. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14606. #endregion
  14607. ////注
  14608. //if (doc.Range.Bookmarks["Attention"] != null)
  14609. //{
  14610. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14611. // mark.Text = frList[0].Attention;
  14612. //}
  14613. foreach (var item in marks.Keys)
  14614. {
  14615. if (doc.Range.Bookmarks[item] != null)
  14616. {
  14617. Bookmark mark = doc.Range.Bookmarks[item];
  14618. mark.Text = marks[item];
  14619. }
  14620. }
  14621. byte[] bytes = null;
  14622. using (MemoryStream stream = new MemoryStream())
  14623. {
  14624. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14625. bytes = stream.ToArray();
  14626. }
  14627. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14628. return Ok(JsonView(true, "", new
  14629. {
  14630. Data = bytes,
  14631. strFileName,
  14632. }));
  14633. }
  14634. else
  14635. {
  14636. return Ok(JsonView(false, "团组信息不存在!"));
  14637. }
  14638. }
  14639. /// <summary>
  14640. /// 导出团组成本
  14641. /// </summary>
  14642. /// <param name="dto"></param>
  14643. /// <returns></returns>
  14644. [HttpPost]
  14645. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14646. {
  14647. var jw = JsonView(false);
  14648. if (dto.Diid == 0)
  14649. {
  14650. return Ok(JsonView(false, "请传递团组id"));
  14651. }
  14652. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14653. if (deleInfo.Code != 0)
  14654. {
  14655. return Ok(JsonView(false, "团组信息查询失败!"));
  14656. }
  14657. var di = deleInfo.Data as DelegationInfoWebView;
  14658. if (di == null)
  14659. {
  14660. return Ok(JsonView(false, "团组信息查询失败!"));
  14661. }
  14662. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14663. WorkbookDesigner designer = new WorkbookDesigner();
  14664. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14665. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14666. List<int> hideColumnList = new List<int>();
  14667. var ColumnSetting = new[]
  14668. {
  14669. new { tag = "VF", Index = 4, P = "CarCost" },
  14670. new { tag = "VN", Index = 5, P = "CarNumber" },
  14671. new { tag = "VRD", Index = 6, P = "CarTiming" },
  14672. new { tag = "T/G S", Index = 7, P = "TGS" },
  14673. new { tag = "TGWH", Index = 8, P = "TGWH" },
  14674. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  14675. new { tag = "T/G M", Index = 10, P = "TGM" },
  14676. new { tag = "T/G A", Index = 11, P = "TGA" },
  14677. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  14678. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  14679. new { tag = "C/F S", Index = 14, P = "CFS" },
  14680. new { tag = "C/F M", Index = 15, P = "CFM" },
  14681. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  14682. new { tag = "B", Index = 17, P = "B" },
  14683. new { tag = "L", Index = 18, P = "L" },
  14684. new { tag = "D", Index = 19, P = "D" },
  14685. new { tag = "TBR", Index = 20, P = "TBR" },
  14686. new { tag = "SGR", Index = 21, P = "SGR" },
  14687. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  14688. new { tag = "Suite", Index = 23, P = "Suite" },
  14689. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  14690. new { tag = "T/V", Index = 25, P = "TV" },
  14691. new { tag = "1/L", Index = 26, P = "iL" },
  14692. new { tag = "I/F", Index = 27, P = "IF" },
  14693. new { tag = "EF", Index = 28, P = "EF" },
  14694. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  14695. new { tag = "TE", Index = 30, P = "TE" },
  14696. new { tag = "T/G T", Index = 31, P = "TGTips" },
  14697. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  14698. new { tag = "P/C", Index = 33, P = "PC" },
  14699. new { tag = "T/L F", Index = 34, P = "TLF" },
  14700. new { tag = "E/C T", Index = 35, P = "ECT" }
  14701. };
  14702. Func<string, bool> isEmpty = (str) =>
  14703. {
  14704. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  14705. {
  14706. return true;
  14707. }
  14708. if (string.IsNullOrWhiteSpace(str))
  14709. {
  14710. return true;
  14711. }
  14712. return false;
  14713. };
  14714. for (int i = 0; i < List_GC.Count; i++)
  14715. {
  14716. GroupCost_Excel gc = new GroupCost_Excel();
  14717. gc.Id = List_GC[i].Id;
  14718. gc.Diid = List_GC[i].Diid.ToString();
  14719. gc.DAY = List_GC[i].DAY;
  14720. string week = "";
  14721. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14722. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14723. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14724. gc.ITIN = List_GC[i].ITIN;
  14725. gc.CarType = List_GC[i].CarType;
  14726. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  14727. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  14728. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  14729. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  14730. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  14731. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  14732. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  14733. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  14734. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  14735. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  14736. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  14737. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  14738. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  14739. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  14740. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  14741. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  14742. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  14743. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  14744. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  14745. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  14746. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  14747. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  14748. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  14749. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  14750. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  14751. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  14752. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  14753. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  14754. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  14755. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  14756. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  14757. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  14758. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  14759. gc.EFR = List_GC[i].EFR;
  14760. List_GC1.Add(gc);
  14761. }
  14762. if (List_GC1.Count > 0)
  14763. {
  14764. var p = List_GC1[0];
  14765. var prs = p.GetType().GetProperties();
  14766. foreach (var item in prs)
  14767. {
  14768. var tp = item.PropertyType;
  14769. if (tp == typeof(int))
  14770. {
  14771. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  14772. if (val == 0)
  14773. {
  14774. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14775. if (columnSetting != null)
  14776. {
  14777. hideColumnList.Add(columnSetting.Index);
  14778. }
  14779. }
  14780. }
  14781. if (tp == typeof(decimal))
  14782. {
  14783. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  14784. if (val == 0)
  14785. {
  14786. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14787. if (columnSetting != null)
  14788. {
  14789. hideColumnList.Add(columnSetting.Index);
  14790. }
  14791. }
  14792. }
  14793. if (tp == typeof(string))
  14794. {
  14795. var val = List_GC1.Sum(x =>
  14796. {
  14797. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  14798. if (decimal.TryParse(str, out decimal str_De))
  14799. {
  14800. return str_De;
  14801. }
  14802. else
  14803. {
  14804. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  14805. }
  14806. });
  14807. if (val == 0)
  14808. {
  14809. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14810. if (columnSetting != null)
  14811. {
  14812. hideColumnList.Add(columnSetting.Index);
  14813. }
  14814. }
  14815. }
  14816. }
  14817. }
  14818. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14819. dt.TableName = "TB";
  14820. //报表标题等不用dt的值
  14821. designer.SetDataSource("TeamName", dto.title.TeamName);
  14822. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14823. designer.SetDataSource("Tax", dto.title.Tax);
  14824. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14825. designer.SetDataSource("Currency", dto.title.Currency);
  14826. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14827. designer.SetDataSource("Rate", dto.title.Rate);
  14828. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14829. var Aparams = hotels.Find(x => x.Type == "Default");
  14830. if (Aparams == null)
  14831. {
  14832. return Ok(jw);
  14833. }
  14834. //酒店数量
  14835. var txtSGRNumber = Aparams.SGR.ToString();
  14836. var txtTBRNumber = Aparams.TBR.ToString();
  14837. var txtJSESNumber = Aparams.JSES.ToString();
  14838. var txtSUITENumbe = Aparams.SUITE.ToString();
  14839. if (dto.costType == "B")
  14840. {
  14841. Aparams = hotels.Find(x => x.Type == "A");
  14842. var Bparams = hotels.Find(x => x.Type == "B");
  14843. if (Aparams == null || Bparams == null)
  14844. {
  14845. return Ok(jw);
  14846. }
  14847. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14848. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14849. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14850. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14851. }
  14852. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14853. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14854. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14855. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14856. var ws = designer.Workbook.Worksheets[1];
  14857. int Row = List_GC.Count;
  14858. int startIndex = 0;
  14859. int HideRows = 0;
  14860. Row = 0;
  14861. List<int> hideRowsList = new List<int>();
  14862. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14863. #region A段left数据
  14864. var left = dto.leftInfo.Find(x => x.Type == "A");
  14865. if (left == null)
  14866. {
  14867. return Ok(jw);
  14868. }
  14869. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14870. if (leftBindData != null)
  14871. {
  14872. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14873. designer.SetDataSource("VisaRS", leftBindData.rs);
  14874. designer.SetDataSource("VisaXS", leftBindData.xs);
  14875. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14876. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14877. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14878. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14879. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14880. }
  14881. else
  14882. {
  14883. hideRowsList.Add(Row + startIndex + HideRows);
  14884. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14885. }
  14886. HideRows += 2;
  14887. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14888. if (leftBindData != null)
  14889. {
  14890. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14891. designer.SetDataSource("BXRS", leftBindData.rs);
  14892. designer.SetDataSource("BXXS", leftBindData.xs);
  14893. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14894. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14895. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14896. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14897. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14898. }
  14899. else
  14900. {
  14901. hideRowsList.Add(Row + startIndex + HideRows);
  14902. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14903. }
  14904. HideRows += 2;
  14905. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14906. if (leftBindData != null)
  14907. {
  14908. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14909. designer.SetDataSource("HSRS", leftBindData.rs);
  14910. designer.SetDataSource("HSXS", leftBindData.xs);
  14911. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14912. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14913. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14914. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14915. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14916. }
  14917. else
  14918. {
  14919. hideRowsList.Add(Row + startIndex + HideRows);
  14920. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14921. }
  14922. HideRows += 2;
  14923. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14924. if (leftBindData != null)
  14925. {
  14926. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14927. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14928. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14929. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14930. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14931. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14932. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14933. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14934. }
  14935. else
  14936. {
  14937. hideRowsList.Add(Row + startIndex + HideRows);
  14938. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14939. }
  14940. HideRows += 2;
  14941. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14942. if (leftBindData != null)
  14943. {
  14944. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14945. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14946. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14947. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14948. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14949. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14950. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14951. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14952. }
  14953. else
  14954. {
  14955. hideRowsList.Add(Row + startIndex + HideRows);
  14956. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14957. }
  14958. HideRows += 2;
  14959. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14960. if (leftBindData != null)
  14961. {
  14962. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14963. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14964. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14965. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14966. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14967. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14968. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14969. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14970. }
  14971. else
  14972. {
  14973. hideRowsList.Add(Row + startIndex + HideRows);
  14974. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14975. }
  14976. HideRows += 2;
  14977. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14978. if (leftBindData != null)
  14979. {
  14980. ////TBR
  14981. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14982. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14983. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14984. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14985. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14986. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14987. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14988. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14989. }
  14990. else
  14991. {
  14992. hideRowsList.Add(Row + startIndex + HideRows);
  14993. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14994. }
  14995. HideRows += 2;
  14996. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14997. if (leftBindData != null)
  14998. {
  14999. ////SGR
  15000. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  15001. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  15002. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  15003. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15004. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15005. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15006. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15007. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15008. }
  15009. else
  15010. {
  15011. hideRowsList.Add(Row + startIndex + HideRows);
  15012. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15013. }
  15014. HideRows += 2;
  15015. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15016. if (leftBindData != null)
  15017. {
  15018. ////JS/ES
  15019. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15020. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15021. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15022. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15023. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15024. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15025. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15026. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15027. }
  15028. else
  15029. {
  15030. hideRowsList.Add(Row + startIndex + HideRows);
  15031. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15032. }
  15033. HideRows += 2;
  15034. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15035. if (leftBindData != null)
  15036. {
  15037. ////SUITE
  15038. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15039. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15040. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15041. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15042. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15043. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15044. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15045. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15046. }
  15047. else
  15048. {
  15049. hideRowsList.Add(Row + startIndex + HideRows);
  15050. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15051. }
  15052. HideRows += 2;
  15053. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15054. if (leftBindData != null)
  15055. {
  15056. designer.SetDataSource("DJDRCB", leftBindData.cb);
  15057. designer.SetDataSource("DJRS", leftBindData.rs);
  15058. designer.SetDataSource("DJXS", leftBindData.xs);
  15059. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15060. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15061. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15062. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15063. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15064. }
  15065. else
  15066. {
  15067. hideRowsList.Add(Row + startIndex + HideRows);
  15068. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15069. }
  15070. HideRows += 2;
  15071. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15072. if (leftBindData != null)
  15073. {
  15074. designer.SetDataSource("HCPCB", leftBindData.cb);
  15075. designer.SetDataSource("HCPRS", leftBindData.rs);
  15076. designer.SetDataSource("HCPXS", leftBindData.xs);
  15077. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15078. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15079. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15080. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15081. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15082. }
  15083. else
  15084. {
  15085. hideRowsList.Add(Row + startIndex + HideRows);
  15086. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15087. }
  15088. HideRows += 2;
  15089. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15090. if (leftBindData != null)
  15091. {
  15092. designer.SetDataSource("CPCB", leftBindData.cb);
  15093. designer.SetDataSource("CPRS", leftBindData.rs);
  15094. designer.SetDataSource("CPXS", leftBindData.xs);
  15095. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15096. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15097. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15098. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15099. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15100. }
  15101. else
  15102. {
  15103. hideRowsList.Add(Row + startIndex + HideRows);
  15104. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15105. }
  15106. HideRows += 2;
  15107. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15108. if (leftBindData != null)
  15109. {
  15110. designer.SetDataSource("GWDRCD", leftBindData.cb);
  15111. designer.SetDataSource("GWRS", leftBindData.rs);
  15112. designer.SetDataSource("GWXS", leftBindData.xs);
  15113. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15114. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15115. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15116. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15117. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15118. }
  15119. else
  15120. {
  15121. hideRowsList.Add(Row + startIndex + HideRows);
  15122. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15123. }
  15124. HideRows += 2;
  15125. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15126. if (leftBindData != null)
  15127. {
  15128. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15129. designer.SetDataSource("LYJRS", leftBindData.rs);
  15130. designer.SetDataSource("LYJXS", leftBindData.xs);
  15131. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15132. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15133. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15134. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15135. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15136. }
  15137. else
  15138. {
  15139. hideRowsList.Add(Row + startIndex + HideRows);
  15140. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15141. }
  15142. #endregion
  15143. #region A段Right信息
  15144. var right = dto.rightInfo.Find(x => x.Type == "A");
  15145. if (right == null)
  15146. {
  15147. return Ok(jw);
  15148. }
  15149. HideRows += 4;
  15150. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15151. if (rightBindData != null)
  15152. {
  15153. //经济舱 + 双人间 TBR
  15154. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15155. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15156. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15157. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15158. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15159. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15160. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15161. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15162. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15163. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15164. }
  15165. else
  15166. {
  15167. hideRowsList.Add(Row + startIndex + HideRows);
  15168. }
  15169. HideRows += 2;
  15170. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15171. if (rightBindData != null)
  15172. {
  15173. //经济舱 + 单人间 SGR
  15174. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15175. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15176. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15177. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15178. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15179. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15180. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15181. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15182. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15183. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15184. }
  15185. else
  15186. {
  15187. hideRowsList.Add(Row + startIndex + HideRows);
  15188. }
  15189. HideRows += 2;
  15190. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15191. if (rightBindData != null)
  15192. {
  15193. //公务舱 + 单人间 SGR
  15194. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15195. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15196. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15197. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15198. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15199. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15200. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15201. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15202. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15203. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15204. }
  15205. else
  15206. {
  15207. hideRowsList.Add(Row + startIndex + HideRows);
  15208. }
  15209. HideRows += 2;
  15210. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15211. if (rightBindData != null)
  15212. {
  15213. //公务舱 + 小套房 JSES
  15214. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15215. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15216. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15217. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15218. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15219. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15220. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15221. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15222. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15223. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15224. }
  15225. else
  15226. {
  15227. hideRowsList.Add(Row + startIndex + HideRows);
  15228. }
  15229. HideRows += 2;
  15230. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15231. if (rightBindData != null)
  15232. {
  15233. //公务舱 + 小套房 JSES
  15234. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15235. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15236. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15237. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15238. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15239. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15240. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15241. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15242. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15243. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15244. }
  15245. else
  15246. {
  15247. hideRowsList.Add(Row + startIndex + HideRows);
  15248. }
  15249. HideRows += 2;
  15250. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15251. if (rightBindData != null)
  15252. {
  15253. //经济舱 + 大套房
  15254. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15255. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15256. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15257. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15258. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15259. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15260. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15261. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15262. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15263. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15264. }
  15265. else
  15266. {
  15267. hideRowsList.Add(Row + startIndex + HideRows);
  15268. }
  15269. HideRows += 2;
  15270. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15271. if (rightBindData != null)
  15272. {
  15273. //头等舱 + 小套房 JSES
  15274. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15275. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15276. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15277. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15278. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15279. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15280. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15281. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15282. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15283. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15284. }
  15285. else
  15286. {
  15287. hideRowsList.Add(Row + startIndex + HideRows);
  15288. }
  15289. HideRows += 2;
  15290. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15291. if (rightBindData != null)
  15292. {
  15293. //头等舱 + 大套房
  15294. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15295. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15296. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15297. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15298. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15299. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15300. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15301. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15302. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15303. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15304. }
  15305. else
  15306. {
  15307. hideRowsList.Add(Row + startIndex + HideRows);
  15308. }
  15309. #endregion
  15310. #region B段标题清空
  15311. designer.SetDataSource("CostBDRCB", "");
  15312. designer.SetDataSource("CostBRS", "");
  15313. designer.SetDataSource("CostBXS", "");
  15314. designer.SetDataSource("CostBZCB", "");
  15315. designer.SetDataSource("CostBDRBJ", "");
  15316. designer.SetDataSource("CostBZBJ", "");
  15317. designer.SetDataSource("CostBDRLR", "");
  15318. designer.SetDataSource("CostBZLR", "");
  15319. designer.SetDataSource("CostBDRCBOM", "");
  15320. designer.SetDataSource("CostBRSOM", "");
  15321. designer.SetDataSource("CostBZCBOM", "");
  15322. designer.SetDataSource("CostBDRBJOM", "");
  15323. designer.SetDataSource("CostBZBJOM", "");
  15324. designer.SetDataSource("CostBDRLROM", "");
  15325. designer.SetDataSource("CostBZLROM", "");
  15326. #endregion
  15327. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15328. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15329. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15330. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15331. designer.SetDataSource("DJName", "地接(CNY)");
  15332. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15333. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15334. designer.SetDataSource("GWName", "公务(CNY)");
  15335. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15336. designer.SetDataSource("LYJName", "零用金(CNY)");
  15337. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15338. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15339. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15340. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15341. designer.SetDataSource("BXName", "保险(CNY)");
  15342. designer.SetDataSource("VisaName", "签证(CNY)");
  15343. #region B段基本数据
  15344. if (dto.costType == "B")
  15345. {
  15346. left = dto.leftInfo.Find(x => x.Type == "B");
  15347. if (left == null)
  15348. {
  15349. return Ok(jw);
  15350. }
  15351. #region B段left数据
  15352. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15353. if (leftBindData != null)
  15354. {
  15355. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15356. designer.SetDataSource("BHSRS", leftBindData.rs);
  15357. designer.SetDataSource("BHSXS", leftBindData.xs);
  15358. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15359. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15360. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15361. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15362. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15363. }
  15364. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15365. if (leftBindData != null)
  15366. {
  15367. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15368. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15369. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15370. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15371. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15372. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15373. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15374. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15375. }
  15376. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15377. if (leftBindData != null)
  15378. {
  15379. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15380. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15381. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15382. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15383. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15384. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15385. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15386. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15387. }
  15388. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15389. if (leftBindData != null)
  15390. {
  15391. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15392. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15393. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15394. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15395. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15396. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15397. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15398. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15399. }
  15400. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15401. if (leftBindData != null)
  15402. {
  15403. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15404. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15405. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15406. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15407. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15408. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15409. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15410. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15411. }
  15412. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15413. if (leftBindData != null)
  15414. {
  15415. designer.SetDataSource("BCPCB", leftBindData.cb);
  15416. designer.SetDataSource("BCPRS", leftBindData.rs);
  15417. designer.SetDataSource("BCPXS", leftBindData.xs);
  15418. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15419. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15420. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15421. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15422. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15423. }
  15424. //TBR
  15425. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15426. if (leftBindData != null)
  15427. {
  15428. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15429. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15430. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15431. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15432. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15433. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15434. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15435. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15436. }
  15437. //SGR
  15438. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15439. if (leftBindData != null)
  15440. {
  15441. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15442. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15443. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15444. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15445. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15446. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15447. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15448. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15449. }
  15450. //JS/ES
  15451. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15452. if (leftBindData != null)
  15453. {
  15454. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15455. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15456. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15457. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15458. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15459. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15460. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15461. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15462. }
  15463. //SUITE
  15464. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15465. if (leftBindData != null)
  15466. {
  15467. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15468. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15469. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15470. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15471. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15472. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15473. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15474. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15475. }
  15476. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15477. if (leftBindData != null)
  15478. {
  15479. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15480. designer.SetDataSource("BDJRS", leftBindData.rs);
  15481. designer.SetDataSource("BDJXS", leftBindData.xs);
  15482. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15483. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15484. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15485. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15486. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15487. }
  15488. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15489. if (leftBindData != null)
  15490. {
  15491. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15492. designer.SetDataSource("BGWRS", leftBindData.rs);
  15493. designer.SetDataSource("BGWXS", leftBindData.xs);
  15494. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15495. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15496. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15497. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15498. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15499. }
  15500. #region 优化方案
  15501. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15502. //excelBind.Add("零用金", new {
  15503. //cb="",
  15504. //rs="",
  15505. //xs ="",
  15506. //zcb = "",
  15507. //});
  15508. #endregion
  15509. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15510. if (leftBindData != null)
  15511. {
  15512. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15513. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15514. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15515. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15516. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15517. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15518. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15519. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15520. }
  15521. #endregion
  15522. #region B段Right信息
  15523. right = dto.rightInfo.Find(x => x.Type == "B");
  15524. if (right == null)
  15525. {
  15526. return Ok(jw);
  15527. }
  15528. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15529. if (rightBindData != null)
  15530. {
  15531. //经济舱 + 双人间 TBR
  15532. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15533. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15534. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15535. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15536. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15537. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15538. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15539. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15540. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15541. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15542. }
  15543. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15544. if (rightBindData != null)
  15545. {
  15546. //经济舱 + 单人间 SGR
  15547. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15548. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15549. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15550. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15551. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15552. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15553. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15554. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15555. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15556. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15557. }
  15558. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15559. if (rightBindData != null)
  15560. {
  15561. //公务舱 + 单人间 SGR
  15562. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15563. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15564. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15565. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15566. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15567. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15568. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15569. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15570. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15571. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15572. }
  15573. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15574. if (rightBindData != null)
  15575. {
  15576. //公务舱 + 小套房 JSES
  15577. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15578. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15579. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15580. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15581. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15582. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15583. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15584. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15585. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15586. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15587. }
  15588. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15589. if (rightBindData != null)
  15590. {
  15591. //公务舱 + 小套房 JSES
  15592. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15593. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15594. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15595. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15596. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15597. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15598. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15599. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15600. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15601. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15602. }
  15603. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15604. if (rightBindData != null)
  15605. {
  15606. //经济舱 + 大套房
  15607. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15608. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15609. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15610. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15611. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15612. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15613. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15614. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15615. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15616. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15617. }
  15618. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15619. if (rightBindData != null)
  15620. {
  15621. //头等舱 + 小套房 JSES
  15622. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15623. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15624. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15625. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15626. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15627. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15628. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15629. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15630. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15631. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15632. }
  15633. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15634. if (rightBindData != null)
  15635. {
  15636. //头等舱 + 大套房
  15637. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15638. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15639. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15640. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15641. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15642. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15643. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15644. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15645. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15646. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15647. }
  15648. #endregion
  15649. #region 标题
  15650. designer.SetDataSource("CostBDRCB", "单人成本");
  15651. designer.SetDataSource("CostBRS", "人数");
  15652. designer.SetDataSource("CostBXS", "系数");
  15653. designer.SetDataSource("CostBZCB", "总成本");
  15654. designer.SetDataSource("CostBDRBJ", "单人报价");
  15655. designer.SetDataSource("CostBZBJ", "总报价");
  15656. designer.SetDataSource("CostBDRLR", "单人利润");
  15657. designer.SetDataSource("CostBZLR", "总利润");
  15658. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15659. designer.SetDataSource("CostBRSOM", "人数");
  15660. designer.SetDataSource("CostBZCBOM", "总成本");
  15661. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15662. designer.SetDataSource("CostBZBJOM", "总报价");
  15663. designer.SetDataSource("CostBDRLROM", "单人利润");
  15664. designer.SetDataSource("CostBZLROM", "总利润");
  15665. #endregion
  15666. }
  15667. #endregion
  15668. designer.SetDataSource("TzZCB2", TzZCB2);
  15669. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15670. designer.SetDataSource("TzZLR2", TzZLR2);
  15671. string[] dataSourceKeys = new string[]
  15672. {
  15673. "VF",
  15674. "TGS",
  15675. "TGOF",
  15676. "TGM",
  15677. "TGA",
  15678. "TGTF",
  15679. "TGEF",
  15680. "CFM",
  15681. "CFOF",
  15682. "B",
  15683. "L",
  15684. "D",
  15685. "TBR",
  15686. "SGR",
  15687. "JSES",
  15688. "Suite",
  15689. "TV",
  15690. "1L",
  15691. "IF",
  15692. "EF",
  15693. "BRF",
  15694. "TE",
  15695. "TGT",
  15696. "DRVT",
  15697. "PC",
  15698. "TLF",
  15699. "ECT"
  15700. };
  15701. foreach (var item in dataSourceKeys)
  15702. {
  15703. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  15704. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  15705. var find = dto.titleModel.FirstOrDefault(expr);
  15706. if (find != null)
  15707. {
  15708. designer.SetDataSource(item, find.text);
  15709. }
  15710. else
  15711. {
  15712. designer.SetDataSource(item, 0);
  15713. }
  15714. }
  15715. designer.SetDataSource(dt);
  15716. //根据数据源处理生成报表内容
  15717. designer.Process();
  15718. designer.Workbook.Worksheets[0].Name = "费用明细";
  15719. designer.Workbook.Worksheets[1].Name = "费用总核算";
  15720. Worksheet sheet = designer.Workbook.Worksheets[0];
  15721. #region 隐藏舱位
  15722. var settingAir = new[]
  15723. {
  15724. new { key = "经济舱", index = 7 },
  15725. new { key = "公务舱", index = 19 },
  15726. new { key = "头等舱", index = 11 }
  15727. };
  15728. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  15729. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  15730. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  15731. .Select((c, s) => s.Name)
  15732. .ToList()
  15733. .GroupBy(x => x)
  15734. .Select(x => x.Key);
  15735. foreach (var item in settingAir)
  15736. {
  15737. if (!airType.Contains(item.key))
  15738. {
  15739. hideRowsList.Add(item.index);
  15740. }
  15741. }
  15742. #endregion
  15743. foreach (var Rowindex in hideRowsList)
  15744. {
  15745. ws.Cells.HideRows(Rowindex, 2);
  15746. }
  15747. ws = designer.Workbook.Worksheets[0];
  15748. foreach (var Column in hideColumnList)
  15749. {
  15750. ws.Cells.HideColumns(Column, 1);
  15751. }
  15752. byte[] bytes = null;
  15753. string strFileName = di.TeamName + "-团组-成本.xls";
  15754. using (MemoryStream stream = new MemoryStream())
  15755. {
  15756. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15757. bytes = stream.ToArray();
  15758. }
  15759. return Ok(JsonView(true, "", new
  15760. {
  15761. Data = bytes,
  15762. strFileName,
  15763. }));
  15764. }
  15765. /// <summary>
  15766. /// 导出客户报表
  15767. /// </summary>
  15768. /// <returns></returns>
  15769. [HttpPost]
  15770. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15771. {
  15772. var jw = JsonView(false);
  15773. if (dto.Diid == 0)
  15774. {
  15775. return Ok(JsonView(false, "请传递团组id"));
  15776. }
  15777. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15778. if (deleInfo.Code != 0)
  15779. {
  15780. return Ok(JsonView(false, "团组信息查询失败!"));
  15781. }
  15782. var di = deleInfo.Data as DelegationInfoWebView;
  15783. if (di == null)
  15784. {
  15785. return Ok(JsonView(false, "团组信息查询失败!"));
  15786. }
  15787. //文件名
  15788. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15789. //获取模板
  15790. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15791. //载入模板
  15792. Document doc = new Document(tmppath);
  15793. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15794. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15795. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15796. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15797. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15798. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15799. if (AParameter == null)
  15800. {
  15801. return Ok(JsonView(false, "系数不存在!"));
  15802. }
  15803. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15804. , TzAirDesc, TzZCost;
  15805. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15806. = TzAirDesc = TzZCost = string.Empty;
  15807. TzNumber = AParameter.CostTypenumber.ToString();
  15808. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15809. CarGuides1 = dto.CarGuides1;
  15810. Meal = dto.Meal;
  15811. SubsidizedMeals = dto.SubsidizedMeals;
  15812. NightRepair = dto.NightRepair;
  15813. AttractionsTickets = dto.AttractionsTickets;
  15814. MiscellaneousFees = dto.MiscellaneousFees;
  15815. ATip = dto.ATip;
  15816. TzHotelDesc = "";
  15817. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15818. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15819. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15820. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15821. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15822. TzAirDesc = "";
  15823. TzZCost = dto.TzZCost;
  15824. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15825. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15826. var index = 1;
  15827. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15828. foreach (var item in TzHotelDescArr)
  15829. {
  15830. if (AinfoArr != null)
  15831. {
  15832. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15833. if (Ainfo != null)
  15834. {
  15835. if (int.Parse(Ainfo.rs) <= 0)
  15836. {
  15837. continue;
  15838. }
  15839. var hotelText = string.Empty;
  15840. switch (item)
  15841. {
  15842. case "SGR":
  15843. hotelText = "单人间";
  15844. break;
  15845. case "JSES":
  15846. hotelText = "小套房";
  15847. break;
  15848. case "SUITE":
  15849. hotelText = "套房";
  15850. break;
  15851. case "TBR":
  15852. hotelText = "双人间";
  15853. break;
  15854. }
  15855. if (item != "TBR")
  15856. {
  15857. 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";
  15858. }
  15859. else
  15860. {
  15861. 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";
  15862. }
  15863. index++;
  15864. }
  15865. }
  15866. }
  15867. index = 1;
  15868. foreach (var item in TzAirDescArr)
  15869. {
  15870. if (AinfoArr != null)
  15871. {
  15872. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15873. if (Ainfo != null)
  15874. {
  15875. if (int.Parse(Ainfo.rs) <= 0)
  15876. {
  15877. continue;
  15878. }
  15879. 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";
  15880. index++;
  15881. }
  15882. }
  15883. }
  15884. if (dto.costType == "B")
  15885. {
  15886. if (BParameter == null)
  15887. {
  15888. return Ok(JsonView(false, "B段系数不存在!"));
  15889. }
  15890. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15891. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15892. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15893. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15894. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15895. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15896. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15897. foreach (var item in TzHotelDescArr)
  15898. {
  15899. if (AinfoArr != null)
  15900. {
  15901. TzHotelDesc += "B段信息 \r\n";
  15902. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15903. if (Ainfo != null)
  15904. {
  15905. if (int.Parse(Ainfo.rs) <= 0)
  15906. {
  15907. continue;
  15908. }
  15909. var hotelText = string.Empty;
  15910. switch (item)
  15911. {
  15912. case "SGR":
  15913. hotelText = "单人间";
  15914. break;
  15915. case "JSES":
  15916. hotelText = "小套房";
  15917. break;
  15918. case "SUITE":
  15919. hotelText = "套房";
  15920. break;
  15921. case "TBR":
  15922. hotelText = "双人间";
  15923. break;
  15924. }
  15925. if (item != "TBR")
  15926. {
  15927. 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";
  15928. }
  15929. else
  15930. {
  15931. 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";
  15932. }
  15933. index++;
  15934. }
  15935. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15936. }
  15937. }
  15938. index = 1;
  15939. foreach (var item in TzAirDescArr)
  15940. {
  15941. if (AinfoArr != null)
  15942. {
  15943. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15944. if (Ainfo != null)
  15945. {
  15946. if (int.Parse(Ainfo.rs) <= 0)
  15947. {
  15948. continue;
  15949. }
  15950. 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";
  15951. index++;
  15952. }
  15953. }
  15954. }
  15955. }
  15956. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15957. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15958. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15959. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15960. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15961. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15962. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15963. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15964. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15965. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15966. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15967. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15968. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15969. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15970. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15971. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15972. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15973. DickeyValue.Add("TzZCost", TzZCost);
  15974. foreach (var key in DickeyValue.Keys)
  15975. {
  15976. if (doc.Range.Bookmarks[key] != null)
  15977. {
  15978. Bookmark mark = doc.Range.Bookmarks[key];
  15979. mark.Text = DickeyValue[key];
  15980. }
  15981. }
  15982. byte[] bytes = null;
  15983. string strFileName = di.TeamName + "-客户报价.doc";
  15984. using (MemoryStream stream = new MemoryStream())
  15985. {
  15986. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15987. bytes = stream.ToArray();
  15988. }
  15989. return Ok(JsonView(true, "", new
  15990. {
  15991. Data = bytes,
  15992. strFileName,
  15993. }));
  15994. }
  15995. /// <summary>
  15996. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15997. /// </summary>
  15998. /// <param name="dto"></param>
  15999. /// <returns></returns>
  16000. [HttpPost]
  16001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16002. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  16003. {
  16004. try
  16005. {
  16006. #region 参数验证
  16007. if (dto.DiId < 0)
  16008. {
  16009. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  16010. }
  16011. List<int> cTableIds = new List<int>() {
  16012. 76 ,//酒店预订
  16013. 77 ,//行程
  16014. 79 ,//车/导游地接
  16015. 80 ,//签证
  16016. 81 ,//邀请/公务活
  16017. 82 ,//团组客户保险
  16018. 85 ,//机票预订
  16019. 98 ,//其他款项
  16020. 285 ,//收款退还
  16021. 751 ,//酒店早餐
  16022. 1015 // 超支费用
  16023. };
  16024. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  16025. {
  16026. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  16027. }
  16028. #endregion
  16029. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  16030. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  16031. if (_GroupCostParameters.Count <= 0)
  16032. {
  16033. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  16034. }
  16035. if (_GroupCostParameters[0].IsShare == 0)
  16036. {
  16037. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  16038. }
  16039. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16040. //处理date为空问题
  16041. if (_GroupCosts.Count > 0)
  16042. {
  16043. for (int i = 0; i < _GroupCosts.Count; i++)
  16044. {
  16045. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  16046. {
  16047. if (i > 0)
  16048. {
  16049. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  16050. }
  16051. }
  16052. }
  16053. }
  16054. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  16055. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  16056. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  16057. string currCode = "";
  16058. #region currCode 验证
  16059. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16060. if (isInt)
  16061. {
  16062. var currData = currDatas.Find(it => it.Id == intCurrency);
  16063. if (currData != null)
  16064. {
  16065. currCode = currData.Name;
  16066. }
  16067. }
  16068. else
  16069. {
  16070. currCode = _GroupCostParameters[0].Currency.Trim();
  16071. }
  16072. #endregion
  16073. //op,酒店单段模式存储
  16074. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16075. {
  16076. CurrencyCode = currCode,
  16077. Rate = _GroupCostParameters[0].Rate,
  16078. CostType = _GroupCostParameters[0].CostType,
  16079. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16080. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16081. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16082. };
  16083. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16084. if (_GroupCostParameters.Count == 2)
  16085. {
  16086. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16087. }
  16088. foreach (var item in _GroupCostParameters)
  16089. {
  16090. decimal _rate = 1;
  16091. decimal _rate1 = item.Rate;
  16092. decimal _scale = 1;
  16093. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16094. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16095. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16096. //if (userInfo != null)
  16097. //{
  16098. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16099. // {
  16100. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16101. // {
  16102. // _scale = 1.00M;
  16103. // }
  16104. // }
  16105. //}
  16106. #endregion
  16107. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16108. {
  16109. CurrencyCode = currCode,
  16110. Rate = _rate1,
  16111. CostType = item.CostType,
  16112. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16113. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16114. CostTypeNumber = item.CostTypenumber
  16115. };
  16116. if (_GroupCostParameters.Count > 1)
  16117. {
  16118. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16119. }
  16120. else
  16121. {
  16122. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16123. }
  16124. if (dto.CTable == 79)//
  16125. {
  16126. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16127. modulePromptInfo.TotalCost = item.DJCB;
  16128. }
  16129. List<string> costTypes = new List<string>() { "A", "B" };
  16130. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16131. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16132. if (_GroupCostsDuplicates.Count() == 1)
  16133. {
  16134. _GroupCostsTypeData = _GroupCosts;
  16135. }
  16136. else
  16137. {
  16138. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16139. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16140. }
  16141. /*
  16142. * 76 酒店预订
  16143. * 77 行程
  16144. * 79 车/导游地接
  16145. * 80 签证
  16146. * 81 邀请/公务活动
  16147. * 82 团组客户保险
  16148. * 85 机票预订
  16149. * 98 其他款项
  16150. * 285 收款退还
  16151. * 751 酒店早餐
  16152. * 1015 超支费用
  16153. */
  16154. switch (dto.CTable)
  16155. {
  16156. case 76: // 酒店预订
  16157. _ModuleSubPromptInfo.AddRange(
  16158. _GroupCostsTypeData.Select(it => new
  16159. {
  16160. it.DAY,
  16161. it.Date,
  16162. it.ACCON,
  16163. it.ITIN,
  16164. it.SGR,
  16165. it.TBR,
  16166. it.JS_ES,
  16167. it.Suite
  16168. })
  16169. );
  16170. break;
  16171. case 79: // 车/导游地接
  16172. _ModuleSubPromptInfo.AddRange(
  16173. _GroupCostsTypeData.Select(it => new
  16174. {
  16175. Date = it.Date, //日期
  16176. CarFee = it.CarCost * _rate * _scale, //车费用
  16177. CarType = it.CarType, //车型
  16178. DriverFee = it.CFS * _rate * _scale, //司机工资
  16179. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16180. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16181. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16182. GuideFee = it.TGS * _rate * _scale, //导游费用
  16183. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16184. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16185. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16186. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16187. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16188. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16189. Breakfast = it.B * _rate * _scale, //早餐费
  16190. Lunch = it.L * _rate * _scale, //午餐费
  16191. Dinner = it.D * _rate * _scale, //晚餐费
  16192. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16193. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16194. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16195. TicketFee = it.EF * _rate * _scale, //门票费
  16196. TicketRemark = it.EFR, //门票费描述
  16197. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16198. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16199. SpentCash = it.PC * _rate * _scale, //零用金
  16200. LeadersFee = it.TLF * _rate * _scale, //领队费
  16201. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16202. })
  16203. );
  16204. break;
  16205. case 85: // 机票
  16206. List<dynamic> datas = new List<dynamic>();
  16207. datas.Add(
  16208. new
  16209. {
  16210. AirType = "经济舱",
  16211. AirNum = item.JJCRS,
  16212. AirDRCB = item.JJCCB,
  16213. AirZCB = (item.JJCRS * item.JJCCB)
  16214. }
  16215. );
  16216. datas.Add(
  16217. new
  16218. {
  16219. AirType = "公务舱",
  16220. AirNum = item.GWCRS,
  16221. AirDRCB = item.GWCCB,
  16222. AirZCB = (item.GWCRS * item.GWCCB)
  16223. }
  16224. );
  16225. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16226. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16227. modulePromptInfo.Data = new
  16228. {
  16229. airFeeData = datas,
  16230. airInitData = initDatas
  16231. };
  16232. _ModulePromptInfos.Add(modulePromptInfo);
  16233. break;
  16234. default:
  16235. break;
  16236. }
  16237. }
  16238. if (dto.CTable != 85)
  16239. {
  16240. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16241. _ModulePromptInfos.Add(_ModulePromptInfo);
  16242. }
  16243. _view.ModulePromptInfos = _ModulePromptInfos;
  16244. return Ok(JsonView(true, "操作成功!", _view));
  16245. }
  16246. catch (Exception ex)
  16247. {
  16248. return Ok(JsonView(false, ex.Message));
  16249. }
  16250. }
  16251. /// <summary>
  16252. /// 根据黑屏代码重新生成行程
  16253. /// </summary>
  16254. /// <param name="dto"></param>
  16255. /// <returns></returns>
  16256. [HttpPost]
  16257. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16258. {
  16259. var jw = JsonView(false, "Error");
  16260. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16261. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16262. .Select(x => new
  16263. {
  16264. x.Id,
  16265. x.Title
  16266. })
  16267. .ToList();
  16268. if (Create.Any())
  16269. {
  16270. jw.Msg = "获取成功!";
  16271. jw.Code = 200;
  16272. jw.Data = new
  16273. {
  16274. BlackCodeListSelect = Create,
  16275. blackCodeIsTrue = true
  16276. };
  16277. }
  16278. else
  16279. {
  16280. jw.Code = 400;
  16281. jw.Data = new
  16282. {
  16283. BlackCodeListSelect = Create,
  16284. blackCodeIsTrue = false,
  16285. };
  16286. }
  16287. return Ok(jw);
  16288. }
  16289. /// <summary>
  16290. /// 根据黑屏代码Id重新生成行程
  16291. /// </summary>
  16292. /// <param name="dto"></param>
  16293. /// <returns></returns>
  16294. [HttpPost]
  16295. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16296. {
  16297. var jw = JsonView(false, "Error");
  16298. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16299. if (result.Code == 0)
  16300. {
  16301. jw.Msg = "获取成功!";
  16302. jw.Code = 200;
  16303. jw.Data = new
  16304. {
  16305. groupCost = result.Data,
  16306. blackCodeIsTrue = true
  16307. };
  16308. }
  16309. else
  16310. {
  16311. jw.Code = 400;
  16312. jw.Data = new
  16313. {
  16314. groupCost = result.Data,
  16315. blackCodeIsTrue = false,
  16316. };
  16317. }
  16318. return Ok(jw);
  16319. }
  16320. /// <summary>
  16321. /// 成本获取OP历史车费用
  16322. /// </summary>
  16323. /// <param name="dto"></param>
  16324. /// <returns></returns>
  16325. [HttpPost]
  16326. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16327. {
  16328. var jw = JsonView(false);
  16329. try
  16330. {
  16331. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16332. //获取现有所有车的数据
  16333. if (!dto.Param.IsNullOrWhiteSpace())
  16334. {
  16335. string sql = $@"
  16336. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16337. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16338. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16339. 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
  16340. AND gctggr.ServiceEndTime is not NULL
  16341. ORDER by gctggrc.id DESC
  16342. ";
  16343. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16344. var numeberResult = await Task.Run(() =>
  16345. {
  16346. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16347. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16348. return numberArr;
  16349. });
  16350. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16351. foreach (var item in numeberResult)
  16352. {
  16353. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16354. {
  16355. Country = "数据异常!",
  16356. City = string.Empty,
  16357. };
  16358. item.Area = find.Country + " " + find.City;
  16359. }
  16360. dbResult.AddRange(numeberResult);
  16361. if (dto.Param.Contains("、"))
  16362. {
  16363. var sp = dto.Param.Split("、");
  16364. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16365. .Where(x =>
  16366. {
  16367. return System.Array.Exists(sp, e =>
  16368. {
  16369. bool where = false;
  16370. if (x.Area != null)
  16371. {
  16372. where = x.Area.Contains(e);
  16373. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16374. {
  16375. return false;
  16376. }
  16377. }
  16378. if (x.PriceName != null && !where)
  16379. {
  16380. where = x.PriceName.Contains(e);
  16381. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16382. {
  16383. return false;
  16384. }
  16385. }
  16386. return where;
  16387. });
  16388. }).ToList();
  16389. }
  16390. else
  16391. {
  16392. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16393. .Where(x =>
  16394. {
  16395. bool where = false;
  16396. if (x.Area != null)
  16397. {
  16398. where = x.Area.Contains(dto.Param);
  16399. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16400. {
  16401. return false;
  16402. }
  16403. }
  16404. if (x.PriceName != null && !where)
  16405. {
  16406. where = x.PriceName.Contains(dto.Param);
  16407. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16408. {
  16409. return false;
  16410. }
  16411. }
  16412. return where;
  16413. }
  16414. )
  16415. .ToList();
  16416. }
  16417. }
  16418. var view = dbResult.Select(x =>
  16419. {
  16420. decimal dp = 0.00M;
  16421. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16422. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16423. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16424. {
  16425. if (startB && endB)
  16426. {
  16427. var timesp = endD.Subtract(startD);
  16428. if ((timesp.Days + 1) != 0)
  16429. {
  16430. dp = x.Price / (timesp.Days + 1);
  16431. }
  16432. }
  16433. }
  16434. else
  16435. {
  16436. dp = x.Price;
  16437. }
  16438. return new
  16439. {
  16440. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16441. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16442. x.Area,
  16443. x.id,
  16444. price = x.Price.ToString("F2"),
  16445. x.PriceName,
  16446. x.PriceContent,
  16447. x.TeamName,
  16448. x.DatePrice,
  16449. dayPrice = dp.ToString("F2"),
  16450. };
  16451. }).OrderByDescending(x => x.id).ToList();
  16452. jw = JsonView(true, "获取成功!", view);
  16453. }
  16454. catch (Exception e)
  16455. {
  16456. jw = JsonView(false, e.Message);
  16457. }
  16458. return Ok(jw);
  16459. }
  16460. [HttpPost]
  16461. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16462. {
  16463. var jw = JsonView(true);
  16464. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16465. #region SQL语句
  16466. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16467. //{
  16468. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16469. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16470. // WHEN COUNT(*) >= 0 THEN 'True'
  16471. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16472. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16473. // ")
  16474. // .ToList();
  16475. //}
  16476. //else
  16477. //{
  16478. // string likeKey = string.Empty;
  16479. // foreach (var item in dto.Keyword)
  16480. // {
  16481. // likeKey += "%" + item;
  16482. // }
  16483. // likeKey += "%";
  16484. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16485. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16486. // WHEN COUNT(*) >= 0 THEN 'True'
  16487. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16488. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16489. // ")
  16490. // .ToList();
  16491. //}
  16492. #endregion
  16493. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16494. {
  16495. @KeyWord = dto.Keyword
  16496. });
  16497. if (table != null && table.Rows.Count > 0)
  16498. {
  16499. foreach (DataRow row in table.Rows)
  16500. {
  16501. matches.Add(new DelegationInfoAndIsTrueView
  16502. {
  16503. Id = row.Field<int>("Id"),
  16504. GroupName = row.Field<string>("GroupName"),
  16505. isTrue = row.Field<string>("isTrue")
  16506. });
  16507. }
  16508. }
  16509. if (matches.Any())
  16510. {
  16511. jw.Data = matches;
  16512. }
  16513. else
  16514. {
  16515. jw.Code = 201;
  16516. jw.Msg = "empty list";
  16517. jw.Data = new List<string>(1);
  16518. }
  16519. return Ok(jw);
  16520. }
  16521. /// <summary>
  16522. /// 报价Word下载
  16523. /// </summary>
  16524. /// <param name="dto"></param>
  16525. /// <returns></returns>
  16526. [HttpPost]
  16527. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16528. {
  16529. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16530. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16531. if (di == null)
  16532. {
  16533. return Ok(JsonView(false, "团组不存在!"));
  16534. }
  16535. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16536. if (mainPrice == null || mainPrice.IsShare == 0)
  16537. {
  16538. return Ok(JsonView(false, "团组成本不存在!"));
  16539. }
  16540. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16541. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16542. if (costTypeHotelNumbers == null)
  16543. {
  16544. return Ok(JsonView(false, "团组成本不存在!"));
  16545. }
  16546. //文件名
  16547. string strFileName = di.TeamName + "-收款账单.doc";
  16548. //获取模板
  16549. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16550. //载入模板
  16551. Document doc = new Document(tmppath);
  16552. decimal allPrice = 0.00M;
  16553. string itemStr = string.Empty;
  16554. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16555. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16556. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16557. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16558. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16559. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16560. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16561. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16562. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16563. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16564. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16565. {
  16566. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16567. ("BXRS", "BXCB", "BXXS", "bx"),
  16568. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16569. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16570. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16571. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16572. ("CPRS", "CPCB", "CPXS", "cp"),
  16573. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16574. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16575. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16576. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16577. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16578. ("DJRS", "DJCB", "DJXS", "dj"),
  16579. ("GWRS", "GWCB", "GWXS", "gw"),
  16580. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16581. };
  16582. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16583. var rightSum = 0.00M;
  16584. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16585. {
  16586. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16587. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16588. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16589. if (prefix == "tbr")
  16590. {
  16591. rsValue *= 2;
  16592. cbValue /= 2;
  16593. }
  16594. if (OtherCostPropertyBJ.Contains(prefix))
  16595. {
  16596. rightSum += cbValue * xsValue;
  16597. }
  16598. }
  16599. var hotelRooms = new Dictionary<string, int>
  16600. {
  16601. { "SGR", costTypeHotelNumbers.SGR },
  16602. { "TBR", costTypeHotelNumbers.TBR },
  16603. { "JSES", costTypeHotelNumbers.JSES },
  16604. { "SUITE", costTypeHotelNumbers.SUITE }
  16605. };
  16606. var flights = new Dictionary<string, int>
  16607. {
  16608. { "经济舱", mainPrice.JJCRS },
  16609. { "公务舱", mainPrice.GWCRS },
  16610. { "头等舱", mainPrice.TDCRS }
  16611. };
  16612. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16613. {
  16614. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16615. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16616. { "头等舱", new[] { "SUITE", "JSES" } }
  16617. };
  16618. var result = new Dictionary<string, int>();
  16619. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16620. foreach (var flight in flights.Keys)
  16621. {
  16622. // 获取当前舱位的匹配规则
  16623. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16624. {
  16625. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16626. }
  16627. }
  16628. #region right计算
  16629. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16630. {
  16631. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16632. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16633. airHotelPriceList.Add(new
  16634. AirHotelPrice
  16635. {
  16636. Name = "经济舱TBR",
  16637. Price = rightSum + air + hotel,
  16638. Count = result["经济舱TBR"] * 2
  16639. });
  16640. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16641. }
  16642. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16643. {
  16644. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16645. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16646. airHotelPriceList.Add(new
  16647. AirHotelPrice
  16648. {
  16649. Name = "经济舱SGR",
  16650. Price = rightSum + air + hotel,
  16651. Count = result["经济舱SGR"]
  16652. });
  16653. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16654. }
  16655. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16656. {
  16657. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16658. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16659. airHotelPriceList.Add(new
  16660. AirHotelPrice
  16661. {
  16662. Name = "公务舱SGR",
  16663. Price = rightSum + air + hotel,
  16664. Count = result["公务舱SGR"]
  16665. });
  16666. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16667. }
  16668. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16669. {
  16670. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16671. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16672. airHotelPriceList.Add(new
  16673. AirHotelPrice
  16674. {
  16675. Name = "公务舱JSES",
  16676. Price = rightSum + air + hotel,
  16677. Count = result["公务舱JSES"]
  16678. });
  16679. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16680. }
  16681. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16682. {
  16683. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16684. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16685. airHotelPriceList.Add(new
  16686. AirHotelPrice
  16687. {
  16688. Name = "公务舱SUITE",
  16689. Price = rightSum + air + hotel,
  16690. Count = result["公务舱SUITE"]
  16691. });
  16692. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16693. }
  16694. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16695. {
  16696. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16697. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16698. airHotelPriceList.Add(new
  16699. AirHotelPrice
  16700. {
  16701. Name = "经济舱SUITE",
  16702. Price = rightSum + air + hotel,
  16703. Count = result["经济舱SUITE"]
  16704. });
  16705. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16706. }
  16707. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16708. {
  16709. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16710. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16711. airHotelPriceList.Add(new
  16712. AirHotelPrice
  16713. {
  16714. Name = "头等舱JSES",
  16715. Price = rightSum + air + hotel,
  16716. Count = result["头等舱JSES"]
  16717. });
  16718. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16719. }
  16720. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16721. {
  16722. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16723. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16724. airHotelPriceList.Add(new
  16725. AirHotelPrice
  16726. {
  16727. Name = "头等舱SUITE",
  16728. Price = rightSum + air + hotel,
  16729. Count = result["头等舱SUITE"]
  16730. });
  16731. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16732. }
  16733. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16734. {
  16735. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16736. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16737. airHotelPriceList.Add(new
  16738. AirHotelPrice
  16739. {
  16740. Name = "经济舱JSES",
  16741. Price = rightSum + air + hotel,
  16742. Count = result["经济舱JSES"]
  16743. });
  16744. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16745. }
  16746. #endregion
  16747. foreach (var item in airSouer.Keys)
  16748. {
  16749. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16750. if (find != null && find.Count > 0)
  16751. {
  16752. if (item.Contains("TBR"))
  16753. {
  16754. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16755. }
  16756. else
  16757. {
  16758. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16759. }
  16760. }
  16761. }
  16762. #region 替换Word模板书签内容
  16763. Dictionary<string, string> marks = new Dictionary<string, string>();
  16764. marks.Add("To", di.ClientUnit);//付款方
  16765. marks.Add("ToTel", di.TellPhone);//付款方电话
  16766. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16767. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16768. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16769. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16770. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16771. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16772. marks.Add("PayItemContent", itemStr);//详细信息
  16773. marks.Add("Total", allPrice.ToString("F2"));//合计
  16774. #endregion
  16775. foreach (var item in marks.Keys)
  16776. {
  16777. if (doc.Range.Bookmarks[item] != null)
  16778. {
  16779. Bookmark mark = doc.Range.Bookmarks[item];
  16780. mark.Text = marks[item];
  16781. }
  16782. }
  16783. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16784. doc.Save(savePaht);
  16785. var jw = new JsonView();
  16786. jw.Msg = "生成成功!";
  16787. jw.Code = 200;
  16788. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16789. return Ok(jw);
  16790. }
  16791. /// <summary>
  16792. /// 详细报价费用Excel下载
  16793. /// </summary>
  16794. /// <param name="dto"></param>
  16795. /// <returns></returns>
  16796. [HttpPost]
  16797. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16798. {
  16799. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16800. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16801. if (di == null)
  16802. {
  16803. return Ok(JsonView(false, "团组不存在!"));
  16804. }
  16805. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16806. if (mainPrice == null || mainPrice.IsShare == 0)
  16807. {
  16808. return Ok(JsonView(false, "团组成本不存在!"));
  16809. }
  16810. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16811. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16812. if (costTypeHotelNumbers == null)
  16813. {
  16814. return Ok(JsonView(false, "团组成本不存在!"));
  16815. }
  16816. WorkbookDesigner designer = new WorkbookDesigner();
  16817. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16818. List<int> hideRowsList = new List<int>();
  16819. int conterStartIndex = 3;
  16820. int rowIndex = conterStartIndex;
  16821. designer.SetDataSource("GroupName", di.TeamName);
  16822. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16823. {
  16824. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16825. ("BXRS", "BXCB", "BXXS", "bx"),
  16826. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16827. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16828. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16829. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16830. ("CPRS", "CPCB", "CPXS", "cp") ,
  16831. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16832. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16833. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16834. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16835. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16836. ("DJRS", "DJCB", "DJXS", "dj") ,
  16837. ("GWRS", "GWCB", "GWXS", "gw") ,
  16838. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16839. };
  16840. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16841. var rightSum = 0.00M;
  16842. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16843. {
  16844. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16845. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16846. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16847. if (prefix == "tbr")
  16848. {
  16849. rsValue *= 2;
  16850. cbValue /= 2;
  16851. }
  16852. if (OtherCostPropertyBJ.Contains(prefix))
  16853. {
  16854. rightSum += cbValue * xsValue;
  16855. }
  16856. if (rsValue == 0)
  16857. {
  16858. hideRowsList.Add(rowIndex);
  16859. }
  16860. else
  16861. {
  16862. designer.SetDataSource($"{prefix}rs", rsValue);
  16863. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16864. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16865. }
  16866. rowIndex += 2;
  16867. }
  16868. var hotelRooms = new Dictionary<string, int>
  16869. {
  16870. { "SGR", costTypeHotelNumbers.SGR },
  16871. { "TBR", costTypeHotelNumbers.TBR },
  16872. { "JSES", costTypeHotelNumbers.JSES },
  16873. { "SUITE", costTypeHotelNumbers.SUITE }
  16874. };
  16875. var flights = new Dictionary<string, int>
  16876. {
  16877. { "经济舱", mainPrice.JJCRS },
  16878. { "公务舱", mainPrice.GWCRS },
  16879. { "头等舱", mainPrice.TDCRS }
  16880. };
  16881. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16882. {
  16883. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16884. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16885. { "头等舱", new[] { "SUITE", "JSES" } }
  16886. };
  16887. var result = new Dictionary<string, int>();
  16888. foreach (var flight in flights.Keys)
  16889. {
  16890. // 获取当前舱位的匹配规则
  16891. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16892. {
  16893. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16894. }
  16895. }
  16896. var allPrice = 0.00M;
  16897. #region right计算
  16898. int airRowIndex = 35;
  16899. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16900. {
  16901. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16902. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16903. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16904. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16905. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16906. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16907. }
  16908. else
  16909. {
  16910. hideRowsList.Add(airRowIndex);
  16911. }
  16912. airRowIndex += 2;
  16913. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16914. {
  16915. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16916. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16917. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16918. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16919. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16920. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16921. }
  16922. else
  16923. {
  16924. hideRowsList.Add(airRowIndex);
  16925. }
  16926. airRowIndex += 2;
  16927. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16928. {
  16929. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16930. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16931. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16932. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16933. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16934. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16935. }
  16936. else
  16937. {
  16938. hideRowsList.Add(airRowIndex);
  16939. }
  16940. airRowIndex += 2;
  16941. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16942. {
  16943. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16944. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16945. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16946. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16947. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16948. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16949. }
  16950. else
  16951. {
  16952. hideRowsList.Add(airRowIndex);
  16953. }
  16954. airRowIndex += 2;
  16955. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16956. {
  16957. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16958. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16959. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16960. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16961. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16962. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16963. }
  16964. else
  16965. {
  16966. hideRowsList.Add(airRowIndex);
  16967. }
  16968. airRowIndex += 2;
  16969. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16970. {
  16971. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16972. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16973. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16974. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16975. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16976. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16977. }
  16978. else
  16979. {
  16980. hideRowsList.Add(airRowIndex);
  16981. }
  16982. airRowIndex += 2;
  16983. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16984. {
  16985. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16986. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16987. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16988. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16989. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16990. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16991. }
  16992. else
  16993. {
  16994. hideRowsList.Add(airRowIndex);
  16995. }
  16996. airRowIndex += 2;
  16997. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16998. {
  16999. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17000. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17001. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  17002. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  17003. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  17004. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17005. }
  17006. else
  17007. {
  17008. hideRowsList.Add(airRowIndex);
  17009. }
  17010. airRowIndex += 2;
  17011. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17012. {
  17013. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17014. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17015. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  17016. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  17017. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  17018. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17019. }
  17020. else
  17021. {
  17022. hideRowsList.Add(airRowIndex);
  17023. }
  17024. #endregion
  17025. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  17026. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  17027. var ws = designer.Workbook.Worksheets[0];
  17028. foreach (var Rowindex in hideRowsList)
  17029. {
  17030. ws.Cells.HideRows(Rowindex, 2);
  17031. }
  17032. designer.Process();
  17033. designer.Workbook.Save(savePaht);
  17034. return Ok(JsonView(true, "生成成功!", new
  17035. {
  17036. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  17037. }));
  17038. }
  17039. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  17040. {
  17041. foreach (var roomType in roomTypes)
  17042. {
  17043. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  17044. {
  17045. hotelRooms[roomType]--;
  17046. flights[flightType]--;
  17047. if (roomType == "TBR")
  17048. {
  17049. flights[flightType]--; // 双人间在减少1
  17050. }
  17051. string key = flightType + roomType;
  17052. if (result.Keys.Contains(key))
  17053. {
  17054. result[key]++;
  17055. }
  17056. else
  17057. {
  17058. result.Add(key, 1);
  17059. }
  17060. }
  17061. }
  17062. }
  17063. private class AirHotelPrice
  17064. {
  17065. public string Name { get; set; }
  17066. public decimal Price { get; set; }
  17067. public int Count { get; set; }
  17068. }
  17069. /// <summary>
  17070. /// 团组系数设置
  17071. /// </summary>
  17072. /// <param name="dto"></param>
  17073. /// <returns></returns>
  17074. [HttpPost]
  17075. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17076. {
  17077. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17078. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17079. if (di == null)
  17080. {
  17081. return Ok(JsonView(false, "团组不存在!"));
  17082. }
  17083. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  17084. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  17085. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  17086. // FirstAsync(firstExpression.ToExpression());
  17087. #region JSON
  17088. string hcpJson = @"
  17089. [
  17090. {
  17091. ""min"": 1,
  17092. ""max"": 500,
  17093. ""value"": 1.50
  17094. },
  17095. {
  17096. ""min"": 501,
  17097. ""max"": 1000,
  17098. ""value"": 1.40
  17099. },
  17100. {
  17101. ""min"": 1001,
  17102. ""max"": 2000,
  17103. ""value"": 1.35
  17104. }
  17105. ]";
  17106. #endregion
  17107. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  17108. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  17109. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  17110. .ToList();
  17111. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  17112. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  17113. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  17114. // new List<(Predicate<decimal>, decimal)>()
  17115. // {
  17116. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  17117. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  17118. // }
  17119. // ));
  17120. #region 签证系数
  17121. var visaXS = 0.00M;
  17122. switch (dto.VisaCB)
  17123. {
  17124. case decimal n when (n > 1 && n < 500):
  17125. switch (dto.VisaRS)
  17126. {
  17127. case 2 or 3:
  17128. visaXS = 1.35M;
  17129. break;
  17130. case 4 or 5:
  17131. visaXS = 1.30M;
  17132. break;
  17133. case 6 or 7:
  17134. visaXS = 1.25M;
  17135. break;
  17136. case 8 or 9 or 10:
  17137. visaXS = 1.20M;
  17138. break;
  17139. case > 10:
  17140. visaXS = 1.15M;
  17141. break;
  17142. default:
  17143. visaXS = 0.00M;
  17144. break;
  17145. }
  17146. break;
  17147. case decimal n when (n >= 500 && n < 1000):
  17148. switch (dto.VisaRS)
  17149. {
  17150. case 2 or 3 or 4:
  17151. visaXS = 1.30M;
  17152. break;
  17153. case 5 or 6 or 7 or 8:
  17154. visaXS = 1.25M;
  17155. break;
  17156. case 9 or 10:
  17157. visaXS = 1.20M;
  17158. break;
  17159. case > 10:
  17160. visaXS = 1.15M;
  17161. break;
  17162. default:
  17163. visaXS = 0.00M;
  17164. break;
  17165. }
  17166. break;
  17167. default:
  17168. switch (dto.VisaRS)
  17169. {
  17170. case 2 or 3 or 4:
  17171. visaXS = 1.30M;
  17172. break;
  17173. case 5 or 6 or 7 or 8:
  17174. visaXS = 1.25M;
  17175. break;
  17176. case 9 or 10:
  17177. visaXS = 1.20M;
  17178. break;
  17179. case > 10:
  17180. visaXS = 1.15M;
  17181. break;
  17182. default:
  17183. visaXS = 0.00M;
  17184. break;
  17185. }
  17186. break;
  17187. }
  17188. #endregion
  17189. #region 火车系数
  17190. var hcpXS = 0.00M;
  17191. foreach (var (condition, result) in hcpSwitchDictionary)
  17192. {
  17193. if (condition(dto.HCPCB))
  17194. {
  17195. hcpXS = result;
  17196. break;
  17197. }
  17198. }
  17199. #endregion
  17200. #region 机票系数
  17201. #region 经济舱系数
  17202. var jjcXS = 0.00M;
  17203. switch (dto.JJCCB)
  17204. {
  17205. case decimal x when (x >= 1000 && x <= 3000):
  17206. jjcXS = 2.6M;
  17207. break;
  17208. case decimal x when (x >= 3001 && x <= 8000):
  17209. jjcXS = 2.3M;
  17210. break;
  17211. case decimal x when (x >= 8001 && x <= 15000):
  17212. jjcXS = 2.1M;
  17213. break;
  17214. case decimal x when (x >= 15001 && x <= 30000):
  17215. jjcXS = 1.95M;
  17216. break;
  17217. case > 30000:
  17218. jjcXS = 1.8M;
  17219. break;
  17220. default:
  17221. break;
  17222. }
  17223. #endregion
  17224. #region 公务舱系数
  17225. var gwcXS = 0.00M;
  17226. switch (dto.GWCCB)
  17227. {
  17228. case decimal x when (x >= 1000 && x <= 3000):
  17229. gwcXS = 2.5M;
  17230. break;
  17231. case decimal x when (x >= 3001 && x <= 8000):
  17232. gwcXS = 2.2M;
  17233. break;
  17234. case decimal x when (x >= 8001 && x <= 15000):
  17235. gwcXS = 2.0M;
  17236. break;
  17237. case decimal x when (x >= 15001 && x <= 30000):
  17238. gwcXS = 1.85M;
  17239. break;
  17240. case > 30000:
  17241. gwcXS = 1.7M;
  17242. break;
  17243. default:
  17244. break;
  17245. }
  17246. #endregion
  17247. #region 头等舱系数
  17248. var tdcXS = 0.00M;
  17249. switch (dto.TDCCB)
  17250. {
  17251. case > 70000:
  17252. tdcXS = 1.5M;
  17253. break;
  17254. default:
  17255. tdcXS = 1.9M;
  17256. break;
  17257. }
  17258. #endregion
  17259. #endregion
  17260. #region 酒店系数
  17261. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  17262. {
  17263. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  17264. {1.5M, new List<string>(){"越南社会主义共和国",
  17265. "老挝",
  17266. "柬埔寨",
  17267. "泰国",
  17268. "缅甸",
  17269. "马来西亚",
  17270. //"新加坡",
  17271. "文莱达鲁萨兰",
  17272. "印度尼西亚",
  17273. "东帝汶"}},
  17274. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  17275. };
  17276. #region SGR
  17277. var sgrXS = 1.25M;
  17278. #endregion
  17279. #region TBR
  17280. var tbrXS = 1.25M;
  17281. #endregion
  17282. #region JSES
  17283. var jsesXS = 1.25M;
  17284. #endregion
  17285. #region SUITE
  17286. var suiteXS = 1.25M;
  17287. #endregion
  17288. var countryArr = di.VisitCountry.Split("|");
  17289. foreach (var item in dic)
  17290. {
  17291. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  17292. .Count();
  17293. if (extsisCount > 0)
  17294. {
  17295. jsesXS = item.Key;
  17296. sgrXS = item.Key;
  17297. tbrXS = item.Key;
  17298. suiteXS = item.Key;
  17299. }
  17300. }
  17301. #endregion
  17302. #region 地接系数
  17303. var djXS = 0.00M;
  17304. switch (dto.DJRS)
  17305. {
  17306. case 2 or 3 :
  17307. djXS = 2.65M;
  17308. break;
  17309. case 4:
  17310. djXS = 2.6M;
  17311. break;
  17312. case 5 or 6:
  17313. djXS = 2.5M;
  17314. break;
  17315. case 7 or 8:
  17316. djXS = 2.4M;
  17317. break;
  17318. case 9 or 10:
  17319. djXS = 2.3M;
  17320. break;
  17321. case 11:
  17322. djXS = 2.2M;
  17323. break;
  17324. case 12:
  17325. djXS = 2.1M;
  17326. break;
  17327. case 13 or 14:
  17328. djXS = 2M;
  17329. break;
  17330. case 15:
  17331. djXS = 1.9M;
  17332. break;
  17333. case 16 or 17 or 18:
  17334. djXS = 1.8M;
  17335. break;
  17336. case 19 or 20:
  17337. djXS = 1.7M;
  17338. break;
  17339. }
  17340. #endregion
  17341. #region 零用金系数
  17342. var lyjXS = 0.00M;
  17343. switch (dto.LYJRS)
  17344. {
  17345. case 2:
  17346. lyjXS = 1.25M;
  17347. break;
  17348. case 3 or 4 or 5:
  17349. lyjXS = 1.2M;
  17350. break;
  17351. case int number when (number > 5 && number < 10):
  17352. lyjXS = 1.15M;
  17353. break;
  17354. case > 10:
  17355. lyjXS = 1.1M;
  17356. break;
  17357. default:
  17358. break;
  17359. }
  17360. #endregion
  17361. return Ok(JsonView(true, "查询成功", new ArrayList()
  17362. {
  17363. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  17364. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  17365. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  17366. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  17367. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  17368. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  17369. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  17370. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  17371. new { label = "地接系数", value = djXS, key = "djXS" },
  17372. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  17373. new { label = "公务系数", value = 2M, key = "gwXS" }
  17374. }));
  17375. }
  17376. #endregion
  17377. #region 酒店预订 New 2023-12-28 17:45
  17378. /// <summary>
  17379. /// 酒店预订
  17380. /// 酒店费用列表 根据团组Id查询
  17381. /// </summary>
  17382. /// <param name="_dto"></param>
  17383. /// <returns></returns>
  17384. [HttpPost]
  17385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17386. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17387. {
  17388. #region 参数验证
  17389. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17390. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17391. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17392. #region 团组操作权限验证 76 酒店预定模块
  17393. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17394. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17395. #endregion
  17396. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17397. #region 页面操作权限验证
  17398. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17399. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17400. #endregion
  17401. #endregion
  17402. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17403. }
  17404. /// <summary>
  17405. /// 酒店预订
  17406. /// 基础数据
  17407. /// </summary>
  17408. /// <param name="_dto"></param>
  17409. /// <returns></returns>
  17410. [HttpPost]
  17411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17412. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17413. {
  17414. #region 参数验证
  17415. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17416. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17417. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17418. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17419. #region 页面操作权限验证
  17420. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17421. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17422. #endregion
  17423. #region 团组操作权限验证 76 酒店预定模块
  17424. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17425. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17426. #endregion
  17427. #endregion
  17428. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17429. }
  17430. /// <summary>
  17431. /// 酒店预订
  17432. /// 创建 入住卷号码
  17433. /// </summary>
  17434. /// <param name="_dto"></param>
  17435. /// <returns></returns>
  17436. [HttpPost]
  17437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17438. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17439. {
  17440. #region 参数验证
  17441. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17442. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17443. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17444. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17445. #region 页面操作权限验证
  17446. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17447. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17448. #endregion
  17449. #region 团组操作权限验证 76 酒店预定模块
  17450. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17451. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17452. #endregion
  17453. #endregion
  17454. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17455. if (data.Code != 0)
  17456. {
  17457. return Ok(JsonView(false, data.Msg));
  17458. }
  17459. return Ok(JsonView(true, data.Msg, data.Data));
  17460. }
  17461. /// <summary>
  17462. /// 酒店预订
  17463. /// 详情
  17464. /// </summary>
  17465. /// <param name="_dto"></param>
  17466. /// <returns></returns>
  17467. [HttpPost]
  17468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17469. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17470. {
  17471. #region 参数验证
  17472. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17473. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17474. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17475. #region 团组操作权限验证 76 酒店预定模块
  17476. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17477. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17478. #endregion
  17479. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17480. #region 页面操作权限验证
  17481. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17482. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17483. #endregion
  17484. #endregion
  17485. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17486. }
  17487. /// <summary>
  17488. /// 酒店预订
  17489. /// Add Or Edit
  17490. /// </summary>
  17491. /// <param name="_dto"></param>
  17492. /// <returns></returns>
  17493. [HttpPost]
  17494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17495. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17496. {
  17497. #region 参数验证
  17498. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17499. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17500. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17501. #region 团组操作权限验证 76 酒店预定模块
  17502. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17503. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17504. #endregion
  17505. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17506. #region 页面操作权限验证
  17507. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17508. if (_dto.Id == 0) // Add
  17509. {
  17510. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17511. }
  17512. else if (_dto.Id > 1) // Edit
  17513. {
  17514. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17515. }
  17516. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17517. #endregion
  17518. #endregion
  17519. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17520. if (_view.Code != 200)
  17521. {
  17522. return Ok(_view);
  17523. }
  17524. #region 成本无酒店价格数据进入超支
  17525. _sqlSugar.BeginTran();
  17526. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17527. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17528. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17529. for (int i = 0; i < groupCost.Count; i++)
  17530. {
  17531. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17532. {
  17533. groupCost[i].Date = groupCost[i - 1].Date;
  17534. }
  17535. }
  17536. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17537. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17538. List<Fin_GroupExtraCostDto_OP>();
  17539. if (start_Bool && end_Bool)
  17540. {
  17541. while (start_Time < end_Time)
  17542. {
  17543. foreach (var item in groupCost_Grp)
  17544. {
  17545. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17546. {
  17547. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17548. {
  17549. extraCostList.Add(new
  17550. Fin_GroupExtraCostDto_OP
  17551. {
  17552. Area = _dto.AreaId,
  17553. coefficient = 1.5M,
  17554. createUser = _dto.UserId,
  17555. currency = _dto.CardPriceCurrency,
  17556. diId = _dto.DiId,
  17557. ManagerConfirm = 0,
  17558. SupervisorConfirm = 0,
  17559. SYsupervisorConfirm = 0,
  17560. editType = 1,
  17561. PortType = 1,
  17562. price = _dto.CardPrice,
  17563. PriceCount = 1,
  17564. priceType = 1027,
  17565. priceDetailType = 1044,
  17566. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17567. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17568. });
  17569. }
  17570. }
  17571. }
  17572. start_Time = start_Time.AddDays(1);
  17573. }
  17574. }
  17575. if (extraCostList.Any())
  17576. {
  17577. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17578. }
  17579. _sqlSugar.CommitTran();
  17580. #endregion
  17581. #region 应用推送
  17582. try
  17583. {
  17584. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17585. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17586. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17587. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17588. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17589. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17590. var diId = _dto.DiId;
  17591. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17592. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17593. #region 操作记录
  17594. var opInfo = new Crm_TableOperationRecord()
  17595. {
  17596. TableName = "Grp_HotelReservations",
  17597. PortType = _dto.PortType,
  17598. DataId = hotelId,
  17599. CreateUserId = _dto.UserId
  17600. };
  17601. //var opStatus = OperationEnum.NoOperation;
  17602. if (_dto.Id < 1) //添加操作
  17603. {
  17604. opInfo.OperationItem = OperationEnum.Add;
  17605. }
  17606. else if (_dto.Id > 0)
  17607. {
  17608. opInfo.OperationItem = OperationEnum.Edit;
  17609. }
  17610. string opRemark = string.Empty;
  17611. if (ccpInfo != null)
  17612. {
  17613. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17614. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17615. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17616. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17617. }
  17618. opInfo.Remark = opRemark;
  17619. await _tableorRep.AddAsync(opInfo);
  17620. #endregion
  17621. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17622. //2024-10-21 新增LZ UID
  17623. var userIds = new List<int>() { 21 };
  17624. string title = $"费用审核";
  17625. string content = "";
  17626. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17627. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17628. try
  17629. {
  17630. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17631. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17632. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17633. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17634. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17635. }
  17636. catch (Exception ex)
  17637. {
  17638. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17639. }
  17640. }
  17641. catch (Exception ex)
  17642. {
  17643. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17644. }
  17645. try
  17646. {
  17647. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17648. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17649. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17650. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17651. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17652. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17653. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17654. //自动审核
  17655. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17656. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17657. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17658. //2024-10-21 新增LZ UID
  17659. var userIds = new List<int>() { 21 };
  17660. string title = $"系统通知";
  17661. var diId = _dto.DiId;
  17662. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17663. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17664. string content = "";
  17665. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17666. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17667. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17668. }
  17669. catch (Exception ex)
  17670. {
  17671. }
  17672. #endregion
  17673. return Ok(_view);
  17674. }
  17675. /// <summary>
  17676. /// 酒店自动审核测试
  17677. /// Add Or Edit
  17678. /// </summary>
  17679. /// <param name="diid"></param>
  17680. /// <param name="dataId"></param>
  17681. /// <returns></returns>
  17682. [HttpPost]
  17683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17684. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17685. {
  17686. #region 应用推送
  17687. try
  17688. {
  17689. //自动审核
  17690. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17691. }
  17692. catch (Exception ex)
  17693. {
  17694. return Ok(JsonView(false, ex.Message));
  17695. }
  17696. #endregion
  17697. return Ok(JsonView(false, "操作成功"));
  17698. }
  17699. /// <summary>
  17700. /// 酒店预订
  17701. /// Del
  17702. /// </summary>
  17703. /// <param name="_dto"></param>
  17704. /// <returns></returns>
  17705. [HttpPost]
  17706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17707. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17708. {
  17709. #region 参数验证
  17710. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17711. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17712. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17713. #region 团组操作权限验证 76 酒店预定模块
  17714. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17715. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17716. #endregion
  17717. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17718. #region 页面操作权限验证
  17719. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17720. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17721. #endregion
  17722. #endregion
  17723. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  17724. #region 操作记录
  17725. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17726. {
  17727. TableName = "Grp_HotelReservations",
  17728. PortType = _dto.PortType,
  17729. OperationItem = OperationEnum.Del,
  17730. DataId = _dto.Id,
  17731. CreateUserId = _dto.UserId
  17732. });
  17733. #endregion
  17734. return Ok(data);
  17735. }
  17736. /// <summary>
  17737. /// 酒店预订
  17738. /// 生成VOUCHER
  17739. /// 2024.05.06 之前版本
  17740. /// </summary>
  17741. /// <param name="_dto"></param>
  17742. /// <returns></returns>
  17743. [HttpPost]
  17744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17745. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17746. {
  17747. try
  17748. {
  17749. #region 参数验证
  17750. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17751. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17752. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17753. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17754. #region 团组操作权限验证 76 酒店预定模块
  17755. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17756. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17757. #endregion
  17758. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17759. #region 页面操作权限验证
  17760. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17761. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17762. #endregion
  17763. #endregion
  17764. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17765. //判断数据是否完整
  17766. if (hr != null)
  17767. {
  17768. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17769. {
  17770. string strFileName = "HotelStatement/";
  17771. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17772. if (dele != null)
  17773. strFileName += dele.TourCode;
  17774. //载入模板
  17775. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17776. Document doc = new Document(sss);
  17777. DocumentBuilder builder = new DocumentBuilder(doc);
  17778. #region 替换Word模板书签内容
  17779. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17780. //入住卷预定号码
  17781. if (doc.Range.Bookmarks["VNO"] != null)
  17782. {
  17783. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17784. mark.Text = hr.CheckNumber;
  17785. }
  17786. //酒店时间
  17787. if (doc.Range.Bookmarks["Date"] != null)
  17788. {
  17789. Bookmark mark = doc.Range.Bookmarks["Date"];
  17790. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17791. }
  17792. //团号
  17793. if (doc.Range.Bookmarks["TNo"] != null)
  17794. {
  17795. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17796. mark.Text = dele.TourCode;
  17797. }
  17798. //预定号码
  17799. if (doc.Range.Bookmarks["BookingId"] != null)
  17800. {
  17801. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17802. mark.Text = hr.ReservationsNo;
  17803. }
  17804. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17805. {
  17806. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17807. mark.Text = hr.DetermineNo;
  17808. }
  17809. //酒店城市
  17810. if (doc.Range.Bookmarks["City"] != null)
  17811. {
  17812. Bookmark mark = doc.Range.Bookmarks["City"];
  17813. mark.Text = hr.City;
  17814. }
  17815. //酒店名称
  17816. if (doc.Range.Bookmarks["HName"] != null)
  17817. {
  17818. Bookmark mark = doc.Range.Bookmarks["HName"];
  17819. mark.Text = hr.HotelName;
  17820. }
  17821. //酒店地址
  17822. if (doc.Range.Bookmarks["Address"] != null)
  17823. {
  17824. Bookmark mark = doc.Range.Bookmarks["Address"];
  17825. mark.Text = hr.HotelAddress;
  17826. }
  17827. //酒店电话
  17828. if (doc.Range.Bookmarks["Tel"] != null)
  17829. {
  17830. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17831. mark.Text = hr.HotelTel;
  17832. }
  17833. //酒店传真
  17834. if (doc.Range.Bookmarks["Fax"] != null)
  17835. {
  17836. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17837. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17838. {
  17839. mark.Text = hr.HotelFax;
  17840. }
  17841. }
  17842. //入住时间
  17843. if (doc.Range.Bookmarks["CIn"] != null)
  17844. {
  17845. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17846. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17847. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17848. }
  17849. //退房时间
  17850. if (doc.Range.Bookmarks["COut"] != null)
  17851. {
  17852. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17853. Bookmark mark = doc.Range.Bookmarks["COut"];
  17854. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17855. }
  17856. //客户名称
  17857. if (doc.Range.Bookmarks["GName"] != null)
  17858. {
  17859. string guestName = "";
  17860. string[] clients = Array.Empty<string>();
  17861. if (hr.GuestName.Contains(","))
  17862. {
  17863. clients = hr.GuestName.Split(",");
  17864. }
  17865. else
  17866. {
  17867. clients = new string[] { hr.GuestName };
  17868. }
  17869. List<int> clientIds_int = new List<int>();
  17870. if (clients.Length > 0)
  17871. {
  17872. foreach (var item in clients)
  17873. {
  17874. if (item.IsNumeric())
  17875. {
  17876. clientIds_int.Add(int.Parse(item));
  17877. }
  17878. }
  17879. }
  17880. if (clientIds_int.Count > 0)
  17881. {
  17882. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17883. foreach (var client in _clientDatas)
  17884. {
  17885. //男
  17886. if (client.Sex == 0) guestName += $"Mr.";
  17887. //女
  17888. else if (client.Sex == 1) guestName += $"Ms.";
  17889. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17890. {
  17891. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17892. }
  17893. //guestName += $"{client.Pinyin},";
  17894. }
  17895. if (guestName.Length > 0)
  17896. {
  17897. guestName = guestName.Substring(0, guestName.Length - 1);
  17898. }
  17899. }
  17900. else
  17901. {
  17902. guestName = hr.GuestName;
  17903. }
  17904. Bookmark mark = doc.Range.Bookmarks["GName"];
  17905. mark.Text = guestName;
  17906. }
  17907. //房间介绍
  17908. if (doc.Range.Bookmarks["ROOM"] != null)
  17909. {
  17910. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17911. mark.Text = hr.RoomExplanation;
  17912. }
  17913. //报价描述
  17914. if (doc.Range.Bookmarks["NOTE"] != null)
  17915. {
  17916. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17917. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17918. if (ss != null)
  17919. mark.Text = ss.Name;
  17920. }
  17921. //入住时间
  17922. if (doc.Range.Bookmarks["CheckIn"] != null)
  17923. {
  17924. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17925. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17926. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17927. }
  17928. //退房时间
  17929. if (doc.Range.Bookmarks["CheckOut"] != null)
  17930. {
  17931. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17932. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17933. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17934. }
  17935. //日期
  17936. if (doc.Range.Bookmarks["DT"] != null)
  17937. {
  17938. Bookmark mark = doc.Range.Bookmarks["DT"];
  17939. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17940. }
  17941. //名称
  17942. if (doc.Range.Bookmarks["VName"] != null)
  17943. {
  17944. Bookmark mark = doc.Range.Bookmarks["VName"];
  17945. mark.Text = hr.HotelName;
  17946. }
  17947. //号码
  17948. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17949. {
  17950. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17951. mark.Text = hr.CheckNumber;
  17952. }
  17953. #endregion
  17954. strFileName += "VOUCHER.doc";
  17955. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17956. doc.Save(fileDir);
  17957. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17958. return Ok(JsonView(true, "操作成功!", Url));
  17959. }
  17960. else
  17961. {
  17962. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17963. }
  17964. }
  17965. else
  17966. {
  17967. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17968. }
  17969. }
  17970. catch (Exception ex)
  17971. {
  17972. return Ok(JsonView(false, ex.Message));
  17973. }
  17974. }
  17975. /// <summary>
  17976. /// 酒店预订
  17977. /// 生成VOUCHER
  17978. /// 2024.05.06 之后版本
  17979. /// </summary>
  17980. /// <param name="_dto"></param>
  17981. /// <returns></returns>
  17982. [HttpPost]
  17983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17984. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17985. {
  17986. #region 参数验证
  17987. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17988. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17989. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17990. #region 团组操作权限验证 76 酒店预定模块
  17991. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17992. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17993. #endregion
  17994. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17995. #region 页面操作权限验证
  17996. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17997. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17998. #endregion
  17999. #endregion
  18000. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  18001. //判断数据是否完整
  18002. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18003. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18004. string strFileName = "HotelStatement/";
  18005. string guestNames = ""; //格式Mr.xxx Ms.xxx
  18006. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  18007. #region 数据处理
  18008. List<int> guestIds = new List<int>();
  18009. //int index = 0;
  18010. foreach (var item in hrDtas)
  18011. {
  18012. if (item.GuestName.Contains(","))
  18013. {
  18014. string[] guestIdArr = item.GuestName.Split(',');
  18015. foreach (var guestIdStr in guestIdArr)
  18016. {
  18017. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  18018. if (guestBool)
  18019. {
  18020. guestIds.Add(guestId);
  18021. }
  18022. }
  18023. }
  18024. else guestNames += item.GuestName;
  18025. var voucherInfo = new HotelVoucherInfoView()
  18026. {
  18027. HotelName = item.HotelName,
  18028. CheckInDate = item.CheckInDate,
  18029. CheckOutDate = item.CheckOutDate,
  18030. ConfirmationNumber = item.DetermineNo.Trim(),
  18031. RoomType = item.RoomExplanation
  18032. };
  18033. vouchers.Add(voucherInfo);
  18034. }
  18035. if (guestIds.Count > 0)
  18036. {
  18037. guestIds = guestIds.Distinct().ToList();
  18038. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  18039. if (guestDatas.Count > 0)
  18040. {
  18041. guestNames = "";
  18042. foreach (var guest in guestDatas)
  18043. {
  18044. string guestName = "";
  18045. if (guest.Sex == 0) guestName += @"MR.";
  18046. else if (guest.Sex == 1) guestName += @"MS.";
  18047. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18048. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18049. guestNames += @$"{guestName.Trim()}、";
  18050. }
  18051. if (guestNames.Length > 0)
  18052. {
  18053. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18054. }
  18055. }
  18056. }
  18057. #endregion
  18058. //载入模板
  18059. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  18060. Document doc = new Document(sss);
  18061. DocumentBuilder builder = new DocumentBuilder(doc);
  18062. if (doc.Range.Bookmarks["GuestName"] != null)
  18063. {
  18064. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  18065. mark.Text = guestNames;
  18066. }
  18067. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18068. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  18069. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  18070. for (int i = 1; i <= vouchers.Count; i++)
  18071. {
  18072. HotelVoucherInfoView hviv = vouchers[i - 1];
  18073. builder.MoveToCell(0, i, 0, 0);
  18074. builder.Write(hviv.HotelName);
  18075. builder.MoveToCell(0, i, 1, 0);
  18076. builder.Write(hviv.CheckInDate);
  18077. builder.MoveToCell(0, i, 2, 0);
  18078. builder.Write(hviv.CheckOutDate);
  18079. builder.MoveToCell(0, i, 3, 0);
  18080. builder.Write(hviv.RoomType);
  18081. builder.MoveToCell(0, i, 4, 0);
  18082. builder.Write(hviv.ConfirmationNumber);
  18083. }
  18084. //删除多余行
  18085. int currRowIndex = vouchers.Count + 1;
  18086. int delRows = 21 - currRowIndex;
  18087. if (delRows > 0)
  18088. {
  18089. for (int i = 0; i < delRows; i++)
  18090. {
  18091. table.Rows.RemoveAt(currRowIndex);
  18092. //cultivateRowIndex++;
  18093. }
  18094. }
  18095. strFileName += "VOUCHER.docx";
  18096. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18097. doc.Save(fileDir);
  18098. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18099. return Ok(JsonView(true, "操作成功!", Url));
  18100. }
  18101. /// <summary>
  18102. /// 酒店预订
  18103. /// 生成VOUCHER 批量生成
  18104. /// New
  18105. /// </summary>
  18106. /// <param name="_dto"></param>
  18107. /// <returns></returns>
  18108. [HttpPost]
  18109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18110. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  18111. {
  18112. #region 参数验证
  18113. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18114. if (_dto.PageId < 1) _dto.PageId = 28;
  18115. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18116. #region 团组操作权限验证 76 酒店预定模块
  18117. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18118. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18119. #endregion
  18120. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18121. #region 页面操作权限验证
  18122. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18123. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18124. #endregion
  18125. #endregion
  18126. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  18127. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  18128. .OrderBy(x => x.CheckInDate)
  18129. .ToListAsync();
  18130. //判断数据是否完整
  18131. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18132. string strFileName = "HotelStatement/";
  18133. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18134. if (dele != null)
  18135. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  18136. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  18137. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  18138. .Where(it => it.IsDel == 0)
  18139. .ToListAsync();
  18140. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  18141. for (int i = 0; i < hrDtas.Count; i++)
  18142. {
  18143. string guestNames = string.Empty;
  18144. List<int> guestIds = new List<int>();
  18145. var item = hrDtas[i];
  18146. //处理客户姓名
  18147. if (item.GuestName.Contains(","))
  18148. {
  18149. string[] guestIdArr = item.GuestName.Split(',');
  18150. foreach (var guestIdStr in guestIdArr)
  18151. if (int.TryParse(guestIdStr, out int guestId))
  18152. guestIds.Add(guestId);
  18153. }
  18154. else
  18155. {
  18156. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  18157. if (guestIdBool)
  18158. {
  18159. guestIds.Add(guestId);
  18160. }
  18161. //NaN
  18162. if (item.GuestName.Contains("NaN"))
  18163. {
  18164. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  18165. }
  18166. }
  18167. if (guestIds.Count > 0)
  18168. {
  18169. guestIds = guestIds.Distinct().ToList();
  18170. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  18171. if (guestDatas1.Count > 0)
  18172. {
  18173. guestNames = "";
  18174. foreach (var guest in guestDatas1)
  18175. {
  18176. string guestName = "";
  18177. if (guest.Sex == 0) guestName += @"MR.";
  18178. else if (guest.Sex == 1) guestName += @"MS.";
  18179. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18180. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18181. guestNames += @$"{guestName.Trim()}、";
  18182. }
  18183. if (guestNames.Length > 0)
  18184. {
  18185. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18186. }
  18187. }
  18188. }
  18189. //if (!string.IsNullOrEmpty(guestNames))
  18190. //{
  18191. hrDtas[i].GuestName = guestNames;
  18192. //}
  18193. }
  18194. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  18195. Document doc = new Document();
  18196. DocumentBuilder builder = new DocumentBuilder(doc);
  18197. try
  18198. {
  18199. builder.MoveToDocumentStart();
  18200. foreach (var item in hrDtas)
  18201. {
  18202. //标题
  18203. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18204. builder.ParagraphFormat.LineSpacing = 1;
  18205. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18206. builder.ParagraphFormat.Style.Font.Size = 9;
  18207. builder.ParagraphFormat.Style.Font.Bold = true;
  18208. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18209. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  18210. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18211. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18212. builder.ParagraphFormat.LineSpacing = 1;
  18213. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18214. builder.ParagraphFormat.Style.Font.Size = 9;
  18215. builder.ParagraphFormat.Style.Font.Bold = true;
  18216. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  18217. builder.StartTable();
  18218. // 设置边框颜色
  18219. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  18220. //设置边框样式
  18221. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  18222. //表格
  18223. #region 第一行
  18224. builder.InsertCell();
  18225. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18226. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18227. //builder.CellFormat.AllowAutoFit = false;
  18228. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18229. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18230. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18231. builder.CellFormat.WrapText = true; //自动换行
  18232. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18233. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  18234. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18235. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18236. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18237. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18238. builder.Write("TOUR NO:");
  18239. builder.InsertCell();
  18240. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18241. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18242. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18243. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18244. builder.ParagraphFormat.Style.Font.Bold = false;
  18245. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18246. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18247. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18248. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18249. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18250. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18251. builder.Write($"{dele?.TourCode ?? "-"}");
  18252. builder.InsertCell();
  18253. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18254. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18255. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18256. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18257. builder.ParagraphFormat.Style.Font.Bold = false;
  18258. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18259. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18260. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18261. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18262. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18263. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18264. builder.Write($"CITY:");
  18265. builder.InsertCell();
  18266. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18267. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18268. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18269. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18270. builder.ParagraphFormat.Style.Font.Bold = false;
  18271. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18272. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18273. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18274. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18275. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18276. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18277. builder.Write($"{item.City}");
  18278. builder.EndRow();
  18279. #endregion
  18280. #region 第二行
  18281. builder.InsertCell();
  18282. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18283. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18284. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18285. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18286. builder.ParagraphFormat.Style.Font.Bold = false;
  18287. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18288. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18289. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18290. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18291. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18292. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18293. builder.Write("CONFIRMATION NO:");
  18294. builder.InsertCell();
  18295. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18296. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18297. builder.ParagraphFormat.Style.Font.Size = 8;
  18298. builder.ParagraphFormat.Style.Font.Bold = false;
  18299. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18300. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18301. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18302. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18303. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18304. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18305. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18306. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18307. builder.Write($"{item.DetermineNo}");
  18308. builder.InsertCell();
  18309. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18310. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18311. builder.InsertCell();
  18312. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18313. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18314. builder.EndRow();
  18315. #endregion
  18316. #region 第三行
  18317. builder.InsertCell();
  18318. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18319. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18320. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18321. builder.ParagraphFormat.Style.Font.Bold = false;
  18322. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18323. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18324. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18325. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18326. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18327. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18328. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18329. builder.Write($"HOTEL NAME:");
  18330. builder.InsertCell();
  18331. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18332. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18333. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18334. builder.ParagraphFormat.Style.Font.Bold = false;
  18335. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18336. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18337. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18338. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18339. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18340. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18341. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18342. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18343. builder.Write($"{item.HotelName}");
  18344. builder.InsertCell();
  18345. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18346. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18347. builder.InsertCell();
  18348. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18349. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18350. builder.EndRow();
  18351. #endregion
  18352. #region 第四行
  18353. builder.InsertCell();
  18354. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18355. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18356. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18357. builder.ParagraphFormat.Style.Font.Bold = false;
  18358. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18359. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18360. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18361. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18362. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18363. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18364. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18365. builder.Write($"HOTEL ADDRESS:");
  18366. builder.InsertCell();
  18367. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18368. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18369. builder.ParagraphFormat.Style.Font.Size = 8;
  18370. builder.ParagraphFormat.Style.Font.Bold = false;
  18371. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18372. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18373. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18374. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18375. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18376. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18377. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18378. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18379. builder.Write($"{item.HotelAddress}");
  18380. builder.InsertCell();
  18381. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18382. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18383. builder.InsertCell();
  18384. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18385. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18386. builder.EndRow();
  18387. #endregion
  18388. #region 第五行
  18389. builder.InsertCell();
  18390. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18391. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18392. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18393. builder.ParagraphFormat.Style.Font.Bold = false;
  18394. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18395. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18396. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18397. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18398. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18399. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18400. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18401. builder.Write("TEL:");
  18402. builder.InsertCell();
  18403. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18404. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18405. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18406. builder.ParagraphFormat.Style.Font.Bold = false;
  18407. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18408. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18409. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18410. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18411. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18412. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18413. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18414. builder.Write($"{item.HotelTel}");
  18415. builder.InsertCell();
  18416. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18417. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18418. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18419. builder.ParagraphFormat.Style.Font.Bold = false;
  18420. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18421. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18422. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18423. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18424. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18425. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18426. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18427. builder.Write($"FAX:");
  18428. builder.InsertCell();
  18429. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18430. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18431. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18432. builder.ParagraphFormat.Style.Font.Bold = false;
  18433. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18434. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18435. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18436. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18437. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18438. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18439. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18440. builder.Write($"{item.HotelFax}");
  18441. builder.EndRow();
  18442. #endregion
  18443. #region 第六行
  18444. builder.InsertCell();
  18445. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18446. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18447. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18448. builder.ParagraphFormat.Style.Font.Bold = false;
  18449. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18450. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18451. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18452. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18453. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18454. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18455. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18456. builder.Write("CHECK IN:");
  18457. builder.InsertCell();
  18458. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18459. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18460. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18461. builder.ParagraphFormat.Style.Font.Bold = false;
  18462. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18463. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18464. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18465. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18466. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18467. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18468. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18469. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18470. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18471. builder.Write($"{checkInStr}");
  18472. builder.InsertCell();
  18473. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18474. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18475. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18476. builder.ParagraphFormat.Style.Font.Bold = false;
  18477. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18478. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18479. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18480. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18481. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18482. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18483. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18484. builder.Write($"CHECK OUT:");
  18485. builder.InsertCell();
  18486. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18487. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18488. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18489. builder.ParagraphFormat.Style.Font.Bold = false;
  18490. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18491. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18492. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18493. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18494. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18495. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18496. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18497. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18498. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18499. builder.Write($"{checkOutStr}");
  18500. builder.EndRow();
  18501. #endregion
  18502. #region 第七行
  18503. builder.InsertCell();
  18504. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18505. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18506. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18507. builder.ParagraphFormat.Style.Font.Bold = false;
  18508. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18509. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18510. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18511. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18512. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18513. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18514. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18515. builder.Write($"GUEST NAME:");
  18516. builder.InsertCell();
  18517. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18518. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18519. builder.ParagraphFormat.Style.Font.Size = 8;
  18520. builder.ParagraphFormat.Style.Font.Bold = false;
  18521. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18522. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18523. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18524. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18525. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18526. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18527. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18528. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18529. builder.Write($"{item.GuestName.Trim()}");
  18530. builder.InsertCell();
  18531. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18532. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18533. builder.InsertCell();
  18534. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18535. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18536. builder.EndRow();
  18537. #endregion
  18538. #region 第八行
  18539. builder.InsertCell();
  18540. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18541. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18542. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18543. builder.ParagraphFormat.Style.Font.Bold = false;
  18544. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18545. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18546. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18547. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18548. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18549. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18550. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18551. builder.Write($"ROOM TYPE:");
  18552. builder.InsertCell();
  18553. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18554. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18555. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18556. builder.ParagraphFormat.Style.Font.Bold = false;
  18557. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18558. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18559. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18560. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18561. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18562. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18563. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18564. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18565. builder.Write($"{item.RoomExplanation}");
  18566. builder.InsertCell();
  18567. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18568. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18569. builder.InsertCell();
  18570. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18571. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18572. builder.EndRow();
  18573. #endregion
  18574. #region 第九行
  18575. builder.InsertCell();
  18576. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18577. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18578. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18579. builder.ParagraphFormat.Style.Font.Bold = false;
  18580. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18581. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18582. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18583. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18584. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18585. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18586. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18587. builder.Write($"NOTE:");
  18588. builder.InsertCell();
  18589. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18590. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18591. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18592. builder.ParagraphFormat.Style.Font.Bold = false;
  18593. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18594. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18595. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18596. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18597. 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.");
  18598. builder.InsertCell();
  18599. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18600. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18601. builder.InsertCell();
  18602. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18603. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18604. builder.EndRow();
  18605. #endregion
  18606. builder.EndTable();
  18607. //换行
  18608. builder.Writeln("");
  18609. builder.Writeln("");
  18610. }
  18611. #region 获取文档中的所有表格 设置文字自适应
  18612. // 获取文档中的所有表格。
  18613. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18614. {
  18615. // 遍历表格中的所有行。
  18616. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18617. {
  18618. foreach (Cell cell in row.Cells)
  18619. {
  18620. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18621. cellFormat.Width = 0;
  18622. }
  18623. }
  18624. }
  18625. #endregion
  18626. #region 设置页眉
  18627. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18628. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18629. if (System.IO.File.Exists(voucherHeaderPath))
  18630. {
  18631. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18632. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18633. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18634. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18635. // 调整图片位置
  18636. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18637. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18638. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18639. shape.Left = 0; // 将图片距离页面左边缘的距离
  18640. shape.Width = 81; // 设置图片宽度
  18641. shape.Height = 36; // 设置图片高度
  18642. }
  18643. //靠右
  18644. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18645. //// 设置页脚上下边距
  18646. //builder.PageSetup.HeaderDistance = 42;
  18647. // 添加页眉线
  18648. Aspose.Words.Border borderHeader = null;
  18649. try
  18650. {
  18651. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18652. }
  18653. catch (Exception e)
  18654. {
  18655. // TODO Auto-generated catch block
  18656. //e.printStackTrace();
  18657. }
  18658. borderHeader.Shadow = true;
  18659. borderHeader.DistanceFromText = 2;
  18660. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18661. #endregion
  18662. }
  18663. catch (Exception ex)
  18664. {
  18665. }
  18666. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18667. doc.Save(fileDir);
  18668. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18669. return Ok(JsonView(true, "操作成功!", Url));
  18670. }
  18671. /// <summary>
  18672. /// 酒店预订
  18673. /// 生成 预定成本 Excel
  18674. /// </summary>
  18675. /// <param name="_dto"></param>
  18676. /// <returns></returns>
  18677. [HttpPost]
  18678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18679. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18680. {
  18681. #region 参数验证
  18682. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18683. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18684. if (!vadalitorRes.IsValid)
  18685. {
  18686. var errors = new StringBuilder();
  18687. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18688. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18689. }
  18690. #region 团组操作权限验证 76 酒店预定模块
  18691. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18692. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18693. #endregion
  18694. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18695. #region 页面操作权限验证
  18696. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18697. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18698. #endregion
  18699. #endregion
  18700. decimal _rate = 1.00M;
  18701. string _currency = string.Empty;
  18702. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18703. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18704. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18705. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18706. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18707. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18708. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18709. if (_GroupCostParameter == null)
  18710. {
  18711. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18712. bool isIntType = int.TryParse(_currency, out int currId);
  18713. if (isIntType)
  18714. {
  18715. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18716. }
  18717. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18718. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18719. if (currInfo == null)
  18720. {
  18721. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18722. }
  18723. else _rate = currInfo.Rate;
  18724. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18725. {
  18726. _rate = _GroupCostParameter.Rate;
  18727. }
  18728. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18729. //string strFileName = "HotelStatement/";
  18730. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18731. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18732. var rateDatas = new List<dynamic>();
  18733. #region 数据处理
  18734. foreach (var item in hrDtas)
  18735. {
  18736. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18737. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18738. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18739. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18740. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18741. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18742. {
  18743. continue;
  18744. }
  18745. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18746. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18747. string singleRoomFeeStr = string.Empty,
  18748. doubleRoomFeeStr = string.Empty,
  18749. suiteRoomFeeStr = string.Empty,
  18750. otherRoomFeeStr = string.Empty,
  18751. payMoneyStr = string.Empty,
  18752. cardPriceStr = string.Empty;
  18753. if (roomCurr.Equals("CNY"))
  18754. {
  18755. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18756. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18757. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18758. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18759. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18760. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18761. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18762. }
  18763. else
  18764. {
  18765. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18766. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18767. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18768. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18769. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18770. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18771. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18772. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18773. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18774. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18775. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18776. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18777. if (ccpPaymentCurrency.Equals("CNY"))
  18778. {
  18779. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18780. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18781. }
  18782. else
  18783. {
  18784. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18785. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18786. }
  18787. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18788. if (hotelcardPriceCurrency.Equals("CNY"))
  18789. {
  18790. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18791. }
  18792. else
  18793. {
  18794. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18795. }
  18796. }
  18797. string breakfastPriceStr = string.Empty,
  18798. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18799. governmentRentStr = string.Empty,
  18800. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18801. cityTaxStr = string.Empty,
  18802. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18803. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18804. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18805. {
  18806. if (breakfastCurrency1.Equals("CNY"))
  18807. {
  18808. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18809. }
  18810. else
  18811. {
  18812. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18813. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18814. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18815. }
  18816. }
  18817. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18818. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18819. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18820. {
  18821. if (governmentRentCurrency.Equals("CNY"))
  18822. {
  18823. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18824. }
  18825. else
  18826. {
  18827. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18828. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18829. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18830. }
  18831. }
  18832. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18833. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18834. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18835. {
  18836. if (cityTaxStrCurrency1.Equals("CNY"))
  18837. {
  18838. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18839. }
  18840. else
  18841. {
  18842. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18843. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18844. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18845. }
  18846. }
  18847. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18848. int payDId = roomInfo?.PayDId ?? 0;
  18849. pcfds.Add(new HotelReservations_PCFD_View()
  18850. {
  18851. City = item.City,
  18852. HotelName = item.HotelName,
  18853. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18854. // SingleRoomCount = item.SingleRoomCount,
  18855. SingleRoomPrice = singleRoomFeeStr,
  18856. // DoubleRoomCount = item.DoubleRoomCount,
  18857. DoubleRoomPrice = doubleRoomFeeStr,
  18858. //SuiteRoomCount = item.SuiteRoomCount,
  18859. SuiteRoomPrice = suiteRoomFeeStr,
  18860. OtherRoomPrice = otherRoomFeeStr,
  18861. //OtherRoomCount = item.OtherRoomCount,
  18862. BreakfastPrice = breakfastPriceStr,
  18863. GovernmentRent = governmentRentStr,
  18864. CityTax = cityTaxStr,
  18865. RoomExplanation = item.RoomExplanation,
  18866. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18867. PayTime = roomInfo?.ConsumptionDate,
  18868. BankNo = roomInfo?.BankNo,
  18869. PayMoney = payMoneyStr,
  18870. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18871. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18872. CardPrice = cardPriceStr,
  18873. Remark = ccpInfo.Remark
  18874. });
  18875. }
  18876. #endregion
  18877. //载入模板
  18878. WorkbookDesigner designer = new WorkbookDesigner();
  18879. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18880. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18881. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18882. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18883. var rateDatas1 = rateDatas.Distinct();
  18884. var rateStr = string.Empty;
  18885. foreach (var item in rateDatas1)
  18886. {
  18887. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18888. }
  18889. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18890. designer.SetDataSource("Opertor", userInfo.CnName);
  18891. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18892. dt.TableName = "ViewMyHotelReservations";
  18893. designer.SetDataSource(dt);
  18894. designer.Process();
  18895. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18896. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18897. designer.Workbook.Save(serverPath);
  18898. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18899. #region 删除指定行
  18900. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18901. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18902. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18903. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18904. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18905. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18906. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18907. cssIndex = dt.Columns["CityTax"].Ordinal,
  18908. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18909. remarkIndex = dt.Columns["Remark"].Ordinal;
  18910. //删除指定列
  18911. foreach (DataRow item in dt.Rows)
  18912. {
  18913. string singleStr = item["SingleRoomPrice"].ToString();
  18914. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18915. if (containsDigitButNotZero1) singleDel = false;
  18916. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18917. string doubleStr = item["DoubleRoomPrice"].ToString();
  18918. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18919. if (containsDigitButNotZero2) doubleDel = false;
  18920. string suiteStr = item["SuiteRoomPrice"].ToString();
  18921. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18922. if (containsDigitButNotZero3) suiteDel = false;
  18923. string otherStr = item["OtherRoomPrice"].ToString();
  18924. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18925. if (containsDigitButNotZero4) otherDel = false;
  18926. string zcStr = item["BreakfastPrice"].ToString();
  18927. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18928. if (containsDigitButNotZero5) zcDel = false;
  18929. string dsStr = item["GovernmentRent"].ToString();
  18930. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18931. if (containsDigitButNotZero6) dsDel = false;
  18932. string cssStr = item["CityTax"].ToString();
  18933. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18934. if (containsDigitButNotZero7) cssDel = false;
  18935. string cpStr = item["ConsumptionPatterns"].ToString();
  18936. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18937. string remarkStr = item["Remark"].ToString();
  18938. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18939. }
  18940. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18941. DeleteColumn(serverPath, cpIndex, cpDel);
  18942. DeleteColumn(serverPath, dsIndex, dsDel);
  18943. DeleteColumn(serverPath, cssIndex, cssDel);
  18944. DeleteColumn(serverPath, zcIndex, zcDel);
  18945. DeleteColumn(serverPath, otherIndex, otherDel);
  18946. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18947. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18948. DeleteColumn(serverPath, singleIndex, singleDel);
  18949. #endregion
  18950. //只保留第一个表格
  18951. DeleteSheet(serverPath);
  18952. return Ok(JsonView(true, "操作成功", url = rst));
  18953. }
  18954. else
  18955. {
  18956. _currency = _GroupCostParameter.Currency;
  18957. bool isIntType = int.TryParse(_currency, out int currId);
  18958. if (isIntType)
  18959. {
  18960. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18961. }
  18962. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18963. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18964. if (currInfo == null)
  18965. {
  18966. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18967. }
  18968. if (!_currency.ToUpper().Equals("CNY"))
  18969. {
  18970. _rate = _GroupCostParameter.Rate;
  18971. }
  18972. _rate = currInfo.Rate;
  18973. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18974. //string strFileName = "HotelStatement/";
  18975. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18976. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18977. #region 数据处理
  18978. foreach (var item in hrDtas)
  18979. {
  18980. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18981. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18982. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18983. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18984. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18985. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18986. string singleRoomFeeStr = string.Empty,
  18987. doubleRoomFeeStr = string.Empty,
  18988. suiteRoomFeeStr = string.Empty,
  18989. otherRoomFeeStr = string.Empty,
  18990. payMoneyStr = string.Empty,
  18991. cardPriceStr = string.Empty;
  18992. if (roomCurr.Equals(_currency))
  18993. {
  18994. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18995. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18996. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18997. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18998. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18999. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  19000. }
  19001. else
  19002. {
  19003. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19004. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19005. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19006. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19007. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19008. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19009. }
  19010. string breakfastPriceStr = string.Empty,
  19011. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19012. governmentRentStr = string.Empty,
  19013. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19014. cityTaxStrStr = string.Empty,
  19015. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19016. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  19017. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  19018. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  19019. int payDId = roomInfo?.PayDId ?? 0;
  19020. pcfds.Add(new HotelReservations_PCFD_View()
  19021. {
  19022. City = item.City,
  19023. HotelName = item.HotelName,
  19024. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19025. // SingleRoomCount = item.SingleRoomCount,
  19026. SingleRoomPrice = singleRoomFeeStr,
  19027. // DoubleRoomCount = item.DoubleRoomCount,
  19028. DoubleRoomPrice = doubleRoomFeeStr,
  19029. //SuiteRoomCount = item.SuiteRoomCount,
  19030. SuiteRoomPrice = suiteRoomFeeStr,
  19031. OtherRoomPrice = otherRoomFeeStr,
  19032. //OtherRoomCount = item.OtherRoomCount,
  19033. BreakfastPrice = breakfastPriceStr,
  19034. GovernmentRent = governmentRentStr,
  19035. CityTax = cityTaxStrStr,
  19036. RoomExplanation = item.RoomExplanation,
  19037. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19038. PayTime = roomInfo?.ConsumptionDate,
  19039. BankNo = roomInfo?.BankNo,
  19040. PayMoney = payMoneyStr,
  19041. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19042. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19043. CardPrice = cardPriceStr,
  19044. Remark = ccpInfo.Remark
  19045. });
  19046. }
  19047. #endregion
  19048. //载入模板
  19049. WorkbookDesigner designer = new WorkbookDesigner();
  19050. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19051. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19052. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19053. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19054. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  19055. designer.SetDataSource("Opertor", userInfo.CnName);
  19056. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19057. dt.TableName = "ViewMyHotelReservations";
  19058. designer.SetDataSource(dt);
  19059. designer.Process();
  19060. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19061. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19062. designer.Workbook.Save(serverPath);
  19063. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19064. #region 删除指定行
  19065. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19066. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19067. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19068. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19069. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19070. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19071. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19072. cssIndex = dt.Columns["CityTax"].Ordinal,
  19073. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19074. remarkIndex = dt.Columns["Remark"].Ordinal;
  19075. //删除指定列
  19076. foreach (DataRow item in dt.Rows)
  19077. {
  19078. string singleStr = item["SingleRoomPrice"].ToString();
  19079. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19080. if (containsDigitButNotZero1) singleDel = false;
  19081. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19082. string doubleStr = item["DoubleRoomPrice"].ToString();
  19083. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19084. if (containsDigitButNotZero2) doubleDel = false;
  19085. string suiteStr = item["SuiteRoomPrice"].ToString();
  19086. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19087. if (containsDigitButNotZero3) suiteDel = false;
  19088. string otherStr = item["OtherRoomPrice"].ToString();
  19089. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19090. if (containsDigitButNotZero4) otherDel = false;
  19091. string zcStr = item["BreakfastPrice"].ToString();
  19092. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19093. if (containsDigitButNotZero5) zcDel = false;
  19094. string dsStr = item["GovernmentRent"].ToString();
  19095. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19096. if (containsDigitButNotZero6) dsDel = false;
  19097. string cssStr = item["CityTax"].ToString();
  19098. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19099. if (containsDigitButNotZero7) cssDel = false;
  19100. string cpStr = item["ConsumptionPatterns"].ToString();
  19101. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19102. string remarkStr = item["Remark"].ToString();
  19103. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19104. }
  19105. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19106. DeleteColumn(serverPath, cpIndex, cpDel);
  19107. DeleteColumn(serverPath, dsIndex, dsDel);
  19108. DeleteColumn(serverPath, cssIndex, cssDel);
  19109. DeleteColumn(serverPath, zcIndex, zcDel);
  19110. DeleteColumn(serverPath, otherIndex, otherDel);
  19111. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19112. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19113. DeleteColumn(serverPath, singleIndex, singleDel);
  19114. #endregion
  19115. //只保留第一个表格
  19116. DeleteSheet(serverPath);
  19117. return Ok(JsonView(true, "操作成功", url = rst));
  19118. }
  19119. //return Ok(JsonView(false));
  19120. }
  19121. /// <summary>
  19122. /// 删除指定列
  19123. /// </summary>
  19124. /// <param name="file"></param>
  19125. /// <param name="columnIndex"></param>
  19126. /// <param name="isDel"></param>
  19127. private void DeleteColumn(string file, int columnIndex, bool isDel)
  19128. {
  19129. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19130. //wb.Save(file);
  19131. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  19132. if (sheet1 != null)
  19133. {
  19134. if (isDel)
  19135. {
  19136. Cells cells = sheet1.Cells;
  19137. cells.DeleteColumn(columnIndex);
  19138. }
  19139. }
  19140. wb.Save(file);
  19141. }
  19142. /// <summary>
  19143. /// 删除sheet
  19144. /// </summary>
  19145. /// <param name="file"></param>
  19146. private void DeleteSheet(string file)
  19147. {
  19148. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19149. //wb.Save(file);
  19150. List<string> sheets = new List<string>();
  19151. foreach (var item in wb.Worksheets)
  19152. {
  19153. sheets.Add(item.Name);
  19154. }
  19155. if (sheets.Count > 0)
  19156. {
  19157. sheets.RemoveAt(0);//不删除第一个sheet
  19158. foreach (var item in sheets)
  19159. {
  19160. wb.Worksheets.RemoveAt(item);
  19161. }
  19162. }
  19163. wb.Save(file);
  19164. }
  19165. /// <summary>
  19166. /// 酒店预订
  19167. /// 确认单
  19168. /// </summary>
  19169. /// <param name="_dto"></param>
  19170. /// <returns></returns>
  19171. [HttpPost]
  19172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19173. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  19174. {
  19175. try
  19176. {
  19177. #region 参数验证
  19178. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19179. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19180. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19181. #region 团组操作权限验证 76 酒店预定模块
  19182. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19183. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19184. #endregion
  19185. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19186. #region 页面操作权限验证
  19187. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19188. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19189. #endregion
  19190. #endregion
  19191. //团组信息
  19192. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  19193. //酒店数据
  19194. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  19195. if (listhoteldata.Count < 0)
  19196. {
  19197. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  19198. }
  19199. //利datatable存储
  19200. DataTable dt = new DataTable();
  19201. dt.Columns.Add("CheckInDate", typeof(string));
  19202. dt.Columns.Add("City", typeof(string));
  19203. dt.Columns.Add("Hotel", typeof(string));
  19204. dt.Columns.Add("Room", typeof(string));
  19205. for (int i = 0; i < listhoteldata.Count; i++)
  19206. {
  19207. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  19208. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  19209. while (dayStart < dayEnd)
  19210. {
  19211. string temp = "";
  19212. DataRow row = dt.NewRow();
  19213. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  19214. row["City"] = listhoteldata[i].City;
  19215. row["Hotel"] = listhoteldata[i].HotelName;
  19216. if (listhoteldata[i].SingleRoomCount > 0)
  19217. {
  19218. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  19219. }
  19220. if (listhoteldata[i].DoubleRoomCount > 0)
  19221. {
  19222. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  19223. }
  19224. if (listhoteldata[i].SuiteRoomCount > 0)
  19225. {
  19226. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  19227. }
  19228. if (listhoteldata[i].OtherRoomCount > 0)
  19229. {
  19230. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  19231. }
  19232. row["Room"] = temp;
  19233. dt.Rows.Add(row);
  19234. dayStart = dayStart.AddDays(1);
  19235. }
  19236. }
  19237. Dictionary<string, string> dic = new Dictionary<string, string>();
  19238. dic.Add("Dele", di.TeamName);
  19239. dic.Add("City", di.VisitCountry);
  19240. //模板路径
  19241. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  19242. //载入模板
  19243. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  19244. DocumentBuilder builder = new DocumentBuilder(doc);
  19245. foreach (var key in dic.Keys)
  19246. {
  19247. builder.MoveToBookmark(key);
  19248. builder.Write(dic[key]);
  19249. }
  19250. //获取word里所有表格
  19251. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19252. //获取所填表格的序数
  19253. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19254. var rowStart = tableOne.Rows[0]; //获取第1行
  19255. //循环赋值
  19256. for (int i = 0; i < dt.Rows.Count; i++)
  19257. {
  19258. builder.MoveToCell(0, i + 1, 0, 0);
  19259. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  19260. builder.MoveToCell(0, i + 1, 1, 0);
  19261. builder.Write(dt.Rows[i]["City"].ToString());
  19262. builder.MoveToCell(0, i + 1, 2, 0);
  19263. builder.Write(dt.Rows[i]["Hotel"].ToString());
  19264. builder.MoveToCell(0, i + 1, 3, 0);
  19265. builder.Write(dt.Rows[i]["Room"].ToString());
  19266. }
  19267. //删除多余行
  19268. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  19269. {
  19270. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  19271. }
  19272. string strFileName = di.TeamName + "酒店确认单.doc";
  19273. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  19274. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  19275. return Ok(JsonView(true, "成功", url));
  19276. }
  19277. catch (Exception ex)
  19278. {
  19279. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  19280. }
  19281. }
  19282. #endregion
  19283. #region 团组状态
  19284. /// <summary>
  19285. /// 团组状态列表 Page
  19286. /// </summary>
  19287. /// <param name="dto">团组列表请求dto</param>
  19288. /// <returns></returns>
  19289. [HttpPost]
  19290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19291. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  19292. {
  19293. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19294. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  19295. {
  19296. string sqlWhere = string.Empty;
  19297. if (dto.IsSure == 0) //未完成
  19298. {
  19299. sqlWhere += string.Format(@" And IsSure = 0");
  19300. }
  19301. else if (dto.IsSure == 1) //已完成
  19302. {
  19303. sqlWhere += string.Format(@" And IsSure = 1");
  19304. }
  19305. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  19306. {
  19307. string tj = dto.SearchCriteria;
  19308. 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}%')",
  19309. tj, tj, tj, tj, tj);
  19310. }
  19311. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19312. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19313. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19314. From (
  19315. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19316. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19317. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19318. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19319. From Grp_DelegationInfo gdi
  19320. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19321. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19322. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19323. Where gdi.IsDel = 0 {0}
  19324. ) temp ", sqlWhere);
  19325. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19326. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19327. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19328. }
  19329. else
  19330. {
  19331. return Ok(JsonView(false, "查询失败"));
  19332. }
  19333. }
  19334. /// <summary>
  19335. /// 团组状态
  19336. /// 设置操作完成
  19337. /// </summary>
  19338. /// <param name="dto">团组列表请求dto</param>
  19339. /// <returns></returns>
  19340. [HttpPost]
  19341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19342. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19343. {
  19344. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19345. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19346. {
  19347. Id = dto.Id,
  19348. IsSure = 1
  19349. };
  19350. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19351. .UpdateColumns(it => new { it.IsSure })
  19352. .WhereColumns(it => new { it.Id })
  19353. .ExecuteCommandAsync();
  19354. if (result > 0)
  19355. {
  19356. return Ok(JsonView(true, "操作完成!"));
  19357. }
  19358. return Ok(JsonView(false, "操作失败!"));
  19359. }
  19360. #endregion
  19361. #region 保险费用录入
  19362. /// <summary>
  19363. /// 根据团组Id查询保险费用列表
  19364. /// </summary>
  19365. /// <param name="dto"></param>
  19366. /// <returns></returns>
  19367. [HttpPost]
  19368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19369. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19370. {
  19371. Result groupData = await _customersRep.CustomersByDiId(dto);
  19372. if (groupData.Code != 0)
  19373. {
  19374. return Ok(JsonView(false, groupData.Msg));
  19375. }
  19376. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19377. }
  19378. /// <summary>
  19379. /// 根据保险费用Id查询保险费用详细
  19380. /// </summary>
  19381. /// <param name="dto"></param>
  19382. /// <returns></returns>
  19383. [HttpPost]
  19384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19385. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19386. {
  19387. try
  19388. {
  19389. Result groupData = await _customersRep.CustomersById(dto);
  19390. if (groupData.Code != 0)
  19391. {
  19392. return Ok(JsonView(false, groupData.Msg));
  19393. }
  19394. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19395. }
  19396. catch (Exception ex)
  19397. {
  19398. return Ok(JsonView(false, ex.Message));
  19399. }
  19400. }
  19401. /// <summary>
  19402. /// 保险费用录入页面初始化绑定
  19403. /// </summary>
  19404. /// <param name="dto"></param>
  19405. /// <returns></returns>
  19406. [HttpPost]
  19407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19408. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19409. {
  19410. try
  19411. {
  19412. Result groupData = await _customersRep.CustomersInitialize(dto);
  19413. if (groupData.Code != 0)
  19414. {
  19415. return Ok(JsonView(false, groupData.Msg));
  19416. }
  19417. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19418. }
  19419. catch (Exception ex)
  19420. {
  19421. return Ok(JsonView(false, ex.Message));
  19422. }
  19423. }
  19424. /// <summary>
  19425. /// 保险费用操作(Status:1.新增,2.修改)
  19426. /// </summary>
  19427. /// <param name="dto"></param>
  19428. /// <returns></returns>
  19429. [HttpPost]
  19430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19431. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19432. {
  19433. Result groupData = await _customersRep.OpCustomers(dto);
  19434. if (groupData.Code != 0)
  19435. {
  19436. return Ok(JsonView(false, groupData.Msg));
  19437. }
  19438. #region 应用推送
  19439. try
  19440. {
  19441. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19442. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19443. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19444. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19445. //自动审核
  19446. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19447. //2024-10-21 新增LZ UID
  19448. var userIds = new List<int>() { 21 };
  19449. string title = $"系统通知";
  19450. var diId = dto.DiId;
  19451. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19452. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19453. string content = "";
  19454. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19455. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19456. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19457. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19458. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19459. }
  19460. catch (Exception ex)
  19461. {
  19462. }
  19463. #endregion
  19464. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19465. }
  19466. /// <summary>
  19467. /// 保险文件上传
  19468. /// </summary>
  19469. /// <param name="file"></param>
  19470. /// <returns></returns>
  19471. [HttpPost]
  19472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19473. public async Task<IActionResult> UploadCus(IFormFile file)
  19474. {
  19475. try
  19476. {
  19477. if (file != null)
  19478. {
  19479. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19480. //文件名称
  19481. string projectFileName = file.FileName;
  19482. //上传的文件的路径
  19483. string filePath = "";
  19484. if (!Directory.Exists(fileDir))
  19485. {
  19486. Directory.CreateDirectory(fileDir);
  19487. }
  19488. //上传的文件的路径
  19489. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19490. using (FileStream fs = System.IO.File.Create(filePath))
  19491. {
  19492. file.CopyTo(fs);
  19493. fs.Flush();
  19494. }
  19495. return Ok(JsonView(true, "上传成功!", projectFileName));
  19496. }
  19497. else
  19498. {
  19499. return Ok(JsonView(false, "上传失败!"));
  19500. }
  19501. }
  19502. catch (Exception ex)
  19503. {
  19504. return Ok(JsonView(false, ex.Message));
  19505. }
  19506. }
  19507. /// <summary>
  19508. /// 保险删除指定文件
  19509. /// </summary>
  19510. /// <param name="dto"></param>
  19511. /// <returns></returns>
  19512. [HttpPost]
  19513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19514. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19515. {
  19516. try
  19517. {
  19518. string filePath = "";
  19519. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19520. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19521. //int id = 0;
  19522. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19523. // 删除该文件
  19524. try
  19525. {
  19526. System.IO.File.Delete(filePath);
  19527. 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()
  19528. {
  19529. Attachment = "",
  19530. }).ExecuteCommandAsync();
  19531. if (result != 0)
  19532. {
  19533. return Ok(JsonView(true, "成功!"));
  19534. }
  19535. else
  19536. {
  19537. return Ok(JsonView(false, "失败!"));
  19538. }
  19539. }
  19540. catch (Exception)
  19541. {
  19542. 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()
  19543. {
  19544. Attachment = "",
  19545. }).ExecuteCommandAsync();
  19546. if (result != 0)
  19547. {
  19548. return Ok(JsonView(true, "成功!"));
  19549. }
  19550. else
  19551. {
  19552. return Ok(JsonView(false, "失败!"));
  19553. }
  19554. }
  19555. }
  19556. catch (Exception ex)
  19557. {
  19558. return Ok(JsonView(false, "程序错误!"));
  19559. throw;
  19560. }
  19561. }
  19562. /// <summary>
  19563. /// 保险费用操作(删除)
  19564. /// </summary>
  19565. /// <param name="dto"></param>
  19566. /// <returns></returns>
  19567. [HttpPost]
  19568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19569. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19570. {
  19571. try
  19572. {
  19573. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19574. if (!res)
  19575. {
  19576. return Ok(JsonView(false, "删除失败"));
  19577. }
  19578. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19579. {
  19580. IsDel = 1,
  19581. DeleteUserId = dto.DeleteUserId,
  19582. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19583. }).ExecuteCommandAsync();
  19584. return Ok(JsonView(true, "删除成功!"));
  19585. }
  19586. catch (Exception ex)
  19587. {
  19588. return Ok(JsonView(false, "程序错误!"));
  19589. throw;
  19590. }
  19591. }
  19592. #endregion
  19593. #region 接团客户名单 PageId 104
  19594. /// <summary>
  19595. /// 接团客户名单
  19596. /// 迁移数据(慎用!)
  19597. /// </summary>
  19598. /// <returns></returns>
  19599. [HttpPost]
  19600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19601. public async Task<IActionResult> PostTourClientListChange()
  19602. {
  19603. try
  19604. {
  19605. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19606. //var groupClinetData1
  19607. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19608. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19609. int updateCount = 0;
  19610. if (oldOAClientList.Count > 0)
  19611. {
  19612. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19613. _sqlSugar.BeginTran();
  19614. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19615. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19616. foreach (var item in oldOAClientList)
  19617. {
  19618. int comId = 0;
  19619. string format = "yyyy-MM-dd HH:mm:ss";
  19620. string data11 = "1990-01-01 00:00";
  19621. var data1 = IsValidDate(item.OPdate, format);
  19622. if (data1) data11 = item.OPdate;
  19623. //客户公司验证
  19624. if (!string.IsNullOrEmpty(item.Company))
  19625. {
  19626. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19627. if (clientComInfo == null) // add
  19628. {
  19629. var addInfo = new Crm_CustomerCompany()
  19630. {
  19631. CompanyAbbreviation = "",
  19632. CompanyFullName = item.Company,
  19633. Address = "",
  19634. PostCodes = "",
  19635. LastedOpUserId = item.OPer,
  19636. LastedOpDt = Convert.ToDateTime(data11),
  19637. CreateUserId = item.OPer,
  19638. CreateTime = Convert.ToDateTime(data11),
  19639. IsDel = 0
  19640. };
  19641. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19642. if (comId1 > 0) comId = comId1;
  19643. }
  19644. else comId = clientComInfo.Id;
  19645. }
  19646. //客户人员验证
  19647. int clientId = 0;
  19648. string name = item.LastName + item.Name;
  19649. if (!string.IsNullOrEmpty(name))
  19650. {
  19651. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19652. if (clientInfo == null)
  19653. {
  19654. DateTime? dateTime = null;
  19655. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19656. if (isDt) dateTime = birthDayDt;
  19657. var addInfo1 = new Crm_DeleClient()
  19658. {
  19659. CrmCompanyId = comId,
  19660. DiId = -1,
  19661. LastName = item.LastName,
  19662. FirstName = item.Name,
  19663. OldName = "",
  19664. Pinyin = item.Pinyin,
  19665. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19666. Marriage = 0,
  19667. Phone = item.Phone,
  19668. Job = item.Job,
  19669. BirthDay = dateTime
  19670. };
  19671. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19672. if (clientId1 > 0) clientId = clientId1;
  19673. }
  19674. else clientId = clientInfo.Id;
  19675. }
  19676. if (clientId < 1)
  19677. {
  19678. continue;
  19679. }
  19680. int airType = 0;
  19681. if (item.AirType == "超经舱") airType = 459;
  19682. else if (item.AirType == "公务舱") airType = 458;
  19683. else if (item.AirType == "经济舱") airType = 460;
  19684. else if (item.AirType == "其他") airType = 565;
  19685. else if (item.AirType == "头等舱") airType = 457;
  19686. var _TourClientListEntity = new Grp_TourClientList()
  19687. {
  19688. DiId = item.Diid,
  19689. ClientId = clientId,
  19690. CreateUserId = item.OPer,
  19691. CreateTime = Convert.ToDateTime(data11),
  19692. Remark = item.Remark,
  19693. IsDel = item.Isdel,
  19694. ShippingSpaceTypeId = airType,
  19695. ShippingSpaceSpecialNeeds = item.AirRemark,
  19696. HotelSpecialNeeds = item.RoomType
  19697. };
  19698. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19699. if (_TourClientList > 0)
  19700. {
  19701. updateCount++;
  19702. }
  19703. }
  19704. _sqlSugar.CommitTran();
  19705. }
  19706. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19707. }
  19708. catch (Exception ex)
  19709. {
  19710. _sqlSugar.RollbackTran();
  19711. return Ok(JsonView(false, ex.Message));
  19712. }
  19713. //return Ok(JsonView(true));
  19714. }
  19715. private bool IsValidDate(string dateString, string format)
  19716. {
  19717. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  19718. }
  19719. /// <summary>
  19720. /// 接团客户名单
  19721. /// 根据团组Id查询List
  19722. /// </summary>
  19723. /// <param name="_dto"></param>
  19724. /// <returns></returns>
  19725. [HttpPost]
  19726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19727. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19728. {
  19729. #region 参数验证
  19730. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19731. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19732. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19733. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19734. #region 页面操作权限验证
  19735. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19736. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19737. #endregion
  19738. #endregion
  19739. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19740. if (viewData.Code != 0)
  19741. {
  19742. return Ok(JsonView(false, viewData.Msg));
  19743. }
  19744. return Ok(JsonView(viewData.Data));
  19745. }
  19746. /// <summary>
  19747. /// 接团客户名单
  19748. /// 基础数据 Init
  19749. /// </summary>
  19750. /// <param name="_dto"></param>
  19751. /// <returns></returns>
  19752. [HttpPost]
  19753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19754. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19755. {
  19756. #region 参数验证
  19757. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19758. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19759. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19760. #region 页面操作权限验证
  19761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19762. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19763. #endregion
  19764. #endregion
  19765. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19766. }
  19767. /// <summary>
  19768. /// 接团客户名单
  19769. /// 根据 Id查询 Details
  19770. /// </summary>
  19771. /// <param name="_dto"></param>
  19772. /// <returns></returns>
  19773. [HttpPost]
  19774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19775. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19776. {
  19777. #region 参数验证
  19778. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19779. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19780. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19781. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19782. #region 页面操作权限验证
  19783. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19784. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19785. #endregion
  19786. #endregion
  19787. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19788. if (viewData.Code != 0)
  19789. {
  19790. return Ok(JsonView(false, viewData.Msg));
  19791. }
  19792. return Ok(JsonView(viewData.Data));
  19793. }
  19794. /// <summary>
  19795. /// 接团客户名单
  19796. /// Add Or Edit
  19797. /// </summary>
  19798. /// <param name="_dto"></param>
  19799. /// <returns></returns>
  19800. [HttpPost]
  19801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19802. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19803. {
  19804. #region 参数验证
  19805. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19806. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19807. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19808. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19809. #region 页面操作权限验证
  19810. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19811. if (_dto.Id == 0) //添加
  19812. {
  19813. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19814. }
  19815. else if (_dto.Id >= 0) //修改
  19816. {
  19817. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19818. }
  19819. #endregion
  19820. #endregion
  19821. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19822. if (viewData.Code != 0)
  19823. {
  19824. return Ok(JsonView(false, viewData.Msg));
  19825. }
  19826. return Ok(JsonView(true));
  19827. }
  19828. /// <summary>
  19829. /// 接团客户名单
  19830. /// json字符串 AddMultiple(添加多个)
  19831. /// </summary>
  19832. /// <param name="_dto"></param>
  19833. /// <returns></returns>
  19834. [HttpPost]
  19835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19836. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19837. {
  19838. #region 参数验证
  19839. string jsonLabel = _dto.JsonLabel;
  19840. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19841. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19842. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19843. #region 页面操作权限验证
  19844. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19845. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19846. #endregion
  19847. #endregion
  19848. var request = new TourClientListAddMultipleDto();
  19849. request.DiId = _dto.DiId;
  19850. request.UserId = _dto.UserId;
  19851. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19852. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19853. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19854. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19855. var infos = new List<TourClientListInfo>();
  19856. foreach (var data in datas)
  19857. {
  19858. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19859. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19860. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19861. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19862. {
  19863. continue;
  19864. }
  19865. infos.Add(new TourClientListInfo()
  19866. {
  19867. IsAccompany = 1,
  19868. LastName = lastName,
  19869. FirstName = firstName,
  19870. Pinyin = lastNameEn + @"/" + firstNameEn,
  19871. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19872. CompanyFullName = data.CompanyFullName,
  19873. Job = data.Job
  19874. });
  19875. }
  19876. if (infos.Any())
  19877. {
  19878. var viewData = await _tourClientListRep._AddMultiple(request);
  19879. if (viewData.Code != 0)
  19880. {
  19881. return Ok(JsonView(false, viewData.Msg));
  19882. }
  19883. return Ok(JsonView(true));
  19884. }
  19885. return Ok(JsonView(false));
  19886. }
  19887. /// <summary>
  19888. /// 接团客户名单
  19889. /// AddMultiple(添加多个)
  19890. /// </summary>
  19891. /// <param name="_dto"></param>
  19892. /// <returns></returns>
  19893. [HttpPost]
  19894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19895. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19896. {
  19897. #region 参数验证
  19898. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19899. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19900. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19901. #region 页面操作权限验证
  19902. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19903. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19904. #endregion
  19905. #endregion
  19906. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19907. if (viewData.Code != 0)
  19908. {
  19909. return Ok(JsonView(false, viewData.Msg));
  19910. }
  19911. return Ok(JsonView(true));
  19912. }
  19913. /// <summary>
  19914. /// 接团客户名单
  19915. /// Del
  19916. /// </summary>
  19917. /// <param name="_dto"></param>
  19918. /// <returns></returns>
  19919. [HttpPost]
  19920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19921. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19922. {
  19923. #region 参数验证
  19924. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19925. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19926. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19927. #region 页面操作权限验证
  19928. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19929. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19930. #endregion
  19931. #endregion
  19932. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19933. if (viewData.Code != 0)
  19934. {
  19935. return Ok(JsonView(false, viewData.Msg));
  19936. }
  19937. return Ok(JsonView(true));
  19938. }
  19939. /// <summary>
  19940. /// 接团客户名单
  19941. /// 文件下载 客户名单
  19942. /// </summary>
  19943. /// <param name="_dto"></param>
  19944. /// <returns></returns>
  19945. [HttpPost]
  19946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19947. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19948. {
  19949. #region 参数验证
  19950. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19951. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19952. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19953. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19954. #region 页面操作权限验证
  19955. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19956. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19957. #endregion
  19958. #endregion
  19959. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19960. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19961. From Grp_TourClientList tcl
  19962. Left Join
  19963. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19964. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19965. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19966. From Crm_DeleClient dc
  19967. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19968. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19969. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19970. Where dc.IsDel = 0) temp
  19971. On temp.DcId =tcl.ClientId
  19972. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19973. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19974. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19975. //载入模板
  19976. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19977. if (_dto.Language == 1)
  19978. {
  19979. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19980. }
  19981. //载入模板
  19982. var doc = new Document(tempPath);
  19983. DocumentBuilder builder = new DocumentBuilder(doc);
  19984. //获取word里所有表格
  19985. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19986. //获取所填表格的序数
  19987. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19988. var rowStart = tableOne.Rows[0]; //获取第1行
  19989. if (_dto.Language == 0)
  19990. {
  19991. //循环赋值
  19992. for (int i = 0; i < DcList.Count; i++)
  19993. {
  19994. EncryptionProcessor.DecryptProperties(DcList[i]);
  19995. builder.MoveToCell(0, i + 1, 0, 0);
  19996. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19997. builder.MoveToCell(0, i + 1, 1, 0);
  19998. int sex = DcList[i].Sex;
  19999. string sexStr = string.Empty;
  20000. if (sex == 0) sexStr = "男";
  20001. else if (sex == 1) sexStr = "女";
  20002. else sexStr = "未设置";
  20003. builder.Write(sexStr);
  20004. builder.MoveToCell(0, i + 1, 2, 0);
  20005. string birthDay = DcList[i].BirthDay;
  20006. string birthDayStr = string.Empty;
  20007. if (!string.IsNullOrEmpty(birthDay))
  20008. {
  20009. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  20010. }
  20011. builder.Write(birthDayStr);
  20012. builder.MoveToCell(0, i + 1, 3, 0);
  20013. string company = "";
  20014. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20015. {
  20016. company = DcList[i].CompanyFullName.ToString();
  20017. }
  20018. builder.Write(company);
  20019. builder.MoveToCell(0, i + 1, 4, 0);
  20020. builder.Write(DcList[i].Job);
  20021. }
  20022. }
  20023. else if (_dto.Language == 1)
  20024. {
  20025. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  20026. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  20027. List<string> transArrayStr = new List<string>();
  20028. string transStrRes1 = "";
  20029. for (int i = 0; i < DcList.Count; i++)
  20030. {
  20031. var dc = DcList[i];
  20032. EncryptionProcessor.DecryptProperties(dc);
  20033. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  20034. if (dc.Job.Equals("暂无")) dc.Job = "-";
  20035. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  20036. if (DcList.Count - 1 == i) transStrRes1 += str1;
  20037. else transStrRes1 += $"{str1}|";
  20038. }
  20039. #region AI转英文
  20040. string jsonValue = JsonConvert.SerializeObject(DcList);
  20041. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  20042. List<SeedMessages> messages = new List<SeedMessages>()
  20043. {
  20044. new SeedMessages
  20045. {
  20046. Role = KimiRole.user,
  20047. Content = jsonValue + text
  20048. }
  20049. };
  20050. KiMiApiClient client = new KiMiApiClient();
  20051. var kimiApiResult = await client.SeedMessage(messages);
  20052. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20053. string clients = kimiApiResult_JObject["content"].ToString();
  20054. string startStr = "```json", endStr = "```";
  20055. // 判断并清除开头部分
  20056. if (clients.StartsWith(startStr))
  20057. {
  20058. clients = clients.Remove(0, startStr.Length);
  20059. }
  20060. // 判断并清除结尾部分
  20061. if (clients.EndsWith(endStr))
  20062. {
  20063. clients = clients.Remove(clients.Length - endStr.Length);
  20064. }
  20065. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  20066. //循环赋值
  20067. for (int i = 0; i < en_Json.Count; i++)
  20068. {
  20069. var dc = en_Json[i];
  20070. var dc1 = DcList.Find(x => x.Id == dc.Id);
  20071. string PYName = dc.FirstName + " " + dc.LastName;
  20072. builder.MoveToCell(0, i + 1, 0, 0);
  20073. builder.Write(PYName);
  20074. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  20075. builder.MoveToCell(0, i + 1, 1, 0);
  20076. builder.Write(sex);
  20077. DateTime birthDt;
  20078. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  20079. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20080. builder.MoveToCell(0, i + 1, 2, 0);
  20081. builder.Write(birthday);
  20082. string company = string.Empty, job = string.Empty;
  20083. company = dc.CompanyFullName;
  20084. job = dc.Job;
  20085. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  20086. {
  20087. //查询对照表
  20088. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  20089. if (tempCec != null)
  20090. {
  20091. company = tempCec.enName;
  20092. }
  20093. }
  20094. builder.MoveToCell(0, i + 1, 3, 0);
  20095. builder.Write(company);
  20096. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  20097. {
  20098. //查询对照表
  20099. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  20100. if (tempPec != null)
  20101. {
  20102. job = tempPec.enName;
  20103. }
  20104. }
  20105. builder.MoveToCell(0, i + 1, 4, 0);
  20106. builder.Write(job);
  20107. }
  20108. #endregion
  20109. #region 旧翻译英文处理
  20110. ////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";
  20111. //string transStrRes = "";
  20112. //if (transStrRes1.Length > 0)
  20113. //{
  20114. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  20115. //}
  20116. ////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
  20117. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  20118. ////List<string> transArray = new List<string> { };
  20119. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  20120. //if (transStrRes.Contains("|"))
  20121. //{
  20122. // string[] transArray1 = transStrRes.Split('|');
  20123. // if (transArray1.Length > 0)
  20124. // {
  20125. // foreach (var item in transArray1)
  20126. // {
  20127. // if (item.Contains("&"))
  20128. // {
  20129. // string[] transArray2 = item.Split('&');
  20130. // int index = 0;
  20131. // string companyName = "", job = "";
  20132. // if (transArray2.Length > 0)
  20133. // {
  20134. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  20135. // if (1 < transArray2.Length) companyName = transArray2[1];
  20136. // if (2 < transArray2.Length) job = transArray2[2];
  20137. // }
  20138. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  20139. // }
  20140. // }
  20141. // }
  20142. //}
  20143. ////循环赋值
  20144. //for (int i = 0; i < DcList.Count; i++)
  20145. //{
  20146. // string PYName = "";
  20147. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  20148. // {
  20149. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  20150. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  20151. // PYName = PY_First + " " + PY_Last;
  20152. // }
  20153. // else
  20154. // {
  20155. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  20156. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  20157. // PYName = PY_First + " " + PY_Last;
  20158. // }
  20159. // builder.MoveToCell(0, i + 1, 0, 0);
  20160. // builder.Write(PYName);
  20161. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  20162. // builder.MoveToCell(0, i + 1, 1, 0);
  20163. // builder.Write(sex);
  20164. // DateTime birthDt;
  20165. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  20166. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20167. // builder.MoveToCell(0, i + 1, 2, 0);
  20168. // builder.Write(birthday);
  20169. // string company = string.Empty, job = string.Empty;
  20170. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  20171. // if (dcTransInfo != null)
  20172. // {
  20173. // company = dcTransInfo.CompanyName;
  20174. // job = dcTransInfo.Job;
  20175. // }
  20176. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20177. // {
  20178. // //查询对照表
  20179. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  20180. // if (tempCec != null)
  20181. // {
  20182. // company = tempCec.enName;
  20183. // }
  20184. // //翻译
  20185. // else
  20186. // {
  20187. // }
  20188. // }
  20189. // builder.MoveToCell(0, i + 1, 3, 0);
  20190. // builder.Write(company);
  20191. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  20192. // {
  20193. // //查询对照表
  20194. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  20195. // if (tempPec != null)
  20196. // {
  20197. // job = tempPec.enName;
  20198. // }
  20199. // //翻译
  20200. // else
  20201. // {
  20202. // }
  20203. // }
  20204. // builder.MoveToCell(0, i + 1, 4, 0);
  20205. // builder.Write(job);
  20206. //}
  20207. #endregion
  20208. }
  20209. //删除多余行
  20210. while (tableOne.Rows.Count > DcList.Count + 1)
  20211. {
  20212. tableOne.Rows.RemoveAt(DcList.Count + 1);
  20213. }
  20214. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  20215. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  20216. doc.Save(fileDir);
  20217. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  20218. return Ok(JsonView(true, "操作成功!", Url));
  20219. }
  20220. private class TranslateInfo
  20221. {
  20222. public int Index { get; set; }
  20223. public string CompanyName { get; set; }
  20224. public string Job { get; set; }
  20225. }
  20226. [HttpPost]
  20227. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  20228. {
  20229. if (files.Count == 0)
  20230. {
  20231. return Ok(JsonView(false, "文件为空"));
  20232. }
  20233. KiMiApiClient KiMiApi = new KiMiApiClient();
  20234. var seedConter = await KiMiApi.UploadFilesAsync(files);
  20235. if (seedConter.Count == 0)
  20236. {
  20237. return Ok(JsonView(false, "上传结果为空!"));
  20238. }
  20239. var messages = new List<SeedMessages>
  20240. {
  20241. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  20242. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  20243. };
  20244. messages.InsertRange(1, seedConter);
  20245. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  20246. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20247. string clients = kimiApiResult_JObject["content"].ToString();
  20248. string startStr = "```json", endStr = "```";
  20249. // 判断并清除开头部分
  20250. if (clients.StartsWith(startStr))
  20251. {
  20252. clients = clients.Remove(0, startStr.Length);
  20253. }
  20254. // 判断并清除结尾部分
  20255. if (clients.EndsWith(endStr))
  20256. {
  20257. clients = clients.Remove(clients.Length - endStr.Length);
  20258. }
  20259. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  20260. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  20261. {
  20262. {"姓", "LastName" },
  20263. {"名", "FirstName" },
  20264. {"姓名拼音", "Pinyin" },
  20265. {"性别", "Sex" },
  20266. {"单位", "CompanyFullName" },
  20267. {"职务", "Job" },
  20268. {"出生日期", "Birthday" },
  20269. };
  20270. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  20271. foreach (var item in clients_JObject)
  20272. {
  20273. BaiduClientOCRView cdc = new BaiduClientOCRView();
  20274. foreach (var field in clientFieldMap.Keys)
  20275. {
  20276. if (item.TryGetValue(field, out JToken value))
  20277. {
  20278. var getValue = value.ToString();
  20279. System.Type type = cdc.GetType();
  20280. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  20281. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  20282. propertyInfo.SetValue(cdc, propertyValue);
  20283. }
  20284. }
  20285. crmClients.Add(cdc);
  20286. }
  20287. return Ok(JsonView(new
  20288. {
  20289. fileCount = files.Count,
  20290. UploadCount = seedConter.Count,
  20291. ApiResult = clients,
  20292. CrmClients = crmClients
  20293. }));
  20294. }
  20295. #endregion
  20296. #region 团组倒推表
  20297. /// <summary>
  20298. /// 倒推表基础数据
  20299. /// Init
  20300. /// </summary>
  20301. /// <returns></returns>
  20302. [HttpPost]
  20303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20304. public async Task<IActionResult> PostInvertedListInit()
  20305. {
  20306. var viewData = await _invertedListRep._Init();
  20307. if (viewData.Code != 0)
  20308. {
  20309. return Ok(JsonView(false, viewData.Msg));
  20310. }
  20311. return Ok(JsonView(viewData.Data));
  20312. }
  20313. /// <summary>
  20314. /// 倒推表
  20315. /// Info
  20316. /// </summary>
  20317. /// <param name="dto"></param>
  20318. /// <returns></returns>
  20319. [HttpPost]
  20320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20321. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20322. {
  20323. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20324. if (viewData.Code != 0)
  20325. {
  20326. return Ok(JsonView(false, viewData.Msg));
  20327. }
  20328. return Ok(JsonView(viewData.Data));
  20329. }
  20330. /// <summary>
  20331. /// 倒推表
  20332. /// Create
  20333. /// </summary>
  20334. /// <param name="dto"></param>
  20335. /// <returns></returns>
  20336. [HttpPost]
  20337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20338. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20339. {
  20340. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20341. if (viewData.Code != 0)
  20342. {
  20343. return Ok(JsonView(false, viewData.Msg));
  20344. }
  20345. return Ok(JsonView(viewData.Data));
  20346. }
  20347. /// <summary>
  20348. /// 倒推表
  20349. /// Update
  20350. /// </summary>
  20351. /// <param name="dto"></param>
  20352. /// <returns></returns>
  20353. [HttpPost]
  20354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20355. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20356. {
  20357. var viewData = await _invertedListRep._Update(dto);
  20358. if (viewData.Code != 0)
  20359. {
  20360. return Ok(JsonView(false, viewData.Msg));
  20361. }
  20362. return Ok(JsonView(viewData.Data));
  20363. }
  20364. /// <summary>
  20365. /// 倒推表
  20366. /// File Download
  20367. /// </summary>
  20368. /// <param name="dto"></param>
  20369. /// <returns></returns>
  20370. [HttpPost]
  20371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20372. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20373. {
  20374. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20375. if (info2.Code != 0)
  20376. {
  20377. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20378. }
  20379. var info1 = info2.Data as InvertedListInfoView;
  20380. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20381. string teamName = "";
  20382. if (info != null) teamName = info.TeamName;
  20383. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20384. var doc = new Document();
  20385. var builder = new DocumentBuilder(doc);
  20386. #region old insert
  20387. ////载入模板
  20388. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20389. //Document doc = new Document(tempPath);
  20390. //DocumentBuilder builder = new DocumentBuilder(doc);
  20391. //利用键值对存放数据
  20392. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20393. //dic.Add("TeamName", teamName);
  20394. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20395. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20396. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20397. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20398. //dic.Add("SQRemark", info1.ApprovalRemark);
  20399. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20400. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20401. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20402. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20403. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20404. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20405. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20406. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20407. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20408. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20409. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20410. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20411. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20412. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20413. //#region 填充word模板书签内容
  20414. //foreach (var key in dic.Keys)
  20415. //{
  20416. // builder.MoveToBookmark(key);
  20417. // builder.Write(dic[key]);
  20418. //}
  20419. //#endregion
  20420. #endregion
  20421. #region New Insert
  20422. string titleFont = $"仿宋",
  20423. contentFont = $"仿宋";
  20424. var fontColor = Color.FromArgb(64, 64, 64);
  20425. //设置标题 团组名称
  20426. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20427. builder.Font.Name = titleFont;
  20428. builder.Font.Color = fontColor;
  20429. builder.Font.Size = 12;
  20430. builder.Font.Bold = true;
  20431. builder.Writeln(teamName);
  20432. //设置副标题 团组出访时间
  20433. builder.Font.Size = 12;
  20434. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20435. builder.Writeln();
  20436. var backgroundColor = Color.FromArgb(199, 199, 199);
  20437. var table = builder.StartTable();
  20438. builder.InsertCell();
  20439. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20440. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20441. builder.CellFormat.Borders.LineWidth = 1;
  20442. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20443. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20444. builder.RowFormat.Height = 40;
  20445. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20446. builder.Font.Name = contentFont;
  20447. builder.Font.Size = 12;
  20448. builder.Font.Bold = true;
  20449. builder.Font.Color = fontColor;
  20450. builder.Write("时间");
  20451. builder.InsertCell();
  20452. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20453. builder.Write("流程");
  20454. builder.InsertCell();
  20455. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20456. builder.Write("说明");
  20457. builder.EndRow();
  20458. //报批资料准备
  20459. if (info1.IsSelectedAirportd)
  20460. {
  20461. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20462. }
  20463. //报批/提供送签资料
  20464. if (info1.IsSelectedApprovalData)
  20465. {
  20466. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20467. }
  20468. //出批件护照办理
  20469. if (info1.IsSelectedIssueApproval)
  20470. {
  20471. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20472. }
  20473. //签证资料准备
  20474. if (info1.IsSelectedVisaInfo)
  20475. {
  20476. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20477. }
  20478. //送签
  20479. if (info1.IsSelectedSendVisa)
  20480. {
  20481. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20482. }
  20483. //出签
  20484. if (info1.IsSelectedIssueVisa)
  20485. {
  20486. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20487. }
  20488. //机票
  20489. if (info1.IsSelectedAirTicket)
  20490. {
  20491. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20492. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20493. }
  20494. //酒店
  20495. if (info1.IsSelectedHotel)
  20496. {
  20497. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20498. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20499. }
  20500. //开行前会
  20501. if (info1.IsSelectedPreTripMeeting)
  20502. {
  20503. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20504. }
  20505. //送机
  20506. if (info1.IsSelectedAirportdDropOff)
  20507. {
  20508. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20509. }
  20510. builder.EndTable();
  20511. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20512. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20513. for (int i = 0; i < table.Rows.Count; i++)
  20514. {
  20515. var row = table.Rows[i];
  20516. //设置宽度
  20517. row.Cells[0].CellFormat.Width = 20.00;
  20518. row.Cells[1].CellFormat.Width = 30.00;
  20519. row.Cells[2].CellFormat.Width = 50.00;
  20520. if (i != 0)
  20521. {
  20522. //边框设置
  20523. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20524. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20525. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20526. }
  20527. }
  20528. #region 页脚插入图片
  20529. // 创建页脚
  20530. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20531. doc.FirstSection.HeadersFooters.Add(footer);
  20532. Paragraph para = new Paragraph(doc);
  20533. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20534. footer.AppendChild(para);
  20535. builder.MoveTo(para);
  20536. string imagePath = "./Images/FMGJ_Log.png";
  20537. builder.InsertImage(imagePath);
  20538. #endregion
  20539. #endregion
  20540. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20541. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20542. string filePath = fileDir + $@"InvertedList/{fileName}";
  20543. doc.Save(filePath);
  20544. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20545. return Ok(JsonView(true, "操作成功!", Url));
  20546. }
  20547. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20548. {
  20549. var fontColor = Color.FromArgb(64, 64, 64);
  20550. builder.InsertCell();
  20551. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20552. builder.RowFormat.Height = 40;
  20553. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20554. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20555. builder.Font.Name = fontName;
  20556. builder.Font.Size = 8;
  20557. builder.Font.Bold = true;
  20558. builder.Font.Color = fontColor;
  20559. builder.Write(dateTime);
  20560. builder.InsertCell();
  20561. builder.Font.Size = 9;
  20562. builder.Font.Bold = true;
  20563. builder.Font.Color = fontColor;
  20564. builder.Write(content);
  20565. builder.InsertCell();
  20566. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20567. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20568. builder.Font.Size = 9;
  20569. builder.Font.Bold = false;
  20570. builder.Font.Color = fontColor;
  20571. builder.Write(reamrk);
  20572. builder.EndRow();
  20573. }
  20574. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20575. {
  20576. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20577. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20578. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20579. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20580. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20581. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20582. }
  20583. #endregion
  20584. #region 会务倒推表
  20585. /// <summary>
  20586. /// 会务倒推表
  20587. /// Init
  20588. /// </summary>
  20589. /// <returns></returns>
  20590. [HttpPost]
  20591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20592. public async Task<IActionResult> InforRetrogressTableInit()
  20593. {
  20594. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20595. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20596. return Ok(JsonView(false, groupData.Msg));
  20597. }
  20598. /// <summary>
  20599. /// 会务倒推表
  20600. /// ExcelDownload
  20601. /// </summary>
  20602. /// <param name="dto"></param>
  20603. /// <returns></returns>
  20604. [HttpPost]
  20605. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20607. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20608. {
  20609. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20610. var validatorRes = await validator.ValidateAsync(dto);
  20611. if (!validatorRes.IsValid)
  20612. {
  20613. StringBuilder sb = new StringBuilder();
  20614. foreach (var item in validatorRes.Errors)
  20615. {
  20616. sb.AppendLine(item.ErrorMessage);
  20617. }
  20618. return Ok(JsonView(false, sb.ToString()));
  20619. }
  20620. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20621. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20622. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20623. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20624. #region Excel
  20625. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20626. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20627. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20628. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20629. var fileNamePrefix = string.Empty;
  20630. if (days >= 30)
  20631. {
  20632. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20633. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20634. }
  20635. else if (days < 30 && days > 7)
  20636. {
  20637. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20638. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20639. }
  20640. else if (days <= 7)
  20641. {
  20642. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20643. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20644. }
  20645. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20646. fileName = CommonFun.ValidFileName(fileName);
  20647. //载入模板
  20648. WorkbookDesigner designer = new WorkbookDesigner();
  20649. designer.Workbook = new Workbook(tempPath);
  20650. designer.Process();
  20651. if (!Directory.Exists(savePath))
  20652. {
  20653. Directory.CreateDirectory(savePath);
  20654. }
  20655. string serverPath = $"{savePath}{fileName}";
  20656. designer.Workbook.Save(serverPath);
  20657. string rst = $"{servicePath}{ftpPath}{fileName}";
  20658. #endregion
  20659. return Ok(JsonView(new { url = rst }));
  20660. }
  20661. #endregion
  20662. #region 三公签证费用(签证费、代办费)
  20663. /// <summary>
  20664. /// 三公签证费用(签证费、代办费)
  20665. /// List
  20666. /// </summary>
  20667. /// <returns></returns>
  20668. [HttpPost]
  20669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20670. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20671. {
  20672. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  20673. }
  20674. /// <summary>
  20675. /// 三公签证费用(签证费、代办费)
  20676. /// Add Or Update
  20677. /// </summary>
  20678. /// <returns></returns>
  20679. [HttpPost]
  20680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20681. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20682. {
  20683. var _view = await _visaFeeInfoRep.Update(_dto);
  20684. if (_view.Code != 0)
  20685. {
  20686. return Ok(JsonView(false, _view.Msg));
  20687. }
  20688. return Ok(JsonView(true, _view.Msg));
  20689. }
  20690. #endregion
  20691. #region 酒店询价
  20692. /// <summary>
  20693. /// 酒店询价
  20694. /// Init
  20695. /// </summary>
  20696. /// <returns></returns>
  20697. [HttpPost]
  20698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20699. public async Task<IActionResult> PostHotelInquiryInit()
  20700. {
  20701. var res = await _hotelInquiryRep._Init();
  20702. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20703. return Ok(JsonView(true, res.Msg, res.Data));
  20704. }
  20705. /// <summary>
  20706. /// 酒店询价
  20707. /// page Item
  20708. /// </summary>
  20709. /// <param name="_dto"></param>
  20710. /// <returns></returns>
  20711. [HttpPost]
  20712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20713. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20714. {
  20715. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20716. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20717. var view = res.Data as PageDataViewBase;
  20718. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20719. }
  20720. /// <summary>
  20721. /// 酒店询价
  20722. /// info
  20723. /// </summary>
  20724. /// <param name="_dto"></param>
  20725. /// <returns></returns>
  20726. [HttpPost]
  20727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20728. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20729. {
  20730. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20731. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20732. return Ok(JsonView(true, res.Msg, res.Data));
  20733. }
  20734. /// <summary>
  20735. /// 酒店询价
  20736. /// Add Or Edit
  20737. /// </summary>
  20738. /// <param name="_dto"></param>
  20739. /// <returns></returns>
  20740. [HttpPost]
  20741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20742. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20743. {
  20744. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20745. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20746. return Ok(JsonView(true, res.Msg, res.Data));
  20747. }
  20748. /// <summary>
  20749. /// 酒店询价
  20750. /// Del
  20751. /// </summary>
  20752. /// <param name="_dto"></param>
  20753. /// <returns></returns>
  20754. [HttpPost]
  20755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20756. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20757. {
  20758. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20759. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20760. return Ok(JsonView(true, res.Msg, res.Data));
  20761. }
  20762. #endregion
  20763. #region 下载匹配op行程单
  20764. /// <summary>
  20765. /// 匹配op行程单
  20766. /// Init
  20767. /// </summary>
  20768. /// <param name="dto">团组列表请求dto</param>
  20769. /// <returns></returns>
  20770. [HttpPost]
  20771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20772. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20773. {
  20774. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20775. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20776. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20777. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20778. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20779. .Where(it => it.IsDel == 0)
  20780. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20781. .OrderByDescending(it => it.VisitStartDate)
  20782. .ToList();
  20783. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20784. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20785. var diids = groupInfos.Select(it => it.Id).ToList();
  20786. List<string> countrys = new List<string>();
  20787. foreach (var item in country)
  20788. {
  20789. var data = _groupRepository.FormartTeamName(item);
  20790. var dataArray = _groupRepository.GroupSplitCountry(data);
  20791. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20792. }
  20793. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20794. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20795. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20796. foreach (var item in areaItem)
  20797. {
  20798. string areaStr = item.Value;
  20799. if (!string.IsNullOrEmpty(areaStr))
  20800. {
  20801. string[] str1 = areaStr.Split("-");
  20802. if (str1.Length > 0)
  20803. {
  20804. areaArray.AddRange(str1);
  20805. }
  20806. }
  20807. }
  20808. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20809. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20810. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20811. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20812. .ToList();
  20813. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20814. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20815. .Where(it => countriesIds.Contains(it.Id))
  20816. .Select(it => new { it.Id, Name = it.Name_CN })
  20817. .ToList();
  20818. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20819. .Select(it => it.TeamName).ToList();
  20820. stopwatch.Stop();
  20821. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20822. }
  20823. ///// <summary>
  20824. ///// 匹配op行程单
  20825. ///// Init 查询区域数据
  20826. ///// </summary>
  20827. ///// <param name="dto">团组列表请求dto</param>
  20828. ///// <returns></returns>
  20829. //[HttpPost]
  20830. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20831. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20832. //{
  20833. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20834. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20835. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20836. // if (string.IsNullOrEmpty(countriesDataStr))
  20837. // {
  20838. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20839. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20840. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20841. // }
  20842. // else
  20843. // {
  20844. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20845. // }
  20846. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20847. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20848. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20849. // List<dynamic> childList = new List<dynamic>();
  20850. // int parentId = dto.CountriesId;
  20851. // if (provinceData.Count > 1)
  20852. // {
  20853. // foreach (var item1 in provinceData)
  20854. // {
  20855. // List<dynamic> childList1 = new List<dynamic>();
  20856. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20857. // foreach (var item2 in citiesData1)
  20858. // {
  20859. // List<dynamic> childList2 = new List<dynamic>();
  20860. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20861. // foreach (var item3 in countiesData1)
  20862. // {
  20863. // childList2.Add(new
  20864. // {
  20865. // id = item3.Id,
  20866. // parentId = item2.Id,
  20867. // level = "district",
  20868. // name = item3.Name_CN,
  20869. // });
  20870. // }
  20871. // childList1.Add(new
  20872. // {
  20873. // id = item2.Id,
  20874. // parentId = item1.Id,
  20875. // level = "city",
  20876. // name = item2.Name_CN,
  20877. // childList = childList2
  20878. // });
  20879. // }
  20880. // childList.Add(new
  20881. // {
  20882. // id = item1.Id,
  20883. // parentId = parentId,
  20884. // level = "province",
  20885. // name = item1.Name_CN,
  20886. // childList = childList1
  20887. // });
  20888. // }
  20889. // //城市
  20890. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20891. // foreach (var item2 in citiesData2)
  20892. // {
  20893. // List<dynamic> childList22 = new List<dynamic>();
  20894. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20895. // foreach (var item3 in countiesData1)
  20896. // {
  20897. // childList22.Add(new
  20898. // {
  20899. // id = item3.Id,
  20900. // parentId = item2.Id,
  20901. // level = "district",
  20902. // name = item3.Name_CN,
  20903. // });
  20904. // }
  20905. // childList.Add(new
  20906. // {
  20907. // id = item2.Id,
  20908. // parentId = parentId,
  20909. // level = "city",
  20910. // name = item2.Name_CN,
  20911. // childList = childList22
  20912. // });
  20913. // }
  20914. // }
  20915. // else
  20916. // {
  20917. // foreach (var item2 in citiesData)
  20918. // {
  20919. // string cname = item2.Name_CN;
  20920. // List<dynamic> childList1 = new List<dynamic>();
  20921. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20922. // foreach (var item3 in countiesData1)
  20923. // {
  20924. // childList1.Add(new
  20925. // {
  20926. // Id = item3.Id,
  20927. // parentId = item2.Id,
  20928. // level = "district",
  20929. // name = item3.Name_CN
  20930. // });
  20931. // }
  20932. // childList.Add(new
  20933. // {
  20934. // id = item2.Id,
  20935. // parentId = parentId,
  20936. // level = "city",
  20937. // name = item2.Name_CN,
  20938. // childList = childList1
  20939. // });
  20940. // }
  20941. // }
  20942. // stopwatch.Stop();
  20943. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20944. //}
  20945. /// <summary>
  20946. /// 匹配op行程单
  20947. /// 接团信息列表 Page
  20948. /// </summary>
  20949. /// <param name="dto">团组列表请求dto</param>
  20950. /// <returns></returns>
  20951. [HttpPost]
  20952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20953. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20954. {
  20955. var swatch = new Stopwatch();
  20956. swatch.Start();
  20957. #region 参数验证
  20958. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20959. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20960. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20961. #region 页面操作权限验证
  20962. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20963. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20964. #endregion
  20965. #endregion
  20966. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20967. {
  20968. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20969. //string sqlWhere = "";
  20970. if (!string.IsNullOrEmpty(dto.Country))
  20971. {
  20972. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20973. }
  20974. if (!string.IsNullOrEmpty(dto.Area))
  20975. {
  20976. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20977. }
  20978. if (!string.IsNullOrEmpty(dto.TeamName))
  20979. {
  20980. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20981. }
  20982. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20983. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20984. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20985. swatch.Stop();
  20986. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20987. }
  20988. else
  20989. {
  20990. return Ok(JsonView(false, "查询失败"));
  20991. }
  20992. }
  20993. /// <summary>
  20994. /// 匹配op行程单
  20995. /// 行程单下载
  20996. /// </summary>
  20997. /// <param name="dto">团组列表请求dto</param>
  20998. /// <returns></returns>
  20999. [HttpPost]
  21000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21001. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  21002. {
  21003. #region 参数验证
  21004. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21005. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21006. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21007. #region 页面操作权限验证
  21008. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21009. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  21010. #endregion
  21011. #endregion
  21012. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21013. {
  21014. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  21015. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  21016. }
  21017. else
  21018. {
  21019. return Ok(JsonView(false, "下载失败!"));
  21020. }
  21021. }
  21022. #endregion
  21023. #region 国家信息 数据 注释
  21024. //[HttpPost]
  21025. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  21026. //{
  21027. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  21028. // foreach (var item in dto)
  21029. // {
  21030. // infos.Add(new Grp_GroupsTaskAssignment()
  21031. // {
  21032. // DIId = item,
  21033. // CTId = 82,
  21034. // UId = 248,
  21035. // IsEnable = 1,
  21036. // CreateUserId = 233,
  21037. // CreateTime = DateTime.Now,
  21038. // IsDel = 0
  21039. // });
  21040. // infos.Add(new Grp_GroupsTaskAssignment()
  21041. // {
  21042. // DIId = item,
  21043. // CTId = 82,
  21044. // UId = 286,
  21045. // IsEnable = 1,
  21046. // CreateUserId = 233,
  21047. // CreateTime = DateTime.Now,
  21048. // IsDel = 0
  21049. // });
  21050. // }
  21051. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  21052. // return Ok("操作成功");
  21053. //}
  21054. //public class paramJsonDto
  21055. //{
  21056. // public List<CountriesInfo> str { get; set; }
  21057. //}
  21058. //[HttpPost]
  21059. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  21060. //{
  21061. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  21062. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  21063. // List<Sys_Cities> cities = new List<Sys_Cities>();
  21064. // List<Sys_Cities> districts = new List<Sys_Cities>();
  21065. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21066. // _sqlSugar.BeginTran();
  21067. // int countitiesIndex = 0;
  21068. // foreach (var item in dto.str)
  21069. // {
  21070. // dynamic data = item.c;
  21071. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  21072. // if (data != null)
  21073. // {
  21074. // countitiesIndex++;
  21075. // foreach (var item1 in data)
  21076. // {
  21077. // string cnname = item1.cn;
  21078. // string enname = item1.en;
  21079. // Sys_Cities provinceInfo = new Sys_Cities()
  21080. // {
  21081. // CountriesId = countriesId,
  21082. // Name_CN = cnname,
  21083. // Name_EN = enname,
  21084. // ParentId = 0,
  21085. // IsCapital = 1,
  21086. // CreateUserId = 208,
  21087. // CreateTime = DateTime.Now,
  21088. // IsDel = 0
  21089. // };
  21090. // if (item1.lv == "province") //省份
  21091. // {
  21092. // provinceInfo.Level = 1;
  21093. // int provinceId = 0;
  21094. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  21095. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  21096. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21097. // var data1 = item1.c;
  21098. // foreach (var item2 in data1)
  21099. // {
  21100. // if (item2.lv == "city")
  21101. // {
  21102. // string citycnname = item2.cn;
  21103. // string cityenname = item2.en;
  21104. // Sys_Cities cityInfo = new Sys_Cities()
  21105. // {
  21106. // CountriesId = countriesId,
  21107. // ParentId = provinceId,
  21108. // Level = 2,
  21109. // Name_CN = citycnname,
  21110. // Name_EN = cityenname,
  21111. // IsCapital = 1,
  21112. // CreateUserId = 208,
  21113. // CreateTime = DateTime.Now,
  21114. // IsDel = 0
  21115. // };
  21116. // if (item2.c != null)
  21117. // {
  21118. // int cityId = 0;
  21119. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  21120. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21121. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  21122. // foreach (var item3 in item2.c)
  21123. // {
  21124. // if (item3.lv == "district")
  21125. // {
  21126. // var districtInfo = new Sys_Cities()
  21127. // {
  21128. // CountriesId = countriesId,
  21129. // Name_CN = item3.cn,
  21130. // Name_EN = item3.en,
  21131. // Level = 3,
  21132. // ParentId = cityId,
  21133. // IsCapital = 1,
  21134. // CreateUserId = 208,
  21135. // CreateTime = DateTime.Now,
  21136. // IsDel = 0
  21137. // };
  21138. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21139. // //{
  21140. // districts.Add(districtInfo);
  21141. // //}
  21142. // }
  21143. // }
  21144. // }
  21145. // else
  21146. // {
  21147. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  21148. // //{
  21149. // cities.Add(cityInfo);
  21150. // //}
  21151. // }
  21152. // }
  21153. // }
  21154. // }
  21155. // else if (item1.lv == "city")//城市
  21156. // {
  21157. // provinceInfo.Level = 2;
  21158. // if (item1.c != null)
  21159. // {
  21160. // int cityId = 0;
  21161. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  21162. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21163. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21164. // foreach (var item3 in item1.c)
  21165. // {
  21166. // if (item3.lv == "district")
  21167. // {
  21168. // var districtInfo = new Sys_Cities()
  21169. // {
  21170. // CountriesId = countriesId,
  21171. // Name_CN = item3.cn,
  21172. // Name_EN = item3.en,
  21173. // Level = 3,
  21174. // ParentId = cityId,
  21175. // IsCapital = 1,
  21176. // CreateUserId = 208,
  21177. // CreateTime = DateTime.Now,
  21178. // IsDel = 0
  21179. // };
  21180. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21181. // //{
  21182. // districts.Add(districtInfo);
  21183. // //}
  21184. // }
  21185. // }
  21186. // }
  21187. // else
  21188. // {
  21189. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  21190. // //{
  21191. // cities.Add(provinceInfo);
  21192. // //}
  21193. // }
  21194. // }
  21195. // }
  21196. // }
  21197. // }
  21198. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  21199. // cities = cities.Distinct().ToList();
  21200. // districts = districts.Distinct().ToList();
  21201. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  21202. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  21203. // cities.AddRange(districts);
  21204. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  21205. // //_sqlSugar.RollbackTran();
  21206. // _sqlSugar.CommitTran();
  21207. // return Ok(JsonView(false, "操作成功!"));
  21208. //}
  21209. //[HttpPost]
  21210. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  21211. //{
  21212. // List<CountitiesInfo> infos = dto.MyProperty;
  21213. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  21214. // _sqlSugar.BeginTran();
  21215. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21216. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  21217. // foreach (var item in infos)
  21218. // {
  21219. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  21220. // if (countryInfo != null)
  21221. // {
  21222. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  21223. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  21224. // if (cityInfo1 != null)
  21225. // {
  21226. // cityInfo1.IsCapital = 0;
  21227. // cityInfos.Add(cityInfo1);
  21228. // }
  21229. // }
  21230. // }
  21231. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  21232. // .UpdateColumns(it => it.IsCapital)
  21233. // .WhereColumns(it => it.Id)
  21234. // .ExecuteCommand();
  21235. // //_sqlSugar.RollbackTran();
  21236. // _sqlSugar.CommitTran();
  21237. // return Ok(JsonView(false, "操作成功!"));
  21238. //}
  21239. //public class CounrtiesDto
  21240. //{
  21241. // public List<CountitiesInfo> MyProperty { get; set; }
  21242. //}
  21243. //public class CountitiesInfo
  21244. //{
  21245. // /// <summary>
  21246. // /// 圣约翰
  21247. // /// </summary>
  21248. // public string capital_name_chinese { get; set; }
  21249. // /// <summary>
  21250. // ///
  21251. // /// </summary>
  21252. // public string capital_name { get; set; }
  21253. // /// <summary>
  21254. // ///
  21255. // /// </summary>
  21256. // public string country_type { get; set; }
  21257. // /// <summary>
  21258. // /// 安提瓜和巴布达
  21259. // /// </summary>
  21260. // public string country_name_chinese { get; set; }
  21261. // /// <summary>
  21262. // /// 安提瓜和巴布达
  21263. // /// </summary>
  21264. // public string country_name_chinese_short { get; set; }
  21265. // /// <summary>
  21266. // /// 安提瓜和巴布达
  21267. // /// </summary>
  21268. // public string country_name_chinese_UN { get; set; }
  21269. // /// <summary>
  21270. // ///
  21271. // /// </summary>
  21272. // public string country_name_english_abbreviation { get; set; }
  21273. // /// <summary>
  21274. // ///
  21275. // /// </summary>
  21276. // public string country_name_english_formal { get; set; }
  21277. // /// <summary>
  21278. // ///
  21279. // /// </summary>
  21280. // public string country_name_english_UN { get; set; }
  21281. // /// <summary>
  21282. // ///
  21283. // /// </summary>
  21284. // public string continent_name { get; set; }
  21285. // /// <summary>
  21286. // ///
  21287. // /// </summary>
  21288. // public string subregion_name { get; set; }
  21289. // /// <summary>
  21290. // ///
  21291. // /// </summary>
  21292. // public string country_code2 { get; set; }
  21293. // /// <summary>
  21294. // ///
  21295. // /// </summary>
  21296. // public string country_code3 { get; set; }
  21297. // /// <summary>
  21298. // ///
  21299. // /// </summary>
  21300. // public string phone_code { get; set; }
  21301. //}
  21302. //public class CountriesInfo : BasicInfo
  21303. //{
  21304. // public List<CitiesInfo> c { get; set; }
  21305. //}
  21306. //public class CitiesInfo : BasicInfo
  21307. //{
  21308. // public List<AreaInfo> c { get; set; }
  21309. //}
  21310. //public class AreaInfo : BasicInfo
  21311. //{
  21312. // public List<AreaInfo> c { get; set; }
  21313. //}
  21314. //public class BasicInfo
  21315. //{
  21316. // public string code { get; set; }
  21317. // public string cn { get; set; }
  21318. // public string lv { get; set; }
  21319. // public string en { get; set; }
  21320. //}
  21321. #endregion
  21322. #region 查看邀请方
  21323. /// <summary>
  21324. /// 查看邀请方
  21325. /// 邀请方信息 Init
  21326. /// </summary>
  21327. /// <param name="dto"></param>
  21328. /// <returns></returns>
  21329. [HttpPost]
  21330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21331. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21332. {
  21333. string sqlWhere = string.Empty;
  21334. if (!string.IsNullOrEmpty(dto.Search))
  21335. {
  21336. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21337. }
  21338. string sql = string.Format($@"Select
  21339. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21340. Id,
  21341. UnitName
  21342. From Res_InvitationOfficialActivityData
  21343. Where IsDel = 0
  21344. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21345. RefAsync<int> total = 0;
  21346. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21347. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21348. }
  21349. /// <summary>
  21350. /// 查看邀请方
  21351. /// 国家信息 Init
  21352. /// </summary>
  21353. /// <param name="dto"></param>
  21354. /// <returns></returns>
  21355. [HttpPost]
  21356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21357. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21358. {
  21359. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21360. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21361. var diids = groupInfos.Select(it => it.Id).ToList();
  21362. List<string> countrys = new List<string>();
  21363. foreach (var item in country)
  21364. {
  21365. var data = _groupRepository.FormartTeamName(item);
  21366. var dataArray = _groupRepository.GroupSplitCountry(data);
  21367. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21368. }
  21369. countrys = countrys.Distinct().ToList();
  21370. for (int i = 0; i < countrys.Count; i++)
  21371. {
  21372. string item = countrys[i];
  21373. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21374. {
  21375. countrys.Remove(item);
  21376. i--;
  21377. }
  21378. }
  21379. RefAsync<int> total = 0;
  21380. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21381. .Where(it => countrys.Contains(it.Name_CN))
  21382. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21383. .Select(it => new { id = it.Id, name = it.Name_CN })
  21384. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21385. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21386. }
  21387. /// <summary>
  21388. /// 查看邀请方
  21389. /// 城市信息 Init
  21390. /// </summary>
  21391. /// <param name="dto"></param>
  21392. /// <returns></returns>
  21393. [HttpPost]
  21394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21395. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21396. {
  21397. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21398. RefAsync<int> total = 0;
  21399. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21400. .Where(it => it.CountriesId == dto.CountiesId)
  21401. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21402. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21403. .Select(it => new { id = it.Id, name = it.Name_CN })
  21404. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21405. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21406. }
  21407. /// <summary>
  21408. /// 查看邀请方
  21409. /// 团组名称 Init
  21410. /// </summary>
  21411. /// <param name="dto"></param>
  21412. /// <returns></returns>
  21413. [HttpPost]
  21414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21415. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21416. {
  21417. var watch = new Stopwatch();
  21418. watch.Start();
  21419. RefAsync<int> total = 0;
  21420. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21421. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21422. .Where((oa, di) => oa.IsDel == 0)
  21423. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21424. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21425. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21426. .Distinct()
  21427. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21428. watch.Stop();
  21429. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21430. }
  21431. /// <summary>
  21432. /// 查看邀请方
  21433. /// 团组 & 邀请方信息
  21434. /// </summary>
  21435. /// <param name="dto"></param>
  21436. /// <returns></returns>
  21437. [HttpPost]
  21438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21439. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21440. {
  21441. var watch = new Stopwatch();
  21442. watch.Start();
  21443. RefAsync<int> total = 0;
  21444. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21445. .AS("Grp_DelegationInfo")
  21446. .Includes(x => x.InvitingInfos)
  21447. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21448. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21449. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21450. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21451. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21452. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21453. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21454. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21455. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21456. infos.ForEach(x =>
  21457. {
  21458. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21459. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21460. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21461. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21462. });
  21463. watch.Stop();
  21464. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21465. }
  21466. #endregion
  21467. #region 报批行程
  21468. /// <summary>
  21469. /// 报批行程初始化
  21470. /// </summary>
  21471. /// <param name="dto"></param>
  21472. /// <returns></returns>
  21473. [HttpPost]
  21474. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21475. {
  21476. const int chiNumber = 5;
  21477. var jw = JsonView(false);
  21478. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21479. var group = groupList.First();
  21480. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21481. group = groupList.First(x => x.Id == diid);
  21482. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21483. .Where(x => x.DiId == diid && x.IsDel == 0)
  21484. .ToArray();
  21485. var count = 1;
  21486. foreach (var item in blackCodeList)
  21487. {
  21488. if (string.IsNullOrWhiteSpace(item.Title))
  21489. {
  21490. item.Title = "未设置名称数据" + count;
  21491. }
  21492. count++;
  21493. }
  21494. ;
  21495. if (group == null)
  21496. {
  21497. jw.Msg = "暂无团组!";
  21498. return Ok(jw);
  21499. }
  21500. var data = new
  21501. {
  21502. groupList = groupList.Select(x => new
  21503. {
  21504. x.TeamName,
  21505. x.Id
  21506. }),
  21507. content = new ArrayList(),
  21508. groupInfo = new
  21509. {
  21510. group.VisitDays,
  21511. group.TourCode,
  21512. group.VisitPNumber,
  21513. group.TeamName,
  21514. group.Id,
  21515. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21516. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21517. group.ClientUnit
  21518. },
  21519. blackCodeList = blackCodeList.Select(x => new
  21520. {
  21521. x.Title,
  21522. x.Id
  21523. }),
  21524. FileTempList = new ArrayList()
  21525. {
  21526. new { Index = 1,FileName = "旧模板" },
  21527. new { Index = 2,FileName = "省外办" },
  21528. new { Index = 3,FileName = "市外办" },
  21529. }
  21530. };
  21531. var resultArr = new ArrayList();
  21532. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21533. #region 默认不生成行程
  21534. //if (content.Count == 0)
  21535. //{
  21536. // var stay = "-";
  21537. // var cityPath = "-";
  21538. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21539. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21540. // .ToList();
  21541. // //添加城市路径以及住宿地
  21542. // //黑屏代码数据
  21543. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21544. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21545. // {
  21546. // jw = JsonView(true, "黑屏代码有误!", data);
  21547. // return Ok(jw);
  21548. // }
  21549. // data = data with
  21550. // {
  21551. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21552. // {
  21553. // x.Title,
  21554. // x.Id,
  21555. // }).ToArray())
  21556. // };
  21557. // foreach (DataRow row in dtBlack.Rows)
  21558. // {
  21559. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21560. // {
  21561. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21562. // return Ok(jw);
  21563. // }
  21564. // }
  21565. // //黑屏代码获取时间区间
  21566. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21567. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21568. // _sqlSugar.BeginTran();
  21569. // for (int i = 0; i < timeArr.Count; i++)
  21570. // {
  21571. // stay = "-";
  21572. // cityPath = "-";
  21573. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21574. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21575. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21576. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21577. // if (tbSelect.Length > 0)
  21578. // {
  21579. // List<string> threeCodeStr = new List<string>();
  21580. // foreach (var item in tbSelect)
  21581. // {
  21582. // var threeCode = item["Three"].ToString() ?? "";
  21583. // if (threeCode.Length == 6)
  21584. // {
  21585. // var start = threeCode.Substring(0, 3);
  21586. // var end = threeCode.Substring(3, 3);
  21587. // if (threeCodeStr.Count == 0)
  21588. // {
  21589. // threeCodeStr.Add(start);
  21590. // threeCodeStr.Add(end);
  21591. // }
  21592. // else
  21593. // {
  21594. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21595. // {
  21596. // threeCodeStr.Add(end);
  21597. // }
  21598. // else
  21599. // {
  21600. // threeCodeStr.Add(start);
  21601. // threeCodeStr.Add(end);
  21602. // }
  21603. // }
  21604. // }
  21605. // }
  21606. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21607. // var last = threeCodeStr.Last();
  21608. // foreach (var item in threeCodeStr)
  21609. // {
  21610. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21611. // if (item.Equals(last))
  21612. // {
  21613. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21614. // }
  21615. // }
  21616. // cityPath = cityPath.Trim('-');
  21617. // }
  21618. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21619. // appro.Diid = diid ?? -1;
  21620. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21621. // appro.Id = thisId;
  21622. // appro.CreateUserId = dto.UserId;
  21623. // appro.CreateTime = DateTime.Now;
  21624. // content.Add(appro);
  21625. // }
  21626. // _sqlSugar.CommitTran();
  21627. //}
  21628. #endregion
  21629. foreach (var x in content)
  21630. {
  21631. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21632. if (chiList.Count < chiNumber)
  21633. {
  21634. for (int i = chiList.Count; i < chiNumber; i++)
  21635. {
  21636. chiList.Add(new Grp_ApprovalTravelDetails());
  21637. }
  21638. }
  21639. resultArr.Add(new
  21640. {
  21641. x.Id,
  21642. x.Date,
  21643. x.Diid,
  21644. chiList = chiList.Select(x1 => new
  21645. {
  21646. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21647. x1.Details,
  21648. x1.ParentId,
  21649. x1.Id
  21650. })
  21651. });
  21652. }
  21653. data = data with
  21654. {
  21655. content = resultArr,
  21656. };
  21657. jw = JsonView(true, "获取成功!", data);
  21658. return Ok(jw);
  21659. }
  21660. /// <summary>
  21661. /// 报批行程删除
  21662. /// </summary>
  21663. /// <param name="dto"></param>
  21664. /// <returns></returns>
  21665. [HttpPost]
  21666. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21667. {
  21668. var jw = JsonView(false);
  21669. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21670. if (group == null)
  21671. {
  21672. jw.Msg = "团组参数有误!";
  21673. return Ok(jw);
  21674. }
  21675. try
  21676. {
  21677. _sqlSugar.BeginTran();
  21678. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21679. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21680. {
  21681. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21682. DeleteUserId = dto.uesrId,
  21683. IsDel = 1
  21684. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21685. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21686. {
  21687. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21688. DeleteUserId = dto.uesrId,
  21689. IsDel = 1
  21690. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21691. _sqlSugar.CommitTran();
  21692. jw = JsonView(true, "删除成功");
  21693. }
  21694. catch (Exception ex)
  21695. {
  21696. jw = JsonView(false, ex.Message);
  21697. }
  21698. return Ok(jw);
  21699. }
  21700. /// <summary>
  21701. /// 报批行程保存
  21702. /// </summary>
  21703. /// <param name="dto"></param>
  21704. /// <returns></returns>
  21705. [HttpPost]
  21706. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21707. {
  21708. var jw = JsonView(false);
  21709. var Find = dto.Arr.Find(x => x.id == 0);
  21710. if (Find != null)
  21711. {
  21712. jw.Msg = "生成的ID为0!";
  21713. return Ok(jw);
  21714. }
  21715. foreach (var item in dto.Arr)
  21716. {
  21717. foreach (var chi in item.chiList)
  21718. {
  21719. if (chi.parentId == 0)
  21720. {
  21721. chi.parentId = item.id;
  21722. }
  21723. }
  21724. }
  21725. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21726. _sqlSugar.BeginTran();
  21727. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21728. {
  21729. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21730. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21731. {
  21732. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21733. DeleteUserId = dto.UserId,
  21734. IsDel = 1
  21735. }).ExecuteCommand();
  21736. }
  21737. try
  21738. {
  21739. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21740. {
  21741. CreateTime = DateTime.Now,
  21742. CreateUserId = dto.UserId,
  21743. Details = x.details,
  21744. ParentId = x.parentId,
  21745. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21746. Remark = "",
  21747. IsDel = 0
  21748. }).ToList()).ExecuteCommand();
  21749. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21750. {
  21751. Id = x.id,
  21752. Details = x.details,
  21753. ParentId = x.parentId,
  21754. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21755. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21756. {
  21757. Details = x.Details,
  21758. ParentId = x.ParentId,
  21759. Time = x.Time
  21760. }).ExecuteCommand();
  21761. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21762. {
  21763. Id = x.id,
  21764. Date = x.date,
  21765. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21766. {
  21767. Date = x.Date
  21768. }).ExecuteCommand();
  21769. _sqlSugar.CommitTran();
  21770. jw = JsonView(true, "保存成功!");
  21771. }
  21772. catch (Exception ex)
  21773. {
  21774. _sqlSugar.RollbackTran();
  21775. jw = JsonView(false, "保存失败!" + ex.Message);
  21776. }
  21777. return Ok(jw);
  21778. }
  21779. /// <summary>
  21780. /// 报批行程生成
  21781. /// </summary>
  21782. /// <param name="dto"></param>
  21783. /// <returns></returns>
  21784. [HttpPost]
  21785. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21786. {
  21787. var jw = JsonView(false);
  21788. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21789. if (group == null)
  21790. {
  21791. jw.Msg = "暂无该团组!";
  21792. return Ok(jw);
  21793. }
  21794. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21795. //黑屏代码数据
  21796. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21797. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21798. {
  21799. jw.Msg = "黑屏代码有误!";
  21800. return Ok(jw);
  21801. }
  21802. foreach (DataRow row in dtBlack.Rows)
  21803. {
  21804. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21805. {
  21806. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21807. return Ok(jw);
  21808. }
  21809. }
  21810. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21811. var resultArr = new ArrayList();
  21812. //if (officialActivitiesArr.Count == 0)
  21813. //{
  21814. // jw.Msg = "暂无公务出访信息!";
  21815. // return Ok(jw);
  21816. //}
  21817. try
  21818. {
  21819. _sqlSugar.BeginTran();
  21820. DeleteApprovalJourney(new
  21821. Domain.Dtos.Groups.DeleteApprovalJourney
  21822. {
  21823. Diid = dto.Diid,
  21824. uesrId = dto.Userid
  21825. });
  21826. var stay = "-";
  21827. var cityPath = "-";
  21828. var arriveCountry = string.Empty;
  21829. //添加城市路径以及住宿地
  21830. //黑屏代码获取时间区间
  21831. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21832. var empty = "【未收入该三字码!请机票同事录入】";
  21833. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21834. #region 配置公务活动时间
  21835. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21836. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21837. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21838. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21839. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21840. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21841. {
  21842. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,6,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  21843. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,8,30,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  21844. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21845. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21846. };
  21847. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21848. {
  21849. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,7,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  21850. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,9,0,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  21851. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21852. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21853. };
  21854. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21855. {
  21856. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,18,0,0), new List<string>{"9:00-10:30","11:00-12:00", "14:00-15:30","16:00-17:00" }),
  21857. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,15,30,0), new List<string>{"9:00-10:30", "11:00-12:00", "14:00-15:00","15:00-16:00"}),
  21858. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21859. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21860. };
  21861. #endregion
  21862. var nextDayNum = 0;
  21863. for (int i = 0; i < timeArr.Count; i++)
  21864. {
  21865. stay = "-";
  21866. cityPath = "-";
  21867. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21868. DateTime NewData = DateTime.Parse(timeArr[i]);
  21869. //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();
  21870. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21871. if (nextDayNum > 0)
  21872. {
  21873. nextDayNum--;
  21874. }
  21875. if (tbSelect.Length > 0)
  21876. {
  21877. List<string> threeCodeStr = new List<string>();
  21878. bool isTrade = false;
  21879. string trip = string.Empty;
  21880. foreach (var item in tbSelect)
  21881. {
  21882. if (nextDayNum == 0)
  21883. {
  21884. nextDayNum = Convert.ToInt32(item["Sign"]);
  21885. }
  21886. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21887. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21888. var takeOffTime = DateTime.Parse(timeArr[i]);
  21889. var fallToTime = DateTime.Parse(timeArr[i]);
  21890. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21891. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21892. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21893. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21894. if (nextDayNum > 0)
  21895. {
  21896. fallToTime = fallToTime.AddDays(nextDayNum);
  21897. }
  21898. trip = string.Empty;
  21899. var start = string.Empty;
  21900. var end = string.Empty;
  21901. var threeCode = item["Three"].ToString() ?? "";
  21902. if (threeCode.Length == 6)
  21903. {
  21904. start = threeCode.Substring(0, 3);
  21905. end = threeCode.Substring(3, 3);
  21906. if (threeCodeStr.Count == 0)
  21907. {
  21908. threeCodeStr.Add(start);
  21909. threeCodeStr.Add(end);
  21910. }
  21911. else
  21912. {
  21913. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21914. {
  21915. threeCodeStr.Add(end);
  21916. }
  21917. else
  21918. {
  21919. threeCodeStr.Add(start);
  21920. threeCodeStr.Add(end);
  21921. }
  21922. }
  21923. }
  21924. //处理机票信息
  21925. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21926. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21927. if (start_Object == null)
  21928. {
  21929. start_Object = new Res_ThreeCode()
  21930. {
  21931. AirPort = empty,
  21932. AirPort_En = empty,
  21933. City = empty,
  21934. Country = empty,
  21935. Four = empty,
  21936. Three = empty,
  21937. };
  21938. }
  21939. if (end_Object == null)
  21940. {
  21941. end_Object = new Res_ThreeCode()
  21942. {
  21943. AirPort = empty,
  21944. AirPort_En = empty,
  21945. City = empty,
  21946. Country = empty,
  21947. Four = empty,
  21948. Three = empty,
  21949. };
  21950. }
  21951. //机型判断
  21952. string airModel = item["AirModel"].ToString();
  21953. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21954. string flightTime = item["FlightTime"].ToString();
  21955. flightTime = ParseBlackTime(flightTime);
  21956. //航班号
  21957. string flightcode = item["Fliagtcode"].ToString();
  21958. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21959. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21960. if (aircompany == null)
  21961. {
  21962. aircompany = new Res_AirCompany
  21963. {
  21964. CnName = hsEmpty,
  21965. EnName = hsEmpty,
  21966. ShortCode = hsEmpty,
  21967. };
  21968. }
  21969. //航班前公务安排
  21970. if (tbSelect.First().Equals(item) && i != 0)
  21971. {
  21972. foreach (var takeoff in takeoffTimes)
  21973. {
  21974. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21975. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21976. {
  21977. foreach (var addTime in takeoff.Item2)
  21978. {
  21979. chiarr.Add(new Grp_ApprovalTravelDetails
  21980. {
  21981. Time = addTime,
  21982. CreateTime = DateTime.Now,
  21983. CreateUserId = dto.Userid,
  21984. ParentId = 0,
  21985. Details = "公务活动"
  21986. });
  21987. }
  21988. break;
  21989. }
  21990. }
  21991. }
  21992. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21993. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21994. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21995. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21996. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21997. if (isTrade)
  21998. {
  21999. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  22000. trip += "(转机不出机场)。";
  22001. }
  22002. //else
  22003. //{
  22004. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  22005. //}
  22006. chiarr.Add(new Grp_ApprovalTravelDetails
  22007. {
  22008. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  22009. CreateTime = DateTime.Now,
  22010. CreateUserId = dto.Userid,
  22011. ParentId = 0,
  22012. Details = trip
  22013. });
  22014. //最后一条到达的时间安排公务
  22015. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  22016. {
  22017. bool isCheckCountry = false;
  22018. if (end_Object.Country != arriveCountry)
  22019. {
  22020. arriveCountry = end_Object.Country;
  22021. isCheckCountry = true;
  22022. }
  22023. if (nextDayNum == 0)
  22024. {
  22025. //需要入境的情况
  22026. if (isCheckCountry)
  22027. {
  22028. foreach (var fallTime in fallTimesCheckCountry)
  22029. {
  22030. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22031. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22032. {
  22033. foreach (var addTime in fallTime.Item2)
  22034. {
  22035. chiarr.Add(new Grp_ApprovalTravelDetails
  22036. {
  22037. Time = addTime,
  22038. CreateTime = DateTime.Now,
  22039. CreateUserId = dto.Userid,
  22040. ParentId = 0,
  22041. Details = "公务活动"
  22042. });
  22043. }
  22044. break;
  22045. }
  22046. }
  22047. }
  22048. else
  22049. {
  22050. foreach (var fallTime in fallTimesNotCheckCountry)
  22051. {
  22052. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22053. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22054. {
  22055. foreach (var addTime in fallTime.Item2)
  22056. {
  22057. chiarr.Add(new Grp_ApprovalTravelDetails
  22058. {
  22059. Time = addTime,
  22060. CreateTime = DateTime.Now,
  22061. CreateUserId = dto.Userid,
  22062. ParentId = 0,
  22063. Details = "公务活动"
  22064. });
  22065. }
  22066. break;
  22067. }
  22068. }
  22069. }
  22070. }
  22071. }
  22072. }
  22073. //添加乘车语句
  22074. //chiarr.Add(new Grp_ApprovalTravelDetails
  22075. //{
  22076. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  22077. // CreateTime = DateTime.Now,
  22078. // CreateUserId = dto.Userid,
  22079. // ParentId = 0,
  22080. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  22081. //});
  22082. //if (i != timeArr.Count - 1)
  22083. //{
  22084. // fallToTime = fallToTime.AddHours(2.5);
  22085. // foreach (var item in Times)
  22086. // {
  22087. // //排列公务时间
  22088. // if (fallToTime.Hour < item.Item1)
  22089. // {
  22090. // chiarr.Add(new Grp_ApprovalTravelDetails
  22091. // {
  22092. // Time = $"{item.Item2} - {item.Item3}",
  22093. // CreateTime = DateTime.Now,
  22094. // CreateUserId = dto.Userid,
  22095. // ParentId = 0,
  22096. // Details = "公务活动"
  22097. // });
  22098. // }
  22099. // }
  22100. //}
  22101. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22102. var last = threeCodeStr.Last();
  22103. foreach (var item in threeCodeStr)
  22104. {
  22105. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22106. if (item.Equals(last))
  22107. {
  22108. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22109. }
  22110. }
  22111. cityPath = cityPath.Trim('-');
  22112. }
  22113. else
  22114. {
  22115. foreach (var item in Times)
  22116. {
  22117. chiarr.Add(new Grp_ApprovalTravelDetails
  22118. {
  22119. Time = $"{item.Item2} - {item.Item3}",
  22120. CreateTime = DateTime.Now,
  22121. CreateUserId = dto.Userid,
  22122. ParentId = 0,
  22123. Details = "公务活动"
  22124. });
  22125. }
  22126. }
  22127. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22128. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22129. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  22130. appro.Diid = dto.Diid;
  22131. appro.CreateUserId = dto.Userid;
  22132. appro.CreateTime = DateTime.Now;
  22133. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22134. appro.Id = thisId;
  22135. //foreach (var item in gwinfo)
  22136. //{
  22137. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  22138. // chi.Details = "拜访" + item.Client;
  22139. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  22140. // {
  22141. // chi.Details += "," + item.ReqSample;
  22142. // }
  22143. // chi.ParentId = thisId;
  22144. // chi.Time = item.Time;
  22145. // chiarr.Add(chi);
  22146. //}
  22147. if (chiarr.Count < 6)
  22148. {
  22149. for (int j = chiarr.Count; j < 6; j++)
  22150. {
  22151. chiarr.Add(new
  22152. Grp_ApprovalTravelDetails());
  22153. }
  22154. }
  22155. resultArr.Add(new
  22156. {
  22157. appro.Id,
  22158. appro.Date,
  22159. appro.Diid,
  22160. chiList = chiarr.Select(x1 => new
  22161. {
  22162. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22163. x1.Details,
  22164. x1.ParentId,
  22165. x1.Id
  22166. })
  22167. });
  22168. }
  22169. _sqlSugar.CommitTran();
  22170. jw = JsonView(true, "生成成功!", resultArr);
  22171. }
  22172. catch (Exception ex)
  22173. {
  22174. jw.Code = 400;
  22175. jw.Msg = "生成失败!" + ex.Message;
  22176. }
  22177. return Ok(jw);
  22178. }
  22179. /// <summary>
  22180. /// 报批行程word导出
  22181. /// </summary>
  22182. /// <param name="dto"></param>
  22183. /// <returns></returns>
  22184. [HttpPost]
  22185. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  22186. {
  22187. var jw = JsonView(false);
  22188. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22189. if (group == null)
  22190. {
  22191. jw.Msg = "暂无该团组!";
  22192. return Ok(jw);
  22193. }
  22194. //模板路径
  22195. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  22196. var fileName = string.Empty;
  22197. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  22198. bool bold = false;
  22199. if (dto.FileIndex == 1)
  22200. {
  22201. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  22202. }
  22203. else if (dto.FileIndex == 2)
  22204. {
  22205. fileName = "省外办-报批.docx";
  22206. bold = false;
  22207. titleFont = "方正黑体简体";
  22208. timeFont = "Times New Roman";
  22209. contentFont = "方正仿宋_GBK";
  22210. }
  22211. else if (dto.FileIndex == 3)
  22212. {
  22213. fileName = "市外办-报批.docx";
  22214. titleFont = "方正黑体简体";
  22215. timeFont = "Times New Roman";
  22216. contentFont = "方正仿宋简体";
  22217. }
  22218. tempPath = tempPath + fileName;
  22219. //载入模板
  22220. Document doc = new Document(tempPath);
  22221. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22222. //获取所填表格的序数
  22223. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22224. Aspose.Words.Tables.Row titleRowClone = null;
  22225. Aspose.Words.Tables.Row CenterRowClone = null;
  22226. int index = 0;
  22227. int indexChi = 0;
  22228. int SetIndex = 0;
  22229. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  22230. //获取数据,放到datatable
  22231. foreach (var item in ApprovalTravelArr)
  22232. {
  22233. if (index > 0)
  22234. {
  22235. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  22236. tableOne.AppendChild(titleRowClone);
  22237. }
  22238. var textTime = item.Date;
  22239. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  22240. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  22241. SetIndex++;
  22242. if (ChiRep.Count > 0)
  22243. {
  22244. foreach (var itemChi in ChiRep)
  22245. {
  22246. var txtTime = itemChi.Time;
  22247. var txtDetail = itemChi.Details;
  22248. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  22249. {
  22250. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  22251. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22252. //indexChi++;
  22253. //SetIndex++;
  22254. break;
  22255. }
  22256. if (indexChi > 0)
  22257. {
  22258. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22259. tableOne.AppendChild(CenterRowClone);
  22260. }
  22261. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  22262. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  22263. indexChi++;
  22264. SetIndex++;
  22265. }
  22266. }
  22267. //else
  22268. //{
  22269. // if (indexChi > 0)
  22270. // {
  22271. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22272. // tableOne.AppendChild(CenterRowClone);
  22273. // }
  22274. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  22275. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22276. // indexChi++;
  22277. // SetIndex++;
  22278. //}
  22279. index++;
  22280. }
  22281. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  22282. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22283. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22284. jw.Code = 200;
  22285. jw.Msg = "";
  22286. return Ok(jw);
  22287. }
  22288. private string ParseBlackTime(string time)
  22289. {
  22290. // 匹配可能只有分钟的情况
  22291. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  22292. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  22293. if (match.Success)
  22294. {
  22295. string hours = match.Groups[1].Value;
  22296. string minutes = match.Groups[2].Value;
  22297. // 如果小时部分为空,则只显示分钟
  22298. if (string.IsNullOrEmpty(hours))
  22299. {
  22300. return $"{minutes}分钟";
  22301. }
  22302. // 如果分钟部分为空,则只显示小时
  22303. else if (string.IsNullOrEmpty(minutes))
  22304. {
  22305. return $"{hours}小时";
  22306. }
  22307. // 否则显示完整格式
  22308. else
  22309. {
  22310. return $"{hours}小时{minutes}分钟";
  22311. }
  22312. }
  22313. else
  22314. {
  22315. return "未知时长";
  22316. }
  22317. }
  22318. private string intToString(int numberVal)
  22319. {
  22320. string numberval = numberVal.ToString();
  22321. Dictionary<char, string> Number = new Dictionary<char, string>();
  22322. Number.Add('1', "一");
  22323. Number.Add('2', "二");
  22324. Number.Add('3', "三");
  22325. Number.Add('4', "四");
  22326. Number.Add('5', "五");
  22327. Number.Add('6', "六");
  22328. Number.Add('7', "七");
  22329. Number.Add('8', "八");
  22330. Number.Add('9', "九");
  22331. string stringNumberVal = string.Empty;
  22332. for (int i = 0; i < numberval.Length; i++)
  22333. {
  22334. if (i == 0)
  22335. {
  22336. stringNumberVal += Number[numberval[i]];
  22337. }
  22338. else if (i >= 1)
  22339. {
  22340. if (numberval[i] == '0')
  22341. {
  22342. stringNumberVal = "十";
  22343. }
  22344. else
  22345. {
  22346. stringNumberVal += "十" + Number[numberval[i]];
  22347. }
  22348. }
  22349. }
  22350. return stringNumberVal;
  22351. }
  22352. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22353. {
  22354. //获取table中的某个单元格,从0开始
  22355. Cell lshCell = table.Rows[rows].Cells[cells];
  22356. //将单元格中段落移除
  22357. foreach (Paragraph item in lshCell.Paragraphs)
  22358. {
  22359. lshCell.Paragraphs.Remove(item);
  22360. }
  22361. if (val.Contains("\r\n"))
  22362. {
  22363. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22364. foreach (var item in spArr)
  22365. {
  22366. //新建一个段落
  22367. Paragraph p = new Paragraph(doc);
  22368. var r = new Run(doc, item);
  22369. //设置字体
  22370. if (!string.IsNullOrEmpty(font))
  22371. {
  22372. r.Font.Name = font;
  22373. }
  22374. r.Font.Bold = bold;
  22375. //把设置的值赋给之前新建的段落
  22376. p.AppendChild(r);
  22377. //将此段落加到单元格内
  22378. lshCell.AppendChild(p);
  22379. }
  22380. }
  22381. else
  22382. {
  22383. //新建一个段落
  22384. Paragraph p = new Paragraph(doc);
  22385. var r = new Run(doc, val);
  22386. //设置字体
  22387. if (!string.IsNullOrEmpty(font))
  22388. {
  22389. r.Font.Name = font;
  22390. }
  22391. r.Font.Bold = bold;
  22392. //把设置的值赋给之前新建的段落
  22393. p.AppendChild(r);
  22394. //将此段落加到单元格内
  22395. lshCell.AppendChild(p);
  22396. }
  22397. }
  22398. /// <summary>
  22399. /// 报批行程AI续写
  22400. /// </summary>
  22401. /// <returns></returns>
  22402. [HttpPost]
  22403. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22404. {
  22405. var jw = JsonView(false);
  22406. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22407. {
  22408. jw.Msg = "参数有误!";
  22409. return Ok(jw);
  22410. }
  22411. KiMiApiClient kiMi = new KiMiApiClient();
  22412. List<SeedMessages> messages = new List<SeedMessages>() {
  22413. new SeedMessages
  22414. {
  22415. Role = KimiRole.system,
  22416. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22417. },
  22418. new SeedMessages
  22419. {
  22420. Role = KimiRole.user,
  22421. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22422. }
  22423. };
  22424. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22425. string data = kimi_result.Choices[0]?.Message.Content;
  22426. if (string.IsNullOrWhiteSpace(data))
  22427. {
  22428. jw.Data = "Ai续写失败!";
  22429. }
  22430. else
  22431. {
  22432. jw = JsonView(true, "success!", data);
  22433. }
  22434. return Ok(jw);
  22435. }
  22436. #endregion
  22437. #region 团组接待意见调查
  22438. /// <summary>
  22439. /// 团组接待意见调查 - 信息管理
  22440. /// 基础数据(团组)
  22441. /// </summary>
  22442. /// <returns></returns>
  22443. [HttpGet]
  22444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22445. public async Task<IActionResult> OpinionaireInit()
  22446. {
  22447. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22448. .Select(x => new
  22449. {
  22450. x.Id,
  22451. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22452. })
  22453. .OrderByDescending(x => x.Id)
  22454. .ToListAsync();
  22455. return Ok(JsonView(groupData, groupData.Count));
  22456. }
  22457. /// <summary>
  22458. /// 团组接待意见调查 - 信息管理
  22459. /// 列表
  22460. /// </summary>
  22461. /// <param name="groupId"></param>
  22462. /// <returns></returns>
  22463. [HttpGet("{groupId}")]
  22464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22465. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22466. {
  22467. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22468. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22469. .Select(x => new
  22470. {
  22471. x.Id,
  22472. x.TourGuideName,
  22473. x.CityName,
  22474. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22475. x.CreateTime
  22476. })
  22477. .OrderBy(x => x.Id)
  22478. .ToListAsync();
  22479. return Ok(JsonView(data));
  22480. }
  22481. /// <summary>
  22482. /// 团组接待意见调查 - 信息管理
  22483. /// 保存
  22484. /// </summary>
  22485. /// <param name="dto"></param>
  22486. /// <returns></returns>
  22487. [HttpPost]
  22488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22489. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22490. {
  22491. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22492. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22493. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22494. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22495. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22496. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22497. _opinionaireRep.BeginTran();
  22498. if (addData != null && addData.Count > 0)
  22499. {
  22500. foreach (var item in addData)
  22501. {
  22502. item.CreateUserId = currUserInfo.UserId;
  22503. item.DiId = dto.DiId;
  22504. }
  22505. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22506. }
  22507. if (updData != null && updData.Count > 0)
  22508. {
  22509. var upd = await _opinionaireRep._sqlSugar
  22510. .Updateable(updData)
  22511. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22512. .WhereColumns(x => new { x.Id })
  22513. .ExecuteCommandAsync();
  22514. }
  22515. _opinionaireRep.CommitTran();
  22516. return Ok(JsonView("操作成功!"));
  22517. }
  22518. /// <summary>
  22519. /// 团组接待意见调查 - 信息管理
  22520. /// 删除
  22521. /// </summary>
  22522. /// <param name="id"></param>
  22523. /// <returns></returns>
  22524. [HttpDelete("{id}")]
  22525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22526. public async Task<IActionResult> OpinionaireManageDel(int id)
  22527. {
  22528. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22529. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22530. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22531. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22532. if (!del) return Ok(JsonView("操作失败!"));
  22533. return Ok(JsonView("操作成功!"));
  22534. }
  22535. /// <summary>
  22536. /// 团组接待意见调查 - 用户
  22537. /// 列表
  22538. /// </summary>
  22539. /// <param name="diId"></param>
  22540. /// <returns></returns>
  22541. [HttpGet("{diId}")]
  22542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22543. public async Task<IActionResult> OpinionaireUserList(int diId)
  22544. {
  22545. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22546. var sql = string.Format(@"
  22547. SELECT
  22548. o.Id,
  22549. o.DiId,
  22550. di.TeamName AS 'GroupName',
  22551. di.VisitPNumber AS 'PeopleNumber',
  22552. di.ClientName AS 'LeadGroup',
  22553. di.VisitCountry AS 'Travel',
  22554. di.VisitDays AS 'Days',
  22555. o.CityName,
  22556. o.TourGuideName,
  22557. o.Catering,
  22558. o.CateringReason,
  22559. o.Stay,
  22560. o.StayReason,
  22561. o.[Route],
  22562. o.RouteReason,
  22563. o.OfficialActivity,
  22564. o.OfficialActivityReason,
  22565. o.TourGuide,
  22566. o.TourGuideReason,
  22567. o.[Translate],
  22568. o.TranslateReason,
  22569. o.Trip,
  22570. o.TripReason,
  22571. o.ESFileName,
  22572. o.SignatureDate,
  22573. o.Remark
  22574. FROM
  22575. Grp_Opinionaire o
  22576. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22577. WHERE
  22578. o.IsDel = 0
  22579. AND o.DiId = {0}
  22580. ORDER BY
  22581. o.Id ASC", diId);
  22582. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22583. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22584. return Ok(JsonView(data));
  22585. }
  22586. /// <summary>
  22587. /// 团组接待意见调查 - 用户
  22588. /// 保存
  22589. /// </summary>
  22590. /// <param name="dto"></param>
  22591. /// <returns></returns>
  22592. [HttpPost]
  22593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22594. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22595. {
  22596. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22597. foreach (var item in dto)
  22598. {
  22599. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22600. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22601. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22602. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22603. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22604. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22605. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22606. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22607. }
  22608. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22609. if (!Directory.Exists(filePathBase))
  22610. {
  22611. Directory.CreateDirectory(filePathBase);
  22612. }
  22613. #region 上传文件
  22614. var filePaths = new List<string>();
  22615. foreach (var item in dto)
  22616. {
  22617. var file = item.File;
  22618. // 将文件保存到指定位置
  22619. var filePath = Path.Combine(filePathBase, file.FileName);
  22620. using (var stream = new FileStream(filePath, FileMode.Create))
  22621. {
  22622. await file.CopyToAsync(stream);
  22623. }
  22624. //验证文件是否上传成功
  22625. if (!System.IO.File.Exists(filePath))
  22626. {
  22627. foreach (var filePathStr in filePaths)
  22628. {
  22629. System.IO.File.Delete(filePathStr);
  22630. }
  22631. return Ok(JsonView(false, "文件上传失败!"));
  22632. }
  22633. item.ESFileName = file.FileName;
  22634. }
  22635. #endregion
  22636. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22637. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22638. .UpdateColumns(x => new
  22639. {
  22640. x.Catering,
  22641. x.CateringReason,
  22642. x.Stay,
  22643. x.StayReason,
  22644. x.Route,
  22645. x.RouteReason,
  22646. x.OfficialActivity,
  22647. x.OfficialActivityReason,
  22648. x.TourGuide,
  22649. x.TourGuideReason,
  22650. x.Translate,
  22651. x.TranslateReason,
  22652. x.Trip,
  22653. x.TripReason,
  22654. x.ESFileName,
  22655. x.SignatureDate,
  22656. x.Remark
  22657. })
  22658. .WhereColumns(x => new { x.Id })
  22659. .ExecuteCommandAsync();
  22660. if (upd < 1)
  22661. {
  22662. foreach (var filePathStr in filePaths)
  22663. {
  22664. System.IO.File.Delete(filePathStr);
  22665. }
  22666. return Ok(JsonView(false));
  22667. }
  22668. return Ok(JsonView(true));
  22669. }
  22670. #endregion
  22671. #region 团组餐厅相关信息
  22672. /// <summary>
  22673. /// 团组相关餐厅信息
  22674. /// 基础数据(团组)
  22675. /// </summary>
  22676. /// <returns></returns>
  22677. [HttpGet]
  22678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22679. public async Task<IActionResult> RestaurantInit()
  22680. {
  22681. return Ok(await _restaurantRep.InitAsync());
  22682. }
  22683. /// <summary>
  22684. /// 团组相关餐厅信息
  22685. /// Item
  22686. /// </summary>
  22687. /// <param name="dto"></param>
  22688. /// <returns></returns>
  22689. [HttpPost]
  22690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22691. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22692. {
  22693. int portType = dto.PortType,
  22694. groupId = dto.GroupId;
  22695. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22696. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22697. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22698. }
  22699. /// <summary>
  22700. /// 团组相关餐厅信息
  22701. /// List
  22702. /// </summary>
  22703. /// <param name="dto"></param>
  22704. /// <returns></returns>
  22705. [HttpPost]
  22706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22707. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22708. {
  22709. int portType = dto.PortType,
  22710. groupId = dto.GroupId;
  22711. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22712. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22713. var sql = string.Format(@" SELECT
  22714. ri.Id,
  22715. ri.GroupId,
  22716. ri.Date,
  22717. ri.StartTime,
  22718. ri.EndTime,
  22719. CASE WHEN ri.Type = 1 THEN '早餐'
  22720. WHEN ri.Type = 2 THEN '午餐'
  22721. WHEN ri.Type = 3 THEN '晚餐'
  22722. ELSE '其他'
  22723. END AS 'Type',
  22724. ri.Name,
  22725. ri.Address,
  22726. ri.Tel,
  22727. ri.Remark,
  22728. ri.CreateTime,
  22729. u.CnName AS CreateUserName
  22730. FROM
  22731. Grp_RestaurantInfo ri
  22732. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22733. WHERE
  22734. ri.IsDel = 0
  22735. AND ri.GroupId = {0}
  22736. ORDER BY
  22737. ri.Date ASC
  22738. ", groupId);
  22739. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22740. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22741. return Ok(JsonView(infos));
  22742. }
  22743. /// <summary>
  22744. /// 团组相关餐厅信息
  22745. /// Info
  22746. /// </summary>
  22747. /// <param name="dto"></param>
  22748. /// <returns></returns>
  22749. [HttpPost]
  22750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22751. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22752. {
  22753. int portType = dto.PortType,
  22754. id = dto.Id;
  22755. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22756. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22757. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22758. }
  22759. /// <summary>
  22760. /// 团组相关餐厅信息
  22761. /// Op
  22762. /// </summary>
  22763. /// <param name="dto"></param>
  22764. /// <returns></returns>
  22765. [HttpPost]
  22766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22767. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22768. {
  22769. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22770. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22771. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22772. return Ok(await _restaurantRep.OpAsync(dto));
  22773. }
  22774. /// <summary>
  22775. /// 团组相关餐厅信息
  22776. /// Del
  22777. /// </summary>
  22778. /// <param name="dto"></param>
  22779. /// <returns></returns>
  22780. [HttpPost]
  22781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22782. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22783. {
  22784. int userId = dto.DeleteUserId;
  22785. var id = dto.Id;
  22786. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22787. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22788. return Ok(await _restaurantRep.DelAsync(dto));
  22789. }
  22790. #endregion
  22791. #region 团组会务成本
  22792. /// <summary>
  22793. /// 团组会务成本数据初始化
  22794. /// </summary>
  22795. /// <returns></returns>
  22796. [HttpPost]
  22797. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  22798. {
  22799. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  22800. .OrderByDescending(x => x.CreateTime)
  22801. .Where(x => x.IsDel == 0)
  22802. .Select<DelegationEasyView>();
  22803. DelegationEasyView di = Dto.GroupId == 0 ?
  22804. expr.First() :
  22805. expr.First(x => x.Id == Dto.GroupId);
  22806. if (di == null)
  22807. {
  22808. return Ok(JsonView(false, "团组信息不存在!"));
  22809. }
  22810. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  22811. .Where(x => x.IsDel == 0 && x.STid == 21)
  22812. .Select(x => new { x.Id, Text = x.Name })
  22813. .ToListAsync();
  22814. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  22815. .Where(x => x.IsDel == 0)
  22816. .Select(x => new { x.Id, x.TeamName })
  22817. .ToListAsync();
  22818. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  22819. var userList = await _sqlSugar.Queryable<Sys_Users>()
  22820. .Where(x => x.IsDel == 0)
  22821. .Select(x => new { x.Id, x.CnName })
  22822. .ToListAsync();
  22823. var units = await _sqlSugar.Queryable<Sys_SetData>()
  22824. .Where(x => x.IsDel == 0 && x.STid == 119)
  22825. .Select(x => new { x.Id, Text = x.Name })
  22826. .ToListAsync();
  22827. var GM = new List<int>();
  22828. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  22829. try
  22830. {
  22831. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  22832. }
  22833. catch (Exception ex)
  22834. {
  22835. GM = new List<int>() { 21 };
  22836. }
  22837. var isReview = Dto.UserId == 21;
  22838. var isGM = GM.Contains(Dto.UserId);
  22839. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  22840. .Where(x => x.IsDel == 0)
  22841. .Select<ConferenceAffairsCostView>()
  22842. .First(x=> x.Diid == di.Id);
  22843. if (ConferenceAffairsCost == null)
  22844. {
  22845. ConferenceAffairsCost = new ConferenceAffairsCostView();
  22846. ConferenceAffairsCost.Diid = di.Id;
  22847. }
  22848. #region 权限校验
  22849. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  22850. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  22851. .Select(x=> x.UserId)
  22852. .Distinct()
  22853. .ToList();
  22854. if (!ids.Contains(Dto.UserId) && !isGM )
  22855. {
  22856. return Ok(JsonView(201, "暂无权限!", new
  22857. {
  22858. typeData,
  22859. groupList,
  22860. currenyList,
  22861. isGM,
  22862. userList,
  22863. units,
  22864. isReview,
  22865. operatorUser = ids,
  22866. di
  22867. }));
  22868. }
  22869. #endregion
  22870. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  22871. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  22872. .Select<ConferenceAffairsCostChildView>()
  22873. .OrderBy(x=>x.Index)
  22874. .ToList();
  22875. var backData = new
  22876. {
  22877. ConferenceAffairsCost,
  22878. ConferenceAffairsCostChi,
  22879. typeData,
  22880. groupList,
  22881. currenyList,
  22882. isGM,
  22883. userList,
  22884. units,
  22885. isReview,
  22886. operatorUser = ids,
  22887. di
  22888. };
  22889. return Ok(JsonView(true, "SUCCESS", backData));
  22890. }
  22891. /// <summary>
  22892. /// 会务成本保存
  22893. /// </summary>
  22894. /// <returns></returns>
  22895. [HttpPost]
  22896. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  22897. {
  22898. _sqlSugar.BeginTran();
  22899. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  22900. try
  22901. {
  22902. if (data.Id == 0)
  22903. {
  22904. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  22905. .Where(x => x.Diid == Dto.GroupId)
  22906. .SetColumns(x => new Grp_ConferenceAffairsCost
  22907. {
  22908. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  22909. DeleteUserId = Dto.UserId
  22910. })
  22911. .ExecuteCommand();
  22912. data.Diid = Dto.GroupId;
  22913. data.CreateTime = DateTime.Now;
  22914. data.CreateUserId = Dto.UserId;
  22915. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  22916. .ExecuteReturnIdentity();
  22917. }
  22918. else
  22919. {
  22920. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  22921. .IgnoreColumns(ignoreAllNullColumns: true)
  22922. .ExecuteCommand();
  22923. }
  22924. if (Dto.ConferenceAffairsCostChild.Any())
  22925. {
  22926. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  22927. var insertArr = datas.Where(x => x.Id == 0).ToList();
  22928. var updateArr = datas.Where(x => x.Id != 0).ToList();
  22929. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  22930. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  22931. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  22932. .IgnoreColumns(ignoreAllNullColumns: true)
  22933. .ExecuteCommand() : 0;
  22934. }
  22935. _sqlSugar.CommitTran();
  22936. }
  22937. catch (Exception ex)
  22938. {
  22939. _sqlSugar.RollbackTran();
  22940. return Ok(JsonView(false, "失败!" + ex.Message));
  22941. }
  22942. return Ok(JsonView(true,"操作成功!"));
  22943. }
  22944. [HttpPost]
  22945. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  22946. {
  22947. var count = 0;
  22948. if (Dto.ConferenceAffairsCostChildids.Any())
  22949. {
  22950. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  22951. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  22952. SetColumns(x => new Grp_ConferenceAffairsCostChild
  22953. {
  22954. ReviewStatus = Dto.ReviewStatus
  22955. }).
  22956. ExecuteCommand();
  22957. }
  22958. return Ok(JsonView(true, "操作成功!",count));
  22959. }
  22960. [HttpPost]
  22961. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  22962. {
  22963. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  22964. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  22965. _sqlSugar.BeginTran();
  22966. try
  22967. {
  22968. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  22969. .Where(x => x.Diid == Dto.GroupId)
  22970. .SetColumns(x => new Grp_ConferenceAffairsCost
  22971. {
  22972. IsDel = 1,
  22973. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  22974. DeleteUserId = Dto.UserId
  22975. })
  22976. .ExecuteCommand();
  22977. if (delCount > 0)
  22978. {
  22979. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  22980. .Where(x => x.Diid == Dto.GroupId)
  22981. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  22982. {
  22983. IsDel = 1,
  22984. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  22985. DeleteUserId = Dto.UserId
  22986. })
  22987. .ExecuteCommand();
  22988. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  22989. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  22990. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  22991. {
  22992. IsDel = 1,
  22993. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  22994. DeleteUserId = Dto.UserId
  22995. })
  22996. .ExecuteCommand();
  22997. }
  22998. _sqlSugar.CommitTran();
  22999. }
  23000. catch (Exception ex)
  23001. {
  23002. _sqlSugar.RollbackTran();
  23003. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23004. }
  23005. return Ok(JsonView(true, "操作成功!"));
  23006. }
  23007. [HttpPost]
  23008. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  23009. {
  23010. _sqlSugar.BeginTran();
  23011. var count = 0;
  23012. try
  23013. {
  23014. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23015. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23016. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23017. {
  23018. IsDel = 1,
  23019. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23020. DeleteUserId = Dto.CreateUserId
  23021. })
  23022. .ExecuteCommand();
  23023. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  23024. {
  23025. CreateTime = DateTime.Now,
  23026. CreateUserId = Dto.CreateUserId,
  23027. UserId = x,
  23028. Diid = Dto.GroupId,
  23029. }).ToList()).ExecuteCommand();
  23030. _sqlSugar.CommitTran();
  23031. }
  23032. catch (Exception ex)
  23033. {
  23034. _sqlSugar.RollbackTran();
  23035. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23036. }
  23037. return Ok(JsonView(true, "操作成功!", count));
  23038. }
  23039. #endregion
  23040. /// <summary>
  23041. /// 123132123
  23042. /// </summary>
  23043. /// <param name="_dto"></param>
  23044. /// <returns></returns>
  23045. [HttpPost]
  23046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23047. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  23048. {
  23049. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  23050. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  23051. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  23052. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  23053. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  23054. dicDetail.Add(789, 1034);
  23055. dicDetail.Add(790, 1035);
  23056. dicDetail.Add(791, 1036);
  23057. dicDetail.Add(792, 1037);
  23058. dicDetail.Add(793, 1038);
  23059. dicDetail.Add(794, 1039);
  23060. dicDetail.Add(795, 1040);
  23061. dicDetail.Add(796, 1041);
  23062. dicDetail.Add(797, 1042);
  23063. dicDetail.Add(798, 1043);
  23064. dicDetail.Add(801, 1044);
  23065. dicDetail.Add(802, 1045);
  23066. dicDetail.Add(803, 1046);
  23067. Dictionary<int, int> dic = new Dictionary<int, int>();
  23068. dic.Add(806, 1027);
  23069. dic.Add(807, 1028);
  23070. dic.Add(808, 1029);
  23071. dic.Add(809, 1030);
  23072. dic.Add(810, 1031);
  23073. dic.Add(811, 1032);
  23074. dic.Add(812, 1033);
  23075. foreach (var item in list_visa)
  23076. {
  23077. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  23078. temp.Coefficient = item.coefficient;
  23079. DateTime dtCrt;
  23080. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  23081. if (b1)
  23082. {
  23083. temp.CreateTime = dtCrt;
  23084. }
  23085. else
  23086. {
  23087. temp.CreateTime = DateTime.Now;
  23088. }
  23089. temp.CreateUserId = item.Operators;
  23090. temp.DeleteTime = "";
  23091. temp.DeleteUserId = 0;
  23092. temp.DiId = int.Parse(item.DIID);
  23093. temp.FilePath = item.FilePath;
  23094. temp.IsDel = item.IsDel;
  23095. temp.Price = item.Price;
  23096. temp.PriceCount = 1;
  23097. temp.PriceCurrency = item.Currency;
  23098. int detailId = 0;
  23099. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  23100. {
  23101. detailId = dicDetail[item.PriceTypeDetail];
  23102. }
  23103. temp.PriceDetailType = detailId;
  23104. temp.PriceDt = DateTime.Now;
  23105. temp.PriceName = item.PriceName;
  23106. temp.PriceSum = item.Price;
  23107. int tid = 0;
  23108. if (dic.ContainsKey(item.PriceType))
  23109. {
  23110. tid = dic[item.PriceType];
  23111. }
  23112. temp.PriceType = tid;
  23113. temp.Remark = item.Remark;
  23114. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  23115. }
  23116. return Ok(JsonView(true, "操作成功!"));
  23117. }
  23118. [HttpPost]
  23119. public IActionResult TimeTest()
  23120. {
  23121. var jw = JsonView(false, "error");
  23122. _sqlSugar.BeginTran();
  23123. try
  23124. {
  23125. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  23126. .Select(x => new Crm_NewClientData
  23127. {
  23128. Id = x.Id,
  23129. Client = x.Client,
  23130. Contact = x.Contact,
  23131. Location = x.Location,
  23132. })
  23133. .ToList();
  23134. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  23135. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  23136. Stopwatch stopwatch = new Stopwatch();
  23137. // 开始计时
  23138. stopwatch.Start();
  23139. foreach (var item in clientList)
  23140. {
  23141. EncryptionProcessor.DecryptProperties(item);
  23142. }
  23143. stopwatch.Stop();
  23144. jw.Code = 200;
  23145. jw.Data = stopwatch.ElapsedMilliseconds;
  23146. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  23147. }
  23148. catch (Exception ex)
  23149. {
  23150. jw.Code = 400;
  23151. jw.Msg = ex.Message;
  23152. }
  23153. return Ok(jw);
  23154. }
  23155. }
  23156. }