123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656 |
- using Aspose.Cells;
- using Aspose.Cells.Drawing;
- using Aspose.Words;
- using Aspose.Words.Drawing;
- using Aspose.Words.Tables;
- using DiffMatchPatch;
- using EyeSoft.Runtime.InteropServices;
- using Google.Protobuf.WellKnownTypes;
- using Microsoft.AspNetCore.Mvc.RazorPages;
- using Microsoft.AspNetCore.SignalR;
- using Microsoft.EntityFrameworkCore.Metadata.Internal;
- using Microsoft.IdentityModel.Tokens;
- using Microsoft.VisualBasic;
- using MySqlX.XDevAPI.Relational;
- using NetTaste;
- using NPOI.HSSF.UserModel;
- using NPOI.SS.Formula.Functions;
- using NPOI.SS.UserModel;
- using NPOI.SS.Util;
- using NPOI.XSSF.UserModel;
- using OASystem.API.Middlewares;
- using OASystem.API.OAMethodLib;
- using OASystem.API.OAMethodLib.APNs;
- using OASystem.API.OAMethodLib.File;
- using OASystem.API.OAMethodLib.Hub.HubClients;
- using OASystem.API.OAMethodLib.Hub.Hubs;
- using OASystem.API.OAMethodLib.JuHeAPI;
- using OASystem.API.OAMethodLib.KiMiApi;
- using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
- using OASystem.Domain.AesEncryption;
- using OASystem.Domain.Attributes;
- using OASystem.Domain.Dtos.CRM;
- using OASystem.Domain.Dtos.FileDto;
- using OASystem.Domain.Dtos.Financial;
- using OASystem.Domain.Dtos.Groups;
- using OASystem.Domain.Entities.Customer;
- using OASystem.Domain.Entities.Financial;
- using OASystem.Domain.Entities.Groups;
- using OASystem.Domain.ViewModels.Financial;
- using OASystem.Domain.ViewModels.Groups;
- using OASystem.Domain.ViewModels.JuHeExchangeRate;
- using OASystem.Domain.ViewModels.OCR;
- using OASystem.Domain.ViewModels.QiYeWeChat;
- using OASystem.Domain.ViewModels.Statistics;
- using OASystem.Infrastructure.Repositories.CRM;
- using OASystem.Infrastructure.Repositories.Financial;
- using OASystem.Infrastructure.Repositories.Groups;
- using OASystem.Infrastructure.Tools;
- using OASystem.RedisRepository;
- using Org.BouncyCastle.Crypto;
- using Org.BouncyCastle.Utilities;
- using Quartz.Util;
- using SqlSugar.Extensions;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing.Printing;
- using System.Globalization;
- using System.IO;
- using System.IO.Compression;
- using System.Reflection;
- using System.Text.Json;
- using System.Web;
- using System.Xml.Linq;
- using TencentCloud.Ocr.V20181119.Models;
- using static OASystem.API.OAMethodLib.JWTHelper;
- using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
- using Bookmark = Aspose.Words.Bookmark;
- using Cell = Aspose.Words.Tables.Cell;
- using Table = Aspose.Words.Tables.Table;
- namespace OASystem.API.Controllers
- {
- /// <summary>
- /// 团组相关
- /// </summary>
- //[Authorize]
- [Route("api/[controller]/[action]")]
- public class GroupsController : ControllerBase
- {
- private readonly ILogger<GroupsController> _logger;
- private readonly GrpScheduleRepository _grpScheduleRep;
- private readonly IMapper _mapper;
- private readonly DelegationInfoRepository _groupRepository;
- private readonly TaskAssignmentRepository _taskAssignmentRep;
- private readonly AirTicketResRepository _airTicketResRep;
- private readonly DecreasePaymentsRepository _decreasePaymentsRep;
- private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
- private readonly DelegationEnDataRepository _delegationEnDataRep;
- private readonly DelegationVisaRepository _delegationVisaRep;
- private readonly VisaPriceRepository _visaPriceRep;
- private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
- private readonly HotelPriceRepository _hotelPriceRep;
- private readonly CustomersRepository _customersRep;
- private readonly MessageRepository _message;
- private readonly SqlSugarClient _sqlSugar;
- private readonly TourClientListRepository _tourClientListRep;
- private readonly TeamRateRepository _teamRateRep;
- #region 成本相关
- private readonly CheckBoxsRepository _checkBoxs;
- private readonly GroupCostRepository _GroupCostRepository;
- private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
- private readonly GroupCostParameterRepository _GroupCostParameterRepository;
- #endregion
- private readonly SetDataRepository _setDataRep;
- private string url;
- private string path;
- private readonly EnterExitCostRepository _enterExitCostRep;
- private readonly IHubContext<ChatHub, IChatClient> _hubContext;
- private readonly UsersRepository _usersRep;
- private readonly IJuHeApiService _juHeApi;
- private readonly InvertedListRepository _invertedListRep;
- private readonly VisaFeeInfoRepository _visaFeeInfoRep;
- private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
- private readonly ThreeCodeRepository _threeCodeRepository;
- private readonly HotelInquiryRepository _hotelInquiryRep;
- private readonly FeeAuditRepository _feeAuditRep;
- private readonly VisaCommissionRepository _visaCommissionRep;
- private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
- private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
- private readonly List<CurrencyInfo> _currencyInit;
- private readonly List<int> _portTypeData;
- private readonly TableOperationRecordRepository _tableorRep;
- private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
- private readonly RestaurantRepository _restaurantRep;
- private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
- private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="logger"></param>
- /// <param name="mapper"></param>
- /// <param name="hubContext"></param>
- /// <param name="sqlSugar"></param>
- /// <param name="grpScheduleRep"></param>
- /// <param name="groupRepository"></param>
- /// <param name="taskAssignmentRep"></param>
- /// <param name="airTicketResRep"></param>
- /// <param name="decreasePaymentsRep"></param>
- /// <param name="InvitationOfficialActivitiesRep"></param>
- /// <param name="delegationEnDataRep"></param>
- /// <param name="enterExitCostRep"></param>
- /// <param name="delegationVisaRep"></param>
- /// <param name="message"></param>
- /// <param name="visaPriceRep"></param>
- /// <param name="carTouristGuideGroundRep"></param>
- /// <param name="checkBoxs"></param>
- /// <param name="GroupCostRepository"></param>
- /// <param name="CostTypeHotelNumberRepository"></param>
- /// <param name="GroupCostParameterRepository"></param>
- /// <param name="hotelPriceRep"></param>
- /// <param name="customersRep"></param>
- /// <param name="setDataRep"></param>
- /// <param name="tourClientListRep"></param>
- /// <param name="teamRateRep"></param>
- /// <param name="usersRep"></param>
- /// <param name="juHeApi"></param>
- /// <param name="invertedListRep"></param>
- /// <param name="visaFeeInfoRep"></param>
- /// <param name="ticketBlackCodeRep"></param>
- /// <param name="hotelInquiryRep"></param>
- /// <param name="threeCodeRepository"></param>
- /// <param name="feeAuditRep"></param>
- /// <param name="visaCommissionRep"></param>
- /// <param name="ffrRep"></param>
- /// <param name="opinionaireRep"></param>
- /// <param name="tableorRep"></param>
- /// <param name="enterExitCostDraftRep"></param>
- /// <param name="restaurantRep"></param>
- /// <param name="enterExitCostQuoteRep"></param>
- /// <param name="grpOrderPreInfoRep"></param>
- public GroupsController(
- ILogger<GroupsController> logger,
- IMapper mapper,
- IHubContext<ChatHub, IChatClient> hubContext,
- SqlSugarClient sqlSugar,
- GrpScheduleRepository grpScheduleRep,
- DelegationInfoRepository groupRepository,
- TaskAssignmentRepository taskAssignmentRep,
- AirTicketResRepository airTicketResRep,
- DecreasePaymentsRepository decreasePaymentsRep,
- InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
- DelegationEnDataRepository delegationEnDataRep,
- EnterExitCostRepository enterExitCostRep,
- DelegationVisaRepository delegationVisaRep,
- MessageRepository message,
- VisaPriceRepository visaPriceRep,
- CarTouristGuideGroundRepository carTouristGuideGroundRep,
- CheckBoxsRepository checkBoxs,
- GroupCostRepository GroupCostRepository,
- CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
- GroupCostParameterRepository GroupCostParameterRepository,
- HotelPriceRepository hotelPriceRep,
- CustomersRepository customersRep,
- SetDataRepository setDataRep,
- TourClientListRepository tourClientListRep,
- TeamRateRepository teamRateRep,
- UsersRepository usersRep,
- IJuHeApiService juHeApi,
- InvertedListRepository invertedListRep,
- VisaFeeInfoRepository visaFeeInfoRep,
- TicketBlackCodeRepository ticketBlackCodeRep,
- HotelInquiryRepository hotelInquiryRep,
- ThreeCodeRepository threeCodeRepository,
- FeeAuditRepository feeAuditRep,
- VisaCommissionRepository visaCommissionRep,
- ForeignReceivablesRepository ffrRep,
- OpinionaireRepository opinionaireRep,
- TableOperationRecordRepository tableorRep,
- EnterExitCostDraftRepository enterExitCostDraftRep,
- RestaurantRepository restaurantRep,
- EnterExitCostQuoteRepository enterExitCostQuoteRep,
- GroupOrderPreInfoRepository grpOrderPreInfoRep
- )
- {
- _logger = logger;
- _mapper = mapper;
- _grpScheduleRep = grpScheduleRep;
- _groupRepository = groupRepository;
- _taskAssignmentRep = taskAssignmentRep;
- _airTicketResRep = airTicketResRep;
- _sqlSugar = sqlSugar;
- url = AppSettingsHelper.Get("ExcelBaseUrl");
- path = AppSettingsHelper.Get("ExcelBasePath");
- if (!System.IO.Directory.Exists(path))
- {
- System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
- }
- _decreasePaymentsRep = decreasePaymentsRep;
- _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
- _delegationEnDataRep = delegationEnDataRep;
- _enterExitCostRep = enterExitCostRep;
- _delegationVisaRep = delegationVisaRep;
- _message = message;
- _visaPriceRep = visaPriceRep;
- _carTouristGuideGroundRep = carTouristGuideGroundRep;
- _checkBoxs = checkBoxs;
- _GroupCostRepository = GroupCostRepository;
- _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
- _GroupCostParameterRepository = GroupCostParameterRepository;
- _hotelPriceRep = hotelPriceRep;
- _customersRep = customersRep;
- _setDataRep = setDataRep;
- _tourClientListRep = tourClientListRep;
- _teamRateRep = teamRateRep;
- _hubContext = hubContext;
- _usersRep = usersRep;
- _juHeApi = juHeApi;
- _invertedListRep = invertedListRep;
- _visaFeeInfoRep = visaFeeInfoRep;
- _ticketBlackCodeRep = ticketBlackCodeRep;
- _hotelInquiryRep = hotelInquiryRep;
- _threeCodeRepository = threeCodeRepository;
- _feeAuditRep = feeAuditRep;
- _visaCommissionRep = visaCommissionRep;
- _ffrRep = ffrRep;
- _opinionaireRep = opinionaireRep;
- _currencyInit = new List<CurrencyInfo>()
- {
- new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
- new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
- new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
- new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
- new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
- };
- _portTypeData = new List<int>() { 2, 3 };
- _tableorRep = tableorRep;
- _enterExitCostDraftRep = enterExitCostDraftRep;
- _restaurantRep = restaurantRep;
- _enterExitCostQuoteRep = enterExitCostQuoteRep;
- _grpOrderPreInfoRep = grpOrderPreInfoRep;
- }
- #region 流程管控
- /// <summary>
- /// 获取团组流程管控信息
- /// </summary>
- /// <param name="_jsonDto">查询参数</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
- {
- if (string.IsNullOrEmpty(_jsonDto.Paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
- if (_ScheduleDto != null)
- {
- if (_ScheduleDto.SearchType == 2)//获取列表
- {
- List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
- return Ok(JsonView(_grpScheduleViewList));
- }
- else//获取对象
- {
- Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
- if (_grpScheduleView != null)
- {
- return Ok(JsonView(_grpScheduleView));
- }
- }
- }
- else
- {
- return Ok(JsonView(false, "参数反序列化失败"));
- }
- return Ok(JsonView(false, "暂无数据!"));
- }
- /// <summary>
- /// 修改团组流程管控详细表数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
- {
- Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
- var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
- .SetColumns(it => it.Duty == _detail.Duty)
- .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
- .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
- .SetColumns(it => it.JobContent == _detail.JobContent)
- .SetColumns(it => it.Remark == _detail.Remark)
- .SetColumns(it => it.StepStatus == _detail.StepStatus)
- .Where(s => s.Id == dto.Id)
- //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
- .ExecuteCommandAsync();
- if (result > 0)
- {
- return Ok(JsonView(true, "保存成功!"));
- }
- return Ok(JsonView(false, "保存失败!"));
- }
- /// <summary>
- /// 删除团组流程管控详细表数据,删除人Id请放在Duty
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
- {
- Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
- _detail.IsDel = 1;
- _detail.DeleteUserId = dto.Duty;
- _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
- .SetColumns(it => it.IsDel == _detail.IsDel)
- .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
- .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
- .Where(it => it.Id == dto.Id)
- //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
- //.WhereColumns(s => s.Id == dto.Id)
- .ExecuteCommandAsync();
- if (result > 0)
- {
- return Ok(JsonView(true, "删除成功!"));
- }
- return Ok(JsonView(false, "删除失败!"));
- }
- /// <summary>
- /// 增加团组流程管控详细表数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
- {
- Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
- if (DateTime.Now < _detail.ExpectBeginDt)
- {
- _detail.StepStatus = 0;
- }
- else
- {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
- _detail.StepStatus = 1;
- }
- var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
- if (result > 0)
- {
- Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
- return Ok(JsonView(true, "添加成功!", _result));
- }
- return Ok(JsonView(false, "添加失败!"));
- }
- #endregion
- #region 团组前期信息
- /// <summary>
- /// 团组前期信息 List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
- {
- var search = dto.Search;
- int[] nameTempIds = new int[] { 1, 12, 28 },
- countryTempIds = new int[] { 2, 13, 29 },
- daysTempIds = new int[] { 4, 15, 31 },
- ppNumTempIds = new int[] { 6 };
- var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
- .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
- .Where((opi, u) => opi.IsDel == 0)
- .OrderByDescending((opi, u) => opi.CreateTime)
- .Select((opi, u) => new GroupOrderPreInfoListView()
- {
- Id = opi.Id,
- Name = opi.Name,
- UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains( x.FormTempId)).Select(x => x.Value),
- VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
- VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
- VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
- Operator = u.CnName,
- OperationTime = opi.CreateTime
- })
- //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
- //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- .ToListAsync();
- var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
- int total = list.Count;
- int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
- var listPageData1 = listPageData
- .Skip((dto.PageIndex - 1) * dto.PageSize)
- .Take(dto.PageSize)
- .ToList();
- var infoIds = listPageData1.Select(x => x.Id).ToList();
- var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
- .Where(x => x.IsDel == 0 && x.STid == 109)
- .ToArrayAsync();
- var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
- .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
- .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
- .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
- .ToListAsync();
- foreach (var item in listPageData1)
- {
- var typeDatas1 = typeDatas.Select(x => new
- {
- Id = x.Id,
- Name = x.Name,
- IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
- }).ToArray();
- item.VersionDetails = typeDatas1;
- }
- return Ok(JsonView(listPageData1, listPageData1.Count));
- }
- /// <summary>
- /// 团组前期信息 Init
- /// </summary>
- /// <returns></returns>
- [HttpGet("{userId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupOrderPreInfo(int userId)
- {
- return Ok(await _grpOrderPreInfoRep.DataInit(userId));
- }
- /// <summary>
- /// 国家数据源
- /// </summary>
- /// <param name="pageIndex">当前页码</param>
- /// <param name="pageSize">每页条数</param>
- /// <param name="search">查询条件</param>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
- {
- var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
- if (pageIndex == 0 && pageSize == 0)
- {
- //所有数据
- return Ok(JsonView(countrys, countrys.Count));
- }
- //分页
- int skip = (pageIndex - 1) * pageSize;
- int take = pageSize;
- if (!string.IsNullOrEmpty(search))
- {
- IEnumerable<char> charSequence = search.Select(c => c);
- var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
- var pageData = pageResult1.Skip(skip).Take(take).ToList();
- return Ok(JsonView(pageData, pageResult1.Count));
- }
- var pageResult2 = countrys.Skip(skip).Take(take).ToList();
- return Ok(JsonView(pageResult2, countrys.Count));
- }
- /// <summary>
- /// 城市数据源
- /// </summary>
- /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
- /// <param name="pageIndex">当前页码</param>
- /// <param name="pageSize">每页条数</param>
- /// <param name="search">查询条件</param>
- /// <returns></returns>
- [HttpGet("{countryLabel}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CityByCountry(
- string countryLabel,
- [FromQuery] int pageIndex,
- [FromQuery] int pageSize,
- [FromQuery] string search)
- {
- countryLabel = HttpUtility.UrlDecode(countryLabel);
- var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
- var citys = Array.Empty<string?>();
- if (countryList.Any())
- {
- var cityDatas = await _sqlSugar
- .Queryable<Grp_NationalTravelFee>()
- .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
- .ToArrayAsync();
- foreach (var item in cityDatas)
- {
- if (item.City.Contains("城市"))
- {
- item.City = item.Country + "-所有城市";
- }
- }
- var cityDatas1 = cityDatas.OrderBy(x => x.Country);
- citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
- }
- if (pageIndex == 0 && pageSize == 0)
- {
- //所有数据
- return Ok(JsonView(citys, citys?.Length ?? 0));
- }
- //分页
- int skip = (pageIndex - 1) * pageSize;
- int take = pageSize;
- if (!string.IsNullOrEmpty(search))
- {
- IEnumerable<char> charSequence = search.Select(c => c);
- var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
- var pageData = pageResult1.Skip(skip).Take(take).ToList();
- return Ok(JsonView(pageData, pageResult1.Count()));
- }
- var pageResult2 = citys.Skip(skip).Take(take).ToList();
- return Ok(JsonView(pageResult2, citys?.Length ?? 0));
- }
- /// <summary>
- /// 团组前期信息 Info
- /// </summary>
- /// <param name="dto">Id</param>
- /// <param name="portType">Id</param>
- /// <returns></returns>
- [HttpGet("{Id}/{TempId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto,int portType=1)
- {
- return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
- }
- /// <summary>
- /// 团组前期信息 移动端 Info
- /// </summary>
- /// <param name="dto">Id</param>
- /// <returns></returns>
- [HttpGet("{Id}/{TempId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
- {
- return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
- }
- /// <summary>
- /// 团组前期信息 Save
- /// </summary>
- /// <param name="dto">Id</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
- {
- return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
- }
- /// <summary>
- /// 团组前期信息 Del
- /// </summary>
- /// <param name="dto">Id</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
- {
- return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
- }
- /// <summary>
- /// 团组前期信息 文件下载
- /// </summary>
- /// <param name="dto">Id</param>
- /// <returns></returns>
- [HttpGet("{Id}/{TempId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
- {
- int id = dto.Id, tempId = dto.TempId;
- var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
- var data = view.Data as GrpOrderPreInfoView;
- #region Excel
- var tempPath = AppSettingsHelper.Get("ExcelTempPath");
- var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
- var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
- var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
- var fileNamePrefix = string.Empty;
- if (tempId == 1405)
- {
- tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
- fileNamePrefix = $"{data.Name}_无商邀版";
- }
- else if (tempId == 1406)
- {
- tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
- fileNamePrefix = $"{data.Name}_有商邀版";
- }
- else
- {
- //tempId == 1404 默认下载
- tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
- fileNamePrefix = $"{data.Name}_单接送机";
- }
- foreach (var item in data.Items)
- {
- var obj = item.NewValue;
- if (obj == null) item.OriginVal = "";
- else if (obj.Equals("有") || obj.Equals("无"))
- {
- item.OriginVal = obj.ToString();
- }
- else if (obj is object[] objArray)
- {
- string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
- item.OriginVal = string.Join("、", stringArray);
- }
- else if (obj is string[] stringArray)
- {
- item.OriginVal = string.Join("、", stringArray);
- }
- else if (obj.Equals("-"))
- {
- item.OriginVal = "";
- }
- }
- var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
- fileName = CommonFun.ValidFileName(fileName);
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(tempPath);
- if (tempId == 1406)
- {
- var view1 = data.Items.Where(x => x.Index < 11).ToArray();
- var view2 = data.Items.Where(x => x.Index > 10).ToArray();
- for (int i = 1; i <= view2.Length; i++)
- {
- view2[i - 1].Index = i;
- }
- designer.SetDataSource("View1", view1);
- designer.SetDataSource("View2", view2);
- }
- else
- {
- designer.SetDataSource("View", data.Items);
- }
- designer.Process();
- if (!Directory.Exists(savePath))
- {
- Directory.CreateDirectory(savePath);
- }
- string serverPath = $"{savePath}{fileName}";
- designer.Workbook.Save(serverPath);
- string rst = $"{servicePath}{ftpPath}{fileName}";
- #endregion
- return Ok(JsonView(new { url = rst }));
- }
- #endregion
- #region 团组基本信息
- /// <summary>
- /// 接团信息列表
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupList(GroupListDto dto)
- {
- var groupData = await _groupRepository.GetGroupList(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 分页查询团组列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
- {
- var watch = new Stopwatch();
- watch.Start();
- RefAsync<int> total = 0;
- var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
- .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
- .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
- .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
- .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
- .Distinct()
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- watch.Stop();
- return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
- }
- /// <summary>
- /// 接团信息列表 Page Init
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupPageListInit()
- {
- var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
- var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
- rankDatas.Insert(0, new { Id = 0, Name = "全部" });
- var _view = new
- {
- depData = depDatas,
- rankData = rankDatas
- };
- return Ok(JsonView(true, "查询成功!", _view));
- }
- /// <summary>
- /// 接团信息列表 Page
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (dto.PortType == 1 || dto.PortType == 2) // web/Android
- {
- string sqlWhere = string.Empty;
- if (dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- if (!string.IsNullOrEmpty(dto.SearchCriteria))
- {
- string tj = dto.SearchCriteria;
- 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}%')",
- tj, tj, tj, tj, tj);
- }
- if (int.TryParse(dto.Rank, out int rankId))
- {
- if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
- }
- string sqlWhere1 = string.Empty;
- if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
- {
- sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
- TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
- JietuanOperator,IsSure,CreateTime,IsBid
- From (
- Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
- CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
- ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
- gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
- ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
- su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
- From Grp_DelegationInfo gdi
- Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {0}
- ) temp {1}", sqlWhere, sqlWhere1);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
- var _view = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _DelegationList
- };
- return Ok(JsonView(true, "查询成功!", _view, total));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 团组列表
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (dto.PortType != 1 && dto.PortType != 2)
- {
- return Ok(JsonView(false, "查询失败!"));
- }
- string orderbyStr = "order by gdi.CreateTime Desc";
- string sqlWhere = string.Empty;
- if (dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- //团组类型
- if (dto.TeamDid > 0)
- {
- sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
- }
- //团组名称
- if (!string.IsNullOrEmpty(dto.TeamName))
- {
- sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
- }
- //客户名称
- if (!string.IsNullOrEmpty(dto.ClientName))
- {
- sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
- }
- //客户单位
- if (!string.IsNullOrEmpty(dto.ClientUnit))
- {
- sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
- }
- //出访时间
- if (!string.IsNullOrEmpty(dto.visitDataTime))
- {
- sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
- orderbyStr = "order by gdi.VisitDate";
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
- JietuanOperator,IsSure,CreateTime
- From (
- Select row_number() over({0}) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
- ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
- su.CnName JietuanOperator,IsSure,gdi.CreateTime
- From Grp_DelegationInfo gdi
- Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {1}
- ) temp ", orderbyStr, sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
- #region 处理所属部门
- /*
- * 1.sq 和 gyy 等显示 市场部
- * 2.王鸽和主管及张总还有管理员号统一国交部
- * 2-1. 4 管理员 ,21 张海麟
- */
- List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
- List<int> userIds1 = new List<int>() { 4, 21 };
- var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
- .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
- .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
- .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
- .ToList();
- foreach (var item in _DelegationList)
- {
- item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
- }
- #endregion
- var _view = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _DelegationList
- };
- return Ok(JsonView(true, "查询成功!", _view, total));
- }
- /// <summary>
- /// 接团信息详情
- /// </summary>
- /// <param name="dto">团组info请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
- {
- var groupData = await _groupRepository.GetGroupInfo(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 接团信息 编辑添加
- /// 基础信息数据源
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
- {
- var groupData = await _groupRepository.GroupEditBasicSource(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 成本修改团组信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
- {
- var jw = JsonView(false, "操作失败");
- var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (di == null)
- {
- jw.Msg = "参数有误!";
- return Ok(jw);
- }
- #region 添加出访起止时间
- var startTime = new DateTime();
- var endTime = new DateTime();
- if (DateTime.TryParse(dto.VisitDate, out startTime))
- {
- endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
- }
- else
- {
- jw.Msg = "参数有误!";
- return Ok(jw);
- }
- #endregion
- di.VisitDate = startTime;
- di.VisitPNumber = dto.VisitPNumber;
- di.VisitDays = dto.VisitDays;
- di.VisitStartDate = startTime;
- di.VisitEndDate = endTime;
- var count = _sqlSugar.Updateable(di)
- .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays , x.VisitStartDate, x.VisitEndDate })
- .ExecuteCommand();
- return Ok( count > 0 ? JsonView(true, "操作成功") : jw);
- }
- /// <summary>
- /// 接团信息 编辑添加
- /// 省份-城市 基础信息数据源
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
- {
- int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
- string search = dto.Search;
- var data = await _groupRepository.CityBasicSource();
- int total = data.Length;
- data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
- .Skip((pageIndex - 1) * pageSize)
- .Take(pageSize)
- .ToArray();
- return Ok(JsonView(data, total));
- }
- /// <summary>
- /// 接团信息 操作(增改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
- {
- // 创建 Stopwatch 实例
- Stopwatch stopwatch = Stopwatch.StartNew();
- decimal ffrPrice = 0.00M;
- DateTime? visitDt = null;
- if (dto.Status == 2)
- {
- var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
- if (groupInfo != null)
- {
- ffrPrice = groupInfo.PaymentMoney;
- visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
- }
- }
- var groupData = await _groupRepository.GroupOperation(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- int diId = 0;
- try
- {
- //添加时 默认加入团组汇率
- if (dto.Status == 1) //添加
- {
- diId = groupData.Data;
- //添加默认币种
- await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
- //默认分配权限
- await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
- //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
- var _managerIds = new List<int>() { 22, 32, 21 };
- var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
- if (userIds.Count > 0)
- {
- userIds.Add(208);
- //创建团组管控
- GroupStepForDelegation.CreateWorkStep(diId);
- //发送消息
- string groupName = dto.TeamName;
- string createGroupUser = string.Empty;
- var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- if (userInfo != null) createGroupUser = userInfo.CnName;
- string title = $"系统通知";
- string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- //默认创建倒推表
- await _invertedListRep._Create(dto.UserId, diId);
- }
- else if (dto.Status == 2)
- {
- diId = dto.Id;
- }
- #region 签证人员团组时间通知
- #region 计算出访起止时间
- var startTime = new DateTime();
- var endTime = new DateTime();
- if (DateTime.TryParse(dto.VisitDate, out startTime))
- {
- endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
- }
- #endregion
- #endregion
- #region 团组操作默认添加/修改收款账单
- if (dto.PayDay > 0 && dto.PaymentMoney > 0)
- {
- var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
- .Where(x => x.IsDel == 0 &&
- x.Diid == diId &&
- x.Remark.Equals("预付款")
- )
- .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
- .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
- .FirstAsync();
- ffrInfo = new Fin_ForeignReceivables()
- {
- Diid = diId,
- PriceName = dto.ClientUnit,
- Price = dto.PaymentMoney,
- Count = 1,
- Unit = $"元",
- ItemSumPrice = dto.PaymentMoney,
- Rate = 1.0000M,
- Currency = 836,
- AddingWay = 0,
- CreateUserId = dto.UserId,
- CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
- Remark = $"预付款"
- };
- if (ffrInfo == null) //Add
- {
- await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
- }
- else //修改
- {
- await _sqlSugar.Updateable(ffrInfo)
- .UpdateColumns(x => new
- {
- x.PriceName,
- x.Price,
- x.ItemSumPrice,
- x.CreateTime,
- x.CreateUserId
- })
- .WhereColumns(x => x.Id)
- .ExecuteCommandAsync();
- }
- }
- #endregion
- if (diId > 0)
- {
- await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
- }
- // 停止计时
- stopwatch.Stop();
- return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
- }
- catch (Exception ex)
- {
- // 停止计时
- stopwatch.Stop();
- Logs("[response]" + JsonConvert.SerializeObject(dto));
- Logs(ex.Message);
- //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
- }
- // 停止计时
- stopwatch.Stop();
- return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
- }
- /// <summary>
- /// 接团流程操作(增改)
- /// 安卓端使用 建团时添加客户名单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
- //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
- #endregion
- #endregion
- try
- {
- //_sqlSugar.BeginTran();
- decimal ffrPrice = 0.00M;
- DateTime? visitDt = null;
- if (dto.Status == 2)
- {
- var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
- if (groupInfo != null)
- {
- ffrPrice = groupInfo.PaymentMoney;
- visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
- }
- }
- var _dto = new GroupOperationDto();
- _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
- var groupData = await _groupRepository.GroupOperation(_dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
- }
- int diId = 0;
- //添加时 默认加入团组汇率
- if (dto.Status == 1) //添加
- {
- diId = groupData.Data;
- //添加默认币种
- await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
- //默认分配权限
- await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
- //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
- List<int> _managerIds = new List<int>() { 21, 22, 32 };
- var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
- if (userIds.Count > 0)
- {
- userIds.Add(208);
- //创建团组管控
- GroupStepForDelegation.CreateWorkStep(diId);
- //发送消息
- string groupName = dto.TeamName;
- string createGroupUser = string.Empty;
- var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- if (userInfo != null) createGroupUser = userInfo.CnName;
- string title = $"系统通知";
- string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- #region 应用推送
- try
- {
- await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
- Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
- Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
- if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
- {
- List<string> userList = new List<string>() { users.QiyeChatUserId };
- await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
- }
- }
- catch (Exception ex)
- {
- }
- #endregion
- //默认创建倒推表
- await _invertedListRep._Create(dto.UserId, diId);
- }
- if (dto.Status == 2)
- {
- diId = dto.Id;
- if (diId == 0)
- {
- //_sqlSugar.RollbackTran();
- return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
- }
- }
- var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
- if (viewData.Code != 0)
- {
- //_sqlSugar.RollbackTran();
- return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
- }
- #region 团组操作默认添加/修改收款账单
- if (dto.PayDay > 0 && dto.PaymentMoney > 0)
- {
- var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
- .Where(x => x.IsDel == 0 &&
- x.Diid == diId &&
- x.Remark.Equals("预付款")
- )
- .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
- .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
- .FirstAsync();
- ffrInfo = new Fin_ForeignReceivables()
- {
- Diid = diId,
- PriceName = dto.ClientUnit,
- Price = dto.PaymentMoney,
- Count = 1,
- Unit = $"元",
- ItemSumPrice = dto.PaymentMoney,
- Rate = 1.0000M,
- Currency = 836,
- AddingWay = 0,
- CreateUserId = dto.UserId,
- CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
- Remark = $"预付款"
- };
- if (ffrInfo == null) //Add
- {
- await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
- }
- else //修改
- {
- await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
- .UpdateColumns(x => new
- {
- x.PriceName,
- x.Price,
- x.ItemSumPrice,
- x.CreateTime,
- x.CreateUserId
- })
- .WhereColumns(x => x.Id)
- .ExecuteCommandAsync();
- }
- }
- #endregion
- #region 签证人员团组时间通知
- #region 计算出访起止时间
- var startTime = new DateTime();
- var endTime = new DateTime();
- if (DateTime.TryParse(dto.VisitDate, out startTime))
- {
- endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
- }
- #endregion
- if (diId > 0)
- {
- await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
- }
- #endregion
- //_sqlSugar.CommitTran();
- return Ok(JsonView(true, "添加成功"));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 接团流程操作(增改)
- /// 安卓端使用 建团时添加客户名单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
- //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
- #endregion
- #endregion
- _sqlSugar.BeginTran();
- decimal ffrPrice = 0.00M;
- DateTime? visitDt = null;
- if (dto.Status == 2)
- {
- var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
- if (groupInfo != null)
- {
- ffrPrice = groupInfo.PaymentMoney;
- visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
- }
- }
- var _dto = new GroupOperationDto();
- _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
- var groupData = await _groupRepository.GroupOperation(_dto);
- if (groupData.Code != 0)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
- }
- try
- {
- int diId = 0;
- //添加时 默认加入团组汇率
- if (dto.Status == 1) //添加
- {
- diId = groupData.Data;
- //添加默认币种
- await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
- //默认分配权限
- await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
- //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
- List<int> _managerIds = new List<int>() { 21, 22, 32 };
- var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
- if (userIds.Count > 0)
- {
- userIds.Add(208);
- //创建团组管控
- GroupStepForDelegation.CreateWorkStep(diId);
- //发送消息
- string groupName = dto.TeamName;
- string createGroupUser = string.Empty;
- var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- if (userInfo != null) createGroupUser = userInfo.CnName;
- string title = $"系统通知";
- string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- #region 应用推送
- try
- {
- await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
- Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
- Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
- if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
- {
- List<string> userList = new List<string>() { users.QiyeChatUserId };
- await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
- }
- }
- catch (Exception ex)
- {
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
- }
- #endregion
- //默认创建倒推表
- await _invertedListRep._Create(dto.UserId, diId);
- }
- else if (dto.Status == 2)
- {
- diId = dto.Id;
- if (diId == 0)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
- }
- }
- var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
- if (viewData.Code != 0)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
- }
- #region 团组操作默认添加/修改收款账单
- if (dto.PayDay > 0 && dto.PaymentMoney > 0)
- {
- var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
- .Where(x => x.IsDel == 0 &&
- x.Diid == diId &&
- x.Remark.Equals("预付款")
- )
- .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
- .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
- .FirstAsync();
- ffrInfo = new Fin_ForeignReceivables()
- {
- Diid = diId,
- PriceName = dto.ClientUnit,
- Price = dto.PaymentMoney,
- Count = 1,
- Unit = $"元",
- ItemSumPrice = dto.PaymentMoney,
- Rate = 1.0000M,
- Currency = 836,
- AddingWay = 0,
- CreateUserId = dto.UserId,
- CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
- Remark = $"预付款"
- };
- if (ffrInfo == null) //Add
- {
- await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
- }
- else //修改
- {
- await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
- .UpdateColumns(x => new
- {
- x.PriceName,
- x.Price,
- x.ItemSumPrice,
- x.CreateTime,
- x.CreateUserId
- })
- .WhereColumns(x => x.Id)
- .ExecuteCommandAsync();
- }
- }
- #endregion
- #region 签证人员团组时间通知
- #region 计算出访起止时间
- var startTime = new DateTime();
- var endTime = new DateTime();
- if (DateTime.TryParse(dto.VisitDate, out startTime))
- {
- endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
- }
- #endregion
- if (diId > 0)
- {
- await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
- }
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 接团信息 操作(删除)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupDel(GroupDelDto dto)
- {
- var diId = dto.Id;
- if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
- #region 删除 验证 (费用录入、出入境费用、收款账单)
- //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
- //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
- //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
- //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
- #endregion
- var groupData = await _groupRepository.GroupDel(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 获取团组销售报价号
- /// 团组添加时 使用
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupSalesQuoteNo()
- {
- var groupData = await _groupRepository.GetGroupSalesQuoteNo();
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- object salesQuoteNo = new
- {
- SalesQuoteNo = groupData.Data
- };
- return Ok(JsonView(salesQuoteNo));
- }
- /// <summary>
- /// 设置确认出团
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
- {
- var groupData = await _groupRepository.ConfirmationGroup(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
- #region OA消息推送
- try
- {
- string groupName = groupInfo.TeamName;
- var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
- string title = $"系统通知";
- string content = $"团组[{groupName}]已确认出团!";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
- }
- catch (Exception ex)
- {
- }
- #endregion
- #region 应用推送
- try
- {
- await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
- Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
- Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
- if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
- {
- List<string> userList = new List<string>() { users.QiyeChatUserId };
- await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
- }
- }
- catch (Exception ex)
- {
- }
- #endregion
- GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
- return Ok(JsonView(true, "操作成功!", groupData.Data));
- }
- /// <summary>
- /// 获取团组名称data And 签证国别Data
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
- {
- var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
- {
- try
- {
- Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 团组清单 Excel
- /// </summary>
- /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
- /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
- {
- DateTime _beginDt, _endDt;
- bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
- endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
- if (!beginBool && !endBool)
- {
- return Ok(JsonView(false, "开始或结束时间不正确!"));
- }
- string sql = string.Format(@"
- SELECT
- ROW_NUMBER,
- Id,
- SalesQuoteNo,
- TourCode,
- TeamTypeId,
- TeamType,
- TeamLevId,
- TeamLev,
- TeamName,
- ClientName,
- ClientUnit,
- VisitDate,
- VisitDays,
- VisitPNumber,
- JietuanOperatorId,
- JietuanOperator,
- IsSure,
- CreateUserName,
- IsBid
- FROM
- (
- SELECT
- ROW_NUMBER() OVER(
- ORDER BY
- gdi.VisitDate Desc
- ) AS ROW_NUMBER,
- gdi.Id,
- SalesQuoteNo,
- TourCode,
- ssd.Id TeamTypeId,
- ssd.Name TeamType,
- ssd1.Id TeamLevId,
- ssd1.Name TeamLev,
- TeamName,
- ClientName,
- ClientUnit,
- VisitDate,
- VisitDays,
- VisitPNumber,
- JietuanOperator JietuanOperatorId,
- su.CnName JietuanOperator,
- IsSure,
- gdi.CreateTime,
- su1.CnName As CreateUserName,
- gdi.IsBid
- FROM
- Grp_DelegationInfo gdi
- LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
- LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
- LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
- LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
- WHERE
- gdi.IsDel = 0
- AND gdi.IsBid = 0
- AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
- ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
- var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
- #region 处理所属部门
- /*
- * 1.sq 和 gyy 等显示 市场部
- * 2.王鸽和主管及张总还有管理员号统一国交部
- * 2-1. 4 管理员 ,21 张海麟
- */
- List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
- List<int> userIds1 = new List<int>() { 4, 21 };
- var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
- .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
- .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
- .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
- .ToListAsync();
- var droupIds = groupList.Select(it => it.Id).ToList();
- var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
- .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
- .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
- .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
- .Select((tcl, dc, cc) => new ClientInfoInfo_Group
- {
- DiId = tcl.DiId,
- LastName = dc.LastName,
- FirstName = dc.FirstName,
- Sex = dc.Sex,
- Birthday = dc.BirthDay,
- Company = cc.CompanyFullName,
- Job = dc.Job,
- CreateTime = tcl.CreateTime,
- })
- .ToList();
- foreach (var item in groupList)
- {
- item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
- string groupFirstName = "";
- var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
- if (currDatas.Any())
- {
- groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
- }
- item.GroupFirst = groupFirstName;
- }
- #endregion
- #region Excel
- var tempPath = AppSettingsHelper.Get("ExcelTempPath");
- var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
- var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
- var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
- var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
- designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
- DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
- dt.TableName = "GroupList";
- designer.SetDataSource(dt);
- designer.Process();
- if (!Directory.Exists(savePath))
- {
- Directory.CreateDirectory(savePath);
- }
- string serverPath = $"{savePath}{fileName}";
- designer.Workbook.Save(serverPath);
- string rst = $"{servicePath}{ftpPath}{fileName}";
- #endregion
- return Ok(JsonView(true, "操作成功!", rst));
- }
- /// <summary>
- /// 团组合同下载(1.付款80% 2.付全款)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- /// <exception cref="Exception"></exception>
- [HttpPost]
- public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
- {
- var jw = JsonView(false);
- var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
- .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
- if (di == null)
- {
- jw.Msg = "团组Id有误!";
- return Ok(jw);
- }
- #region 权限校验
- var allDownFile = new List<int>() { 21 };
- try
- {
- var setting = _sqlSugar.Queryable<Sys_SetData>()
- .First(x => x.Id == 1418 && x.IsDel == 0);
- allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
- }
- catch (Exception)
- { }
- var guojiaoDownFile = new List<int>() { 330 };
- var shichangDownFile = new List<int>() { 95 };
- if (allDownFile.Contains(dto.UserId))
- {
- }
- else if (guojiaoDownFile.Contains(dto.UserId))
- {
- var guojiaobuDi = new List<int>() { 4, 21 };
- var departmentStr = _sqlSugar.Queryable<Sys_Department>()
- .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
- .Where((d, u) => u.Id == di.JietuanOperator)
- .Select((d, u) => d.DepName)
- .First();
- if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
- {
- jw.Msg = "暂无下载权限!";
- return Ok(jw);
- }
- }
- else if (shichangDownFile.Contains(dto.UserId))
- {
- var dic = new Dictionary<int, int[]>()
- {
- { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
- };
- try
- {
- var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
- if (sqSetting != null)
- {
- Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
- foreach (var item in result.Keys)
- {
- if (dic.Keys.Contains(item))
- {
- int[] dilatation = new int[dic[item].Length + result[item].Length];
- Array.Copy(dic[item], dilatation, dic[item].Length);
- Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
- dic[item] = dilatation;
- }
- else
- {
- dic.Add(item, result[item]);
- }
- }
- }
- if (!dic[95].Contains(di.CreateUserId))
- {
- jw.Msg = "暂无下载权限!";
- return Ok(jw);
- }
- }
- catch (Exception)
- { }
- }
- else if (dto.UserId == di.CreateUserId)
- {
- }
- else
- {
- jw.Msg = "暂无下载权限!";
- return Ok(jw);
- }
- #endregion
- var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
- .Where(x=>x.DiId == dto.GroupId && x.IsDel == 0)
- .ToListAsync();
- if (!blackCodeList.Any())
- {
- jw.Msg = "该团无机票行程代码!";
- return Ok(jw);
- }
- var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
- .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
- if (groupEnterExitCost == null)
- {
- jw.Msg = "暂无三公费用信息!";
- return Ok(jw);
- }
- var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
- rateList ??= new List<CurrencyInfo>();
- var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
- var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
- .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
- .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
- .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
- .Select((x, a, b) => new
- {
- x.Index,
- itemName = a.Name,
- CurrencyStr = b.Name,
- x.Cost,
- x.SubTotal,
- x.Remark
- })
- .OrderBy((x) => x.Index)
- .ToList();
- decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
- decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
- decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
- decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
- decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
- decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
- decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
- decimal subJJC = 0.00M,
- subGWC = 0.00M,
- subTDC = 0.00M;
- //经济舱
- if (groupEnterExitCost.SumJJC == 1)
- {
- subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
- }
- //公务舱
- if (groupEnterExitCost.SumGWC == 1)
- {
- subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
- }
- //头等舱
- if (groupEnterExitCost.SumTDC == 1)
- {
- subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
- }
- var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
- .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
- .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
- .LeftJoin<Crm_CustomerCompany>((x, s, dc,cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
- .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
- .Select((x, s, dc, cc) => new groupClints
- {
- Id =x.Id,
- Name =s.Name,
- IsAccompany =x.IsAccompany,
- CompanyFullName =cc.CompanyFullName
- })
- .ToListAsync();
- groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
- //获取舱位人数
- var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
- .GroupBy(x => x.Name)
- .Select(x => new { Cabin = x.Key, Count = x.Count() })
- .ToList();
- string cityPath = string.Empty;
- string startCity = string.Empty;
- string endCity = string.Empty;
- foreach (var item in blackCodeList)
- {
- string city = GeneralMethod.GetGroupCityLine(item, "-");
- cityPath += city + "\r\n";
- if (item.Equals(blackCodeList.First()))
- {
- var sp = city.Split('-');
- startCity = sp[0];
- endCity = sp[sp.Length - 1];
- }
- }
- Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
- bookMarkDic.Add("ClientUnit",di.ClientUnit);
- bookMarkDic.Add("VisitCountry", di.VisitCountry);
- bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
- bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
- bookMarkDic.Add("CityPath", cityPath);
- bookMarkDic.Add("StartCity", startCity);
- bookMarkDic.Add("EndCity", endCity);
- bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays -1}晚");
- Document doc = null;
- var percentage = 0.8M;
- var fileNameadd = "预付";
- if (dto.FileType == 1)
- {
- doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
- }
- else if (dto.FileType == 2)
- {
- doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
- percentage = 1;
- fileNameadd = "全款";
- }
- else
- {
- throw new Exception("FileType有误!");
- }
- DocumentBuilder builder = new DocumentBuilder(doc);
- decimal totalPrice = 0.00M;
- Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
- if (firstTable != null)
- {
- // 遍历表格的行和单元格
- foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
- {
- for (int i = 0; i < row.Cells.Count; i++)
- {
- var cell = row.Cells[i];
- // 读取单元格内容
- string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
- if (cellTextFirst.Contains("舱位"))
- {
- break;
- }
- if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
- {
- if (i == 2)
- {
- if (cellTextFirst == "经济舱")
- {
- // 设置单元格内容
- cell.FirstParagraph.Runs.Clear(); // 清除原有内容
- cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
- }
- else
- {
- // 设置单元格内容
- cell.FirstParagraph.Runs.Clear(); // 清除原有内容
- cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
- }
- }
- if (i == 3)
- {
- var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
- if (count != null)
- {
- // 设置单元格内容
- cell.FirstParagraph.Runs.Clear(); // 清除原有内容
- cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
- }
- }
- if (i == 4)
- {
- var rowPrice = 0.00M;
- var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
- count ??= 0;
- if (cellTextFirst == "经济舱")
- {
- rowPrice = subJJC * (int)count;
- }
- else
- {
- rowPrice = subGWC * (int)count;
- }
- totalPrice += rowPrice;
- // 设置单元格内容
- cell.FirstParagraph.Runs.Clear(); // 清除原有内容
- cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
- }
- }
- }
- }
- }
- bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
- bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
- bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
- //--合同表格部分
- bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
- bookMarkDic.Add("ClientUnit1", di.ClientUnit);
- bookMarkDic.Add("VisitCountry1", di.VisitCountry);
- bookMarkDic.Add("DayCount", di.VisitDays.ToString());
- bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日")+"-"+di.VisitEndDate.ToString("yyyy年MM月dd日"));
- bookMarkDic.Add("CityPath1", cityPath);
- bookMarkDic.Add("CityPath2", cityPath);
- Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
- if (contractTable != null)
- {
- //数据源
- var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
- .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
- .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
- .Select((it, y, s) => new
- {
- it.Cost,
- it.SubTotal,
- it.Type,
- y.Id,
- y.City,
- s.Name,
- CurrencyCodeCn = s.Remark
- })
- .ToList()
- .Select(x => new
- {
- CurrencyCode = x.Name,
- CityId = x.Id,
- x.City,
- VisitPNumber = di.VisitPNumber,
- x.Type,
- x.Cost,
- x.SubTotal,
- Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
- x.CurrencyCodeCn,
- });
- var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
- var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
- var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
- var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
- List<tableSetting> tableSettings = new List<tableSetting>()
- {
- new tableSetting{ Index = 1 , Property = "City"},
- new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
- new tableSetting{ Index = 3 , Property = "Cost"},
- new tableSetting{ Index = 4 , Property = "VisitPNumber"},
- //new tableSetting{ Index = 5 , Property = ""},
- //new tableSetting{ Index = 6 , Property = ""},
- new tableSetting{ Index = 7 , Property = "Rate"},
- //new tableSetting{ Index = 8 , Property = ""},
- };
- //1.住宿费
- int cloneRow = 8;
- int startDayPrice = 8; //写入index
- decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
- foreach (var dac in dac1)
- {
- var first = dac.First();
- var dayCount = dac.Count();
- Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
- for (int i = 1; i < row.Cells.Count; i++)
- {
- var cell = row.Cells[i];
- var findProperty = tableSettings.Find(x => x.Index == i);
- if (findProperty != null)
- {
- string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
- // 设置单元格内容
- cell.FirstParagraph.Runs.Clear(); // 清除原有内容
- cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
- }
- else
- {
- switch (i)
- {
- case 5:
- cell.FirstParagraph.Runs.Clear();
- cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
- break;
- case 6:
- var xiaoji = dayCount * first.VisitPNumber * first.Cost;
- cell.FirstParagraph.Runs.Clear();
- cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
- break;
- case 8:
- var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
- cell.FirstParagraph.Runs.Clear();
- cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
- ZSPriceSum += xiaojiRMB;
- break;
- default:
- break;
- }
- }
- }
- startDayPrice++;
- if (!dac1.Last().Equals(dac))
- {
- Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
- // 将克隆的行追加到原行后面
- contractTable.Rows.Insert(startDayPrice, newRow);
- }
- else
- {
- cloneRow += dac1.Count() + 1;
- startDayPrice = cloneRow;
- }
- }
- //2.伙食费
- foreach (var dac in dac2)
- {
- var first = dac.First();
- var dayCount = dac.Count();
- Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
- for (int i = 1; i < row.Cells.Count; i++)
- {
- var cell = row.Cells[i];
- var findProperty = tableSettings.Find(x => x.Index == i);
- if (findProperty != null)
- {
- string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
- // 设置单元格内容
- cell.FirstParagraph.Runs.Clear(); // 清除原有内容
- cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
- }
- else
- {
- switch (i)
- {
- case 5:
- cell.FirstParagraph.Runs.Clear();
- cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
- break;
- case 6:
- var xiaoji = dayCount * first.VisitPNumber * first.Cost;
- cell.FirstParagraph.Runs.Clear();
- cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
- break;
- case 8:
- var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
- cell.FirstParagraph.Runs.Clear();
- cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
- HSPriceSum += xiaojiRMB;
- break;
- default:
- break;
- }
- }
- }
- startDayPrice++;
- if (!dac2.Last().Equals(dac))
- {
- Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
- // 将克隆的行追加到原行后面
- contractTable.Rows.Insert(startDayPrice, newRow);
- }
- else
- {
- cloneRow += dac2.Count() + 1;
- startDayPrice = cloneRow;
- }
- }
- //3.公杂费
- foreach (var dac in dac3)
- {
- var first = dac.First();
- var dayCount = dac.Count();
- Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
- for (int i = 1; i < row.Cells.Count; i++)
- {
- var cell = row.Cells[i];
- var findProperty = tableSettings.Find(x => x.Index == i);
- if (findProperty != null)
- {
- string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
- // 设置单元格内容
- cell.FirstParagraph.Runs.Clear(); // 清除原有内容
- cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
- }
- else
- {
- switch (i)
- {
- case 5:
- cell.FirstParagraph.Runs.Clear();
- cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
- break;
- case 6:
- var xiaoji = dayCount * first.VisitPNumber * first.Cost;
- cell.FirstParagraph.Runs.Clear();
- cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
- break;
- case 8:
- var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
- cell.FirstParagraph.Runs.Clear();
- cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
- GZPriceSum += xiaojiRMB;
- break;
- default:
- break;
- }
- }
- }
- startDayPrice++;
- if (!dac3.Last().Equals(dac))
- {
- Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
- // 将克隆的行追加到原行后面
- contractTable.Rows.Insert(startDayPrice, newRow);
- }
- else
- {
- cloneRow += dac3.Count() + 1;
- startDayPrice = cloneRow;
- }
- }
- //合并单元格
- for (int i = 8; i < contractTable.Rows.Count - 1; i++)
- {
- var currentRow = contractTable.Rows[i];
- var nextRow = contractTable.Rows[i + 1];
- // 获取当前行和下一行的第一个单元格
- Cell currentCell = currentRow.Cells[0];
- Cell nextCell = nextRow.Cells[0];
- // 检查单元格内容是否一致(去除尾部的换行符)
- string currentText = currentCell.GetText().Trim();
- string nextText = nextCell.GetText().Trim();
- if (currentText == nextText)
- {
- // 如果当前单元格已经被合并,找到合并的起始单元格
- if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
- {
- // 找到合并的起始单元格
- int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
- // 将下一行的单元格设置为合并的后续单元格
- nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
- }
- else
- {
- // 如果当前单元格是合并的起始单元格
- currentCell.CellFormat.VerticalMerge = CellMerge.First;
- // 将下一行的单元格设置为合并的后续单元格
- nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
- }
- }
- else
- {
- // 如果内容不一致,重置当前单元格的合并属性
- if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
- {
- // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
- int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
- contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
- }
- else
- {
- currentCell.CellFormat.VerticalMerge = CellMerge.None;
- }
- }
- }
- bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
- bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
- bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
- }
- foreach (var bookmarkName in bookMarkDic.Keys)
- {
- Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
- if (bookmark != null)
- {
- if (bookmarkName == "ClientUnit")
- {
- // 移动到书签位置
- builder.MoveTo(bookmark.BookmarkStart);
- // 设置字体样式为下划线
- builder.Font.Underline = Aspose.Words.Underline.Single;
- // 插入书签值
- builder.Write(bookMarkDic[bookmarkName]);
- // 清除字体格式,避免影响后续文本
- builder.Font.ClearFormatting();
- }
- else
- {
- builder.MoveToBookmark(bookmarkName);
- builder.Write(bookMarkDic[bookmarkName]);
- }
- }
- }
- string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
- doc.Save(savePaht);
- jw.Msg = "生成成功!";
- jw.Code = 200;
- jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath"))};
- return Ok(jw);
- }
- static int FindMergeStartRowIndex(Table table, int rowIndex)
- {
- int index = rowIndex;
- while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
- {
- index--;
- }
- return index;
- }
- #endregion
- #region 团组&签证
- /// <summary>
- /// 根据团组Id获取签证客户信息List
- /// </summary>
- /// <param name="dto">请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
- {
- var groupData = await _groupRepository.GetCrmByGroupId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度01(团组列表)
- /// </summary>
- /// <param name="dto">请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "参数为空"));
- }
- DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
- return Ok(JsonView(visaList));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请求错误:"));
- }
- List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
- return Ok(JsonView(list));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度03(相册)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请求错误:"));
- }
- List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
- string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
- list.ForEach(s => s.url = url);
- return Ok(JsonView(list));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度04(图片上传)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
- {
- //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
- //if (!string.IsNullOrEmpty(result))
- //{
- //}
- //else {
- // return Ok(JsonView(false, "上传失败"));
- //}
- DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
- int sucNum = 0;
- try
- {
- foreach (var item in dto.base64DataList)
- {
- string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
- string result = DecodeBase64ToImage(item, imageName);
- if (!string.IsNullOrEmpty(result))
- {
- Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
- pic.CreateUserId = dto.CreateUserId;
- pic.PicName = imageName;
- pic.PicPath = result;
- pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
- int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
- if (insertResult > 0)
- {
- sucNum++;
- }
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- string msg = string.Format(@"成功上传{0}张", sucNum);
- return Ok(JsonView(true, msg));
- }
- private string DecodeBase64ToImage(string base64DataURL, string imgName)
- {
- string filename = "";//声明一个string类型的相对路径
- String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
- System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
- try//会有异常抛出,try,catch一下
- {
- byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
- System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
- bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
- var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
- //文件名称
- filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
- //上传的文件的路径
- string filePath = "";
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + filename;
- //string url = HttpRuntime.AppDomainAppPath.ToString();
- //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
- //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
- bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
- //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
- //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
- //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
- ms.Close();//关闭当前流,并释放所有与之关联的资源
- bitmap.Dispose();
- }
- catch (Exception e)
- {
- string massage = e.Message;
- Logs("IOS图片上传Error:" + massage);
- //filename = e.Message;
- }
- return filename;//返回相对路径
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请求错误:"));
- }
- string msg = "参数错误";
- if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
- {
- try
- {
- //_delegationVisaRep.BeginTran();
- var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
- .SetColumns(it => it.WorkStatus == dto.visaStatus)
- .Where(s => s.Id == dto.visaProgressCustomerId)
- .ExecuteCommandAsync();
- if (updCount > 0 && dto.publishCode == 1)
- {
- _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
- string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
- OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
- //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
- //var groupData = await _groupRepository.GetGroupInfo(grpDto);
- _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
- if (groupData == null)
- {
- _delegationVisaRep.RollbackTran();
- }
- string title = string.Format(@"[签证进度更新]");
- string content = string.Format(@"测试文本");
- bool rst = await _message.AddMsg(new MessageDto()
- {
- Type = MessageTypeEnum.GroupVisaProgressUpdate,
- IssuerId = dto.publisher,
- Title = title,
- Content = content,
- ReleaseTime = DateTime.Now,
- UIdList = new List<int> {
- 234
- }
- });
- if (rst)
- {
- return Ok(JsonView(true, "发送通知成功"));
- }
- }
- //_delegationVisaRep.CommitTran();
- }
- catch (Exception)
- {
- //_delegationVisaRep.RollbackTran();
- }
- }
- return Ok(JsonView(true, msg));
- }
- #endregion
- #region 团组任务分配
- /// <summary>
- /// 团组任务分配初始化
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetTaskAssignmen()
- {
- var groupData = await _taskAssignmentRep.GetTaskAssignmen();
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 团组任务分配查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
- {
- var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 团组任务分配操作
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
- {
- Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 团组任务分配
- /// 批量分配
- /// 查询团组
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
- {
- //参数验证
- if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
- if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
- return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
- return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
- }
- /// <summary>
- /// 团组任务分配
- /// 批量分配
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
- {
- //参数验证
- if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
- if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
- if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
- return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
- }
- #endregion
- #region 团组费用审核
- /// <summary>
- /// 费用审核
- /// 团组列表 Page
- /// </summary>
- /// <param name="_dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
- {
- string sqlWhere = string.Empty;
- if (_dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (_dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- if (!string.IsNullOrEmpty(_dto.SearchCriteria))
- {
- string tj = _dto.SearchCriteria;
- 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}%')",
- tj, tj, tj, tj, tj);
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
- VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
- From (
- Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
- ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
- VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
- From Grp_DelegationInfo gdi
- Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {0}
- ) temp ", sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
- var _view = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _DelegationList
- };
- return Ok(JsonView(true, "查询成功!", _view, total));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 获取团组费用审核
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 页面操作权限验证
- var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- var _view = new Grp_CreditCardPaymentView();
- var clientNameList = getSimplClientList(_dto.DiId);
- #region 费用清单
- var exp = Expressionable.Create<Grp_CreditCardPayment>();
- exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
- exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
- var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
- var detailList = new List<Grp_CreditCardPaymentDetailView>();
- var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
- /*
- * 76://酒店预订
- */
- var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 79://车/导游地接
- */
- var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 80: //签证
- */
- var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- *81: //邀请/公务活动
- */
- var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 82: //团组客户保险
- */
- var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * Lable = 85 机票预订
- */
- var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 85 机票预定
- */
- var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 98 其他款项
- */
- var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 285:收款退还
- */
- var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 1015: //超支费用
- */
- var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
- /*
- * 币种信息
- */
- var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
- /*
- * 车/导游地接 费用类型
- */
- var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
- /*
- * 车/导游地接 费用类型
- */
- var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
- var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
- /*
- * 用户信息
- */
- var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
- /*
- * 费用模块
- */
- var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
- string priceModule = string.Empty;
- if (sdPriceName != null)
- {
- priceModule = sdPriceName.Name;
- }
- /*
- * 成本信息
- */
- var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
- decimal _groupRate = 0.0000M;
- string _groupCurrencyCode = "-";
- if (groupCost != null)
- {
- _groupRate = groupCost.Rate;
- if (int.TryParse(groupCost.Currency, out int _currency))
- {
- _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
- }
- else _groupCurrencyCode = groupCost.Currency;
- }
- string costContentSql = $"Select * From Grp_GroupCost";
- var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
- //处理日期为空的天数
- for (int i = 0; i < groupCostDetails.Count; i++)
- if (i != 0)
- if (string.IsNullOrEmpty(groupCostDetails[i].Date))
- groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
- /*
- * 处理详情数据
- */
- foreach (var entity in entityList)
- {
- var _detail = new Grp_CreditCardPaymentDetailView();
- _detail.Id = entity.Id;
- _detail.PriceName = priceModule;
- _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
- if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
- else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
- //处理金额
- if (entity.CTable == 1015)
- {
- var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
- if (czInfo != null)
- {
- entity.PayMoney = czInfo.Price * czInfo.PriceCount;
- entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
- }
- }
- /*
- * 应付款金额
- */
- var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
- string PaymentCurrency_WaitPay = "Unknown";
- string hotelCurrncyCode = "Unknown";
- string hotelCurrncyName = "Unknown";
- if (sdPaymentCurrency_WaitPay != null)
- {
- PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
- hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
- hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
- if (hotelCurrncyCode.Equals("CNY"))
- {
- entity.DayRate = 1.0000M;
- }
- }
- _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
- /*
- * 此次付款金额
- */
- decimal CurrPayStr = 0.00M,
- OriginalCurrPay = 0.00M;
- if (entity.PayPercentage == 0)
- {
- if (entity.PayThenMoney != 0)
- CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
- }
- else
- {
- if (entity.PayMoney != 0)
- {
- CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
- }
- }
- //if (_dto.Label == 79)
- //{
- // string original = string.Empty;
- // if (hotelCurrncyCode.Equals("CNY"))
- // {
- // OriginalCurrPay = CurrPayStr;
- // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
- // }
- // else
- // {
- // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
- // //760 EUR(7600.00 CNY)
- // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
- // }
- //}
- //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
- string original = string.Empty;
- if (hotelCurrncyCode.Equals("CNY"))
- {
- OriginalCurrPay = CurrPayStr;
- _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
- }
- else
- {
- OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
- //760 EUR(7600.00 CNY)
- _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
- }
- /*
- * 剩余尾款
- */
- decimal BalanceStr = 0;
- if (CurrPayStr != 0)
- {
- if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
- BalanceStr = 0;
- else
- BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
- }
- _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
- /*
- * Bus名称
- */
- _detail.BusName = "待增加";
- /*
- *费用所属
- */
- switch (entity.CTable)
- {
- case 76://酒店预订
- Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (hotelReservations != null)
- {
- DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
- checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
- int hotel_days = (int)(checkOut - checkIn).TotalDays;
- string roomFeeStr = "", roomFeestr1 = "";
- //是否比较房型价格
- //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
- //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
- roomFeeStr += $"<br/>";
- var roomTotal = 0.00M;
- if (hotelReservations.SingleRoomPrice > 0)
- {
- var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
- //__isSingle = true;
- roomTotal += fee;
- }
- if (hotelReservations.DoubleRoomPrice > 0)
- {
- var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
- // __isDouble = true;
- roomTotal += fee;
- }
- if (hotelReservations.SuiteRoomPrice > 0)
- {
- var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
- //__isSuite = true;
- roomTotal += fee;
- }
- if (hotelReservations.OtherRoomPrice > 0)
- {
- var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
- //__isOther = true;
- roomTotal += fee;
- }
- if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
- else roomFeeStr += " 0.00 * 0";
- decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
- string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
- string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
- var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
- /*
- * 费用类型
- * 1:房费
- * 2:早餐
- * 3:地税
- * 4:城市税
- * </summary>
- */
- //地税
- var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
- if (governmentRentData != null)
- {
- governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
- governmentRentFee = governmentRentData.Price;
- var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
- if (governmentRentCurrData != null)
- {
- governmentRentCode = governmentRentCurrData.Name;
- governmentRentName = $"({governmentRentCurrData.Remark})";
- }
- }
- //城市税
- var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
- if (cityTaxData != null)
- {
- cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
- cityTaxFee = cityTaxData.Price;
- var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
- if (cityTaxCurrData != null)
- {
- cityTaxCode = cityTaxCurrData.Name;
- cityTaxName = $"({cityTaxCurrData.Remark})";
- }
- }
- //酒店早餐
- var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
- if (breakfastData != null)
- {
- breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
- breakfastFee = breakfastData.Price;
- var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
- if (breakfastCurrData != null)
- {
- breakfastCode = breakfastCurrData.Name;
- breakfastName = $"({breakfastCurrData.Remark})";
- }
- }
- //房间费用
- var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
- if (roomData != null)
- {
- _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
- if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
- else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
- roomBool = roomData.IsOppay == 1 ? "是" : "否";
- roomFee = roomData.Price;
- var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
- if (roomCurrData != null)
- {
- roomCode = roomCurrData.Name;
- roomName = $"({roomCurrData.Remark})";
- }
- }
- string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
- string hotelCostStr = "";
- decimal hotelCsotTotal = 0.00M;
- if (groupCost != null)
- {
- if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
- hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
- }
- if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
- var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
- string hotelCost_day = "";
- var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
- foreach (var item in hotelCostDetails1)
- {
- hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
- hotelCost_day += @$"{item.First()?.Date ?? "-"}";
- if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
- //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
- if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
- //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
- if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
- //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
- if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
- //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
- hotelCost_day += @$"<br/>";
- }
- string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
- if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
- if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
- if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
- string hotelCostTotalStr = "";// $" 成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
- _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
- $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
- $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
- $"房间说明: {hotelReservations.Remark} <br/>" +
- $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
- $"{hotelBreakfastStr}" +
- $"{hotelGovernmentRentStr}" +
- $"{hotelCityTaxStr}";
- _detail.PriceNameContent = hotelReservations.HotelName;
- }
- break;
- case 79://车/导游地接
- Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (touristGuideGroundReservations != null)
- {
- if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
- {
- _detail.BusName = touristGuideGroundReservations.BusName;
- }
- _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
- //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
- //if (isInt)
- //{
- // var cityInfo = cityData.Find(it => it.Id == cityId);
- // if (cityInfo != null)
- // {
- // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
- // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
- // if (carFeeItem != null)
- // {
- // nameContent += $@"({carFeeItem.Name})";
- // }
- // _detail.PriceNameContent = nameContent;
- // }
- //}
- //else
- //{
- // _detail.PriceNameContent = touristGuideGroundReservations.Area;
- //}
- var touristGuideGroundReservationsContents =
- _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
- string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
- foreach (var item in touristGuideGroundReservationsContents)
- {
- string typeName = "Unknown";
- string carCurrencyCode = "Unknown";
- string carCurrencyName = "Unknown";
- var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
- if (carTypeData != null) typeName = carTypeData.Name;
- var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
- if (currencyData != null)
- {
- carCurrencyCode = currencyData.Name;
- carCurrencyName = currencyData.Remark;
- }
- //op、成本 币种是否一致
- bool IsCurrencyAgreement = false;
- if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
- string opCostStr = string.Empty;
- decimal opCostTypePrice = 0.00M;
- #region 处理成本各项费用
- var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
- var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
- if (opCost.Count > 0)
- {
- switch (item.SId)
- {
- case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
- //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
- case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
- case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
- case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
- case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
- case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
- case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
- //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
- //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
- case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
- case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
- case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
- case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
- case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
- case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
- case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
- case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
- case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
- case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
- //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
- }
- opCostStr = $" / 成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
- if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
- }
- #endregion
- string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
- if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
- priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
- $"{opTypeStr} {opCostStr}<br/>" +
- $"明细:{item.PriceContent ?? "-"}<br/>" +
- $"备注:{item.Remark ?? "-"}<br/><br/>";
- }
- _detail.PriceMsgContent = priceMsg;
- }
- break;
- case 80: //签证
- Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (visaInfo != null)
- {
- string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
- _detail.PriceNameContent = visaInfo.VisaDescription;
- _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
- }
- break;
- case 81: //邀请/公务活动
- Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (_ioa != null)
- {
- string inviteCurrName = "Unknown", //邀请费用币种 Name
- inviteCurrCode = "Unknown", //邀请费用币种 Code
- sendCurrName = "Unknown", //快递费用币种 Name
- sendCurrCode = "Unknown", //快递费用币种 Code
- eventsCurrName = "Unknown", //公务活动费币种 Name
- eventsCurrCode = "Unknown", //公务活动费币种 Code
- translateCurrName = "Unknown", //公务翻译费 Name
- translateCurrCode = "Unknown"; //公务翻译费 Code
- #region 处理费用币种
- var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
- if (inviteCurrData != null)
- {
- inviteCurrName = inviteCurrData.Remark;
- inviteCurrCode = inviteCurrData.Name;
- }
- var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
- if (sendCurrData != null)
- {
- sendCurrName = sendCurrData.Remark;
- sendCurrCode = sendCurrData.Name;
- }
- var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
- if (eventsCurrData != null)
- {
- eventsCurrName = eventsCurrData.Remark;
- eventsCurrCode = eventsCurrData.Name;
- }
- var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
- if (translateCurrData != null)
- {
- translateCurrName = translateCurrData.Remark;
- translateCurrCode = translateCurrData.Name;
- }
- #endregion
- _detail.PriceNameContent = _ioa.InviterArea;
- _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
- $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
- $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
- $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
- $@"备注:" + _ioa.Remark + "<br/>";
- }
- break;
- case 82: //团组客户保险
- Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
- if (customers != null)
- {
- _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
- _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
- }
- break;
- case 85: //机票预订
- Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (jpRes != null)
- {
- string FlightsDescription = jpRes.FlightsDescription;
- string PriceDescription = jpRes.PriceDescription;
- _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
- _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
- }
- break;
- case 98://其他款项
- Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (gdpRes != null)
- {
- _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
- _detail.PriceNameContent = gdpRes.PriceName;
- }
- break;
- case 285://收款退还
- Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (refundAndOtherMoney != null)
- {
- _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
- _detail.PriceNameContent = refundAndOtherMoney.PriceName;
- }
- break;
- case 751://酒店早餐
- break;
- case 1015://超支费用
- Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (groupExtraCost != null)
- {
- _detail.PriceNameContent = groupExtraCost.PriceName;
- _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
- }
- break;
- default:
- break;
- }
- /*
- * 申请人
- */
- string operatorName = " - ";
- var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
- if (_opUser != null)
- {
- operatorName = _opUser.CnName;
- }
- _detail.OperatorName = operatorName;
- /*
- * 审核人
- */
- string auditOperatorName = "Unknown";
- if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
- else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
- else
- {
- var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
- if (_adUser != null)
- {
- auditOperatorName = _adUser.CnName;
- }
- }
- _detail.AuditOperatorName = auditOperatorName;
- /*
- * 超预算比例
- */
- string overBudgetStr = "";
- if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
- else if (entity.ExceedBudget == 0)
- {
- if (entity.CTable == 76 || entity.CTable == 79)
- {
- if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
- else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
- }
- else
- {
- overBudgetStr = "未超预算";
- }
- }
- else overBudgetStr = entity.ExceedBudget.ToString("P");
- _detail.OverBudget = overBudgetStr;
- decimal auditFee = 0.00M; //已审核金额 人名币
- decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
- decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
- decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
- if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
- {
- auditedFeeOriginal = entity.PayMoney;
- auditFee = CurrPayStr;
- }
- else if (entity.IsAuditGM == 0)
- {
- unAuditFeeCNY = CurrPayStr;
- unAuditFeeOriginal = OriginalCurrPay;
- OriginalCurrPay = 0.00M;
- }
- /*
- * 费用总计
- */
- ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
- {
- CurrencyId = entity.PaymentCurrency,
- CurrencyName = PaymentCurrency_WaitPay,
- AmountPayable = entity.PayMoney,
- ThisPayment = OriginalCurrPay,
- BalancePayment = BalanceStr,
- AuditedFunds = auditFee,
- AuditedFundsOriginal = auditedFeeOriginal,
- UnAuditFundsCNY = unAuditFeeCNY,
- UnAuditFundsOriginal = unAuditFeeOriginal
- });
- _detail.IsAuditGM = entity.IsAuditGM;
- detailList.Add(_detail);
- }
- #endregion
- _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
- /*
- * 下方描述处理
- */
- var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
- var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
- if (ccpCurrencyPrice != null)
- {
- int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
- nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
- }
- else
- {
- nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
- }
- string amountPayableStr = string.Format(@"应付款总金额: ");
- string thisPaymentStr = string.Format(@"此次付款总金额: ");
- string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
- string auditedFundsStr = string.Format(@"已审费用总额: ");
- string unAuditedFundsStr = string.Format(@"未审费用总额: ");
- foreach (var item in nonDuplicat)
- {
- var currencyName = item.CurrencyName;
- var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
- if (strs.Count > 0)
- {
- decimal amountPayable = strs.Sum(it => it.AmountPayable);
- decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
- decimal balancePayment = strs.Sum(it => it.BalancePayment);
- amountPayableStr += string.Format(@"{0}{1} |", amountPayable.ToString("#0.00"), currencyName);
- //单独处理此次付款金额
- thisPaymentStr += string.Format(@"{0}{1} |", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
- balancePaymentStr += string.Format(@"{0}{1} |", balancePayment.ToString("#0.00"), currencyName);
- //单独处理已审核费用
- //if (item.CurrencyId == 836) //人民币
- //{
- // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
- // auditedFundsStr += string.Format(@"{0}{1} |", auditedFunds.ToString("#0.00"), currencyName);
- //}
- //else
- //{
- // auditedFundsStr += string.Format(@"{0}{1} |", strs.Sum(x => x.AmountPayable), currencyName);
- //}
- if (currencyName.Equals("CNY"))
- {
- //已审核费用
- auditedFundsStr += string.Format(@"{0}{1} |", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
- //未审核费用
- unAuditedFundsStr += string.Format(@"{0}{1} |", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
- }
- else
- {
- //已审核费用
- auditedFundsStr += string.Format(@"{0}{1}({2}CNY) |", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
- //未审核费用
- unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY) |", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
- }
- }
- }
- _view.TotalStr1 = amountPayableStr[..^1];
- _view.TotalStr2 = thisPaymentStr[..^1];
- _view.TotalStr3 = balancePaymentStr[..^1];
- _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
- //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
- var _view1 = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _view
- };
- return Ok(JsonView(_view1));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 费用审核
- /// 修改团组费用审核状态
- /// </summary>
- /// <param name="_dto">参数Json字符串</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- #endregion
- #region 页面操作权限验证
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
- #endregion
- List<string> idList = _dto.CreditIdStr.Split(',').ToList();
- Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
- DateTime dtNow = DateTime.Now;
- _groupRepository.BeginTran();
- int rst = 0;
- var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
- var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
- var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
- var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
- List<dynamic> msgDatas = new List<dynamic>();
- Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
- foreach (var item in idList)
- {
- int CreditId = int.Parse(item);
- var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
- .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
- .SetColumns(it => it.AuditGMOperate == _dto.UserId)
- .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
- .Where(s => s.Id == CreditId)
- .ExecuteCommandAsync();
- if (result < 1)
- {
- rst = -1;
- _groupRepository.RollbackTran();
- return Ok(JsonView(false, "操作失败并回滚!"));
- }
- var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
- if (creditData != null)
- {
- #region 应用通知配置
- try
- {
- dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
- }
- catch (Exception ex)
- {
- }
- #endregion
- string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
- string groupNameStr = string.Empty;
- var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
- if (groupData != null) groupNameStr = groupData.TeamName;
- string creditTypeStr = string.Empty;
- var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
- if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
- string creditCurrency = string.Empty;
- var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
- if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
- if (creditCurrency.Equals("CNY"))
- {
- creditData.DayRate = 1.0000M;
- }
- if (creditData.PayPercentage == 0.00M)
- {
- creditData.PayPercentage = 100M;
- }
- decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
- string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
- string msgContent = "";
- if (creditCurrency.Equals("CNY"))
- {
- msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
- }
- else
- {
- msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
- }
- msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
- }
- }
- if (rst == 0)
- {
- _groupRepository.CommitTran();
- foreach (var item in msgDatas)
- {
- //发送消息
- GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
- }
- #region 应用推送
- try
- {
- foreach (var ccpId in dic_ccp_user.Keys)
- {
- List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
- await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
- }
- }
- catch (Exception)
- {
- }
- #endregion
- return Ok(JsonView(true, "操作成功!"));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- #endregion
- #region 机票费用录入
- /// <summary>
- /// 机票录入当前登录人可操作团组
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
- /// <summary>
- /// 机票费用录入列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.AirTicketResList(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
-
- /// <summary>
- /// 根据id查询费用录入信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
- {
- Result groupData = await _airTicketResRep.AirTicketResById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
-
- /// <summary>
- /// 机票费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
- {
- Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- #region 应用推送
- try
- {
- int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- string content = "";
- var diId = dto.AirTicketResOpData.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
- await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 根据舱位类型查询接团客户名单信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
- {
- try
- {
- List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
- if (crm_Groups.Count != 0)
- {
- List<dynamic> Customer = new List<dynamic>();
- foreach (var item in crm_Groups)
- {
- var data = new
- {
- Id = item.Id,
- Pinyin = item.Pinyin,
- Name = item.LastName + item.FirstName
- };
- Customer.Add(data);
- }
- return Ok(JsonView(true, "查询成功!", Customer));
- }
- return Ok(JsonView(true, "暂无数据", crm_Groups));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 根据团号获取客户信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
- {
- var jw = JsonView(false);
- if (dto.DIID < 1)
- {
- jw.Msg += "请输入正确的diid";
- return Ok(jw);
- }
- var arr = getSimplClientList(dto.DIID);
- jw = JsonView(true, "获取成功!", arr);
- return Ok(jw);
- }
- private List<SimplClientInfo> getSimplClientList(int diId)
- {
- 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);
- List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
- foreach (var item in arr)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- return arr;
- }
- private string getClientNameStr(List<SimplClientInfo> list, string origin)
- {
- string result = origin;
- if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
- {
- string[] temparr = origin.Split(',');
- string fistrStr = temparr[0];
- int count = temparr.Count();
- int tempId;
- bool success = int.TryParse(fistrStr, out tempId);
- if (success)
- {
- SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
- if (tempInfo != null)
- {
- if (count > 1)
- {
- result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
- }
- else
- {
- result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
- }
- }
- }
- }
- return result;
- }
- private string getClientNameStr1(List<SimplClientInfo> list, string origin)
- {
- string result = origin;
- if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
- {
- string[] temparr = origin.Split(',');
- result = "";
- foreach (var item in temparr)
- {
- int tempId;
- bool success = int.TryParse(item, out tempId);
- if (success)
- {
- SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
- if (tempInfo != null)
- {
- result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
- }
- }
- }
- }
- if (result.Length > 0) result = result.Substring(0, result.Length - 1);
- return result;
- }
- /// <summary>
- /// 机票费用录入,删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
- {
- try
- {
- var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
- if (res)
- {
- var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- return Ok(JsonView(true, "删除成功!"));
- }
- return Ok(JsonView(false, "删除失败!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
- /// <summary>
- /// 导出机票录入报表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
- }
- else
- {
- List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
- if (AirTicketReservations.Count != 0)
- {
- Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
- Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
- string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
- string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
- decimal countCost = 0;
- foreach (var item in AirTicketReservations)
- {
- #region 处理客人姓名
- string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
- item.ClientName = clientNames;
- #endregion
- if (item.BankType == "其他")
- {
- item.BankNo = "--";
- }
- else
- {
- if (!string.IsNullOrEmpty(item.BankType))
- {
- item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
- }
- }
- item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
- item.Price = System.Decimal.Round(item.Price, 2);
- countCost += Convert.ToDecimal(item.Price);
- }
- designer.SetDataSource("Export", AirTicketReservations);
- designer.SetDataSource("ExportDiCode", diCode);
- designer.SetDataSource("ExportDiName", diName);
- designer.SetDataSource("ExportOpUserName", _Users.CnName);
- designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
- designer.Process();
- string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
- designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
- string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
- return Ok(JsonView(true, "成功", url = rst));
- }
- else
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
- throw;
- }
- }
- Dictionary<string, string> transDic = new Dictionary<string, string>();
- /// <summary>
- /// 行程单导出
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
- }
- else
- {
- List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
- if (dto.Language == "CN")
- {
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
- DocumentBuilder builder = new DocumentBuilder(doc);
- int tableIndex = 0;//表格索引
- //得到文档中的第一个表格
- Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
- foreach (var item in _AirTicketReservations)
- {
- #region 处理固定数据
- string[] FlightsCode = item.FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string name = "";
- foreach (string clientName in nameArray)
- {
- if (!name.Contains(clientName))
- {
- name += clientName + ",";
- }
- }
- if (!string.IsNullOrWhiteSpace(name))
- {
- table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- #endregion
- #region 循环数据处理
- List<AirInfo> airs = new List<AirInfo>();
- string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
- DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
- for (int i = 0; i < FlightsCode.Length; i++)
- {
- AirInfo air = new AirInfo();
- string[] tempstr = DayArray[i]
- .Replace("\r\n", string.Empty)
- .Replace("\\r\\n", string.Empty)
- .TrimStart().TrimEnd()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
- string starCity = "";
- if (star_Three != null)
- {
- starCity = star_Three.AirPort;
- }
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
- string EndCity = "";
- if (End_Three != null)
- {
- EndCity = End_Three.AirPort;
- }
- air.Destination = starCity + "/" + EndCity;
- air.Flight = FlightsCode[i];
- air.SeatingClass = item.CTypeName;
- string dateTime = tempstr[2];
- string DateTemp = dateTime.Substring(2, 5).ToUpper();
- air.FlightDate = DateTemp;
- air.DepartureTime = tempstr[5];
- air.LandingTime = tempstr[6];
- air.ValidityPeriod = DateTemp + "/" + DateTemp;
- air.TicketStatus = "--";
- air.Luggage = "--";
- air.DepartureTerminal = "--";
- air.LandingTerminal = "--";
- airs.Add(air);
- }
- int row = 13;
- for (int i = 0; i < airs.Count; i++)
- {
- if (airs.Count > 2)
- {
- for (int j = 0; j < airs.Count - 2; j++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.Add(CopyRow);
- }
- }
- PropertyInfo[] properties = airs[i].GetType().GetProperties();
- int index = 0;
- foreach (PropertyInfo property in properties)
- {
- string value = property.GetValue(airs[i]).ToString();
- Cell ishcel0 = table.Rows[row].Cells[index];
- Paragraph p = new Paragraph(doc);
- string s = value;
- p.AppendChild(new Run(doc, s));
- p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
- ishcel0.AppendChild(p);
- ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
- index++;
- }
- row++;
- }
- #endregion
- Paragraph lastParagraph = new Paragraph(doc);
- //第一个表格末尾加段落
- table.ParentNode.InsertAfter(lastParagraph, table);
- //复制第一个表格
- Table cloneTable = (Table)table.Clone(true);
- //在文档末尾段落后面加入复制的表格
- table.ParentNode.InsertAfter(cloneTable, lastParagraph);
- if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
- {
- int rownewsIndex = 13;
- for (int i = 0; i < 2; i++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.RemoveAt(13);
- table.Rows.Add(CopyRow);
- rownewsIndex++;
- }
- }
- else
- {
- table.Rows.RemoveAt(12);
- }
- cloneTable.Rows.RemoveAt(12);
- }
- if (_AirTicketReservations.Count != 0)
- {
- string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string name = "";
- foreach (string clientName in nameArray)
- {
- if (!name.Contains(clientName))
- {
- name += clientName + ",";
- }
- }
- if (!string.IsNullOrWhiteSpace(name))
- {
- table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- }
- doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
- //保存合并后的文档
- string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
- string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
- doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
- return Ok(JsonView(true, "成功!", rst));
- }
- else
- {
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
- DocumentBuilder builder = new DocumentBuilder(doc);
- int tableIndex = 0;//表格索引
- //得到文档中的第一个表格
- Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
- List<string> texts = new List<string>();
- foreach (var item in _AirTicketReservations)
- {
- string[] FlightsCode = item.FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- if (!transDic.ContainsKey(_AirCompany.CnName))
- {
- transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
- }
- }
- else
- {
- if (!transDic.ContainsKey("--"))
- {
- transDic.Add("--", "--");
- }
- }
- }
- string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string name = "";
- foreach (string clientName in nameArray)
- {
- name += clientName + ",";
- }
- if (!texts.Contains(name))
- {
- texts.Add(name);
- }
- List<AirInfo> airs = new List<AirInfo>();
- string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
- DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
- for (int i = 0; i < FlightsCode.Length; i++)
- {
- AirInfo air = new AirInfo();
- string[] tempstr = DayArray[i]
- .Replace("\r\n", string.Empty)
- .Replace("\\r\\n", string.Empty)
- .TrimStart().TrimEnd()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
- if (star_Three != null)
- {
- if (!transDic.ContainsKey(star_Three.AirPort))
- {
- transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
- }
- }
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
- if (End_Three != null)
- {
- if (!transDic.ContainsKey(End_Three.AirPort))
- {
- transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
- }
- }
- if (!texts.Contains(item.CTypeName))
- {
- texts.Add(item.CTypeName);
- }
- }
- }
- List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
- if (transData.Count > 0)
- {
- foreach (TranslateResult item in transData)
- {
- if (!transDic.ContainsKey(item.Query))
- {
- transDic.Add(item.Query, item.Translation);
- }
- }
- }
- foreach (var item in _AirTicketReservations)
- {
- #region 处理固定数据
- string[] FlightsCode = item.FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["AirlineCompany"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string names = "";
- foreach (string clientName in nameArray)
- {
- names += clientName + ",";
- }
- if (!string.IsNullOrWhiteSpace(names))
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["ClientName"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- #endregion
- #region 循环数据处理
- List<AirInfo> airs = new List<AirInfo>();
- string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
- DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
- for (int i = 0; i < FlightsCode.Length; i++)
- {
- AirInfo air = new AirInfo();
- string[] tempstr = DayArray[i]
- .Replace("\r\n", string.Empty)
- .Replace("\\r\\n", string.Empty)
- .TrimStart().TrimEnd()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
- string starCity = "";
- if (star_Three != null)
- {
- string str2 = "--";
- string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult2))
- {
- str2 = translateResult2;
- str2 = _airTicketResRep.Processing(str2);
- }
- starCity = str2;
- }
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
- string EndCity = "";
- if (End_Three != null)
- {
- string str1 = "--";
- string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult1))
- {
- str1 = translateResult1;
- str1 = _airTicketResRep.Processing(str1);
- }
- EndCity = str1;
- }
- air.Destination = starCity + "/" + EndCity;
- air.Flight = FlightsCode[i];
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- air.SeatingClass = str;
- string dateTime = tempstr[2];
- string DateTemp = dateTime.Substring(2, 5).ToUpper();
- air.FlightDate = DateTemp;
- air.DepartureTime = tempstr[5];
- air.LandingTime = tempstr[6];
- air.ValidityPeriod = DateTemp + "/" + DateTemp;
- air.TicketStatus = "--";
- air.Luggage = "--";
- air.DepartureTerminal = "--";
- air.LandingTerminal = "--";
- airs.Add(air);
- }
- int row = 13;
- for (int i = 0; i < airs.Count; i++)
- {
- if (airs.Count > 2)
- {
- for (int j = 0; j < airs.Count - 2; j++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.Add(CopyRow);
- }
- }
- PropertyInfo[] properties = airs[i].GetType().GetProperties();
- int index = 0;
- foreach (PropertyInfo property in properties)
- {
- string value = property.GetValue(airs[i]).ToString();
- Cell ishcel0 = table.Rows[row].Cells[index];
- Paragraph p = new Paragraph(doc);
- string s = value;
- p.AppendChild(new Run(doc, s));
- p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
- ishcel0.AppendChild(p);
- ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
- //ishcel0.CellFormat.VerticalAlignment=
- index++;
- }
- row++;
- }
- #endregion
- Paragraph lastParagraph = new Paragraph(doc);
- //第一个表格末尾加段落
- table.ParentNode.InsertAfter(lastParagraph, table);
- //复制第一个表格
- Table cloneTable = (Table)table.Clone(true);
- //在文档末尾段落后面加入复制的表格
- table.ParentNode.InsertAfter(cloneTable, lastParagraph);
- if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
- {
- int rownewsIndex = 13;
- for (int i = 0; i < 2; i++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.RemoveAt(13);
- table.Rows.Add(CopyRow);
- rownewsIndex++;
- }
- }
- else
- {
- table.Rows.RemoveAt(12);
- }
- cloneTable.Rows.RemoveAt(12);
- }
- if (_AirTicketReservations.Count != 0)
- {
- string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["AirlineCompany"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string names = "";
- foreach (string clientName in nameArray)
- {
- names += clientName + ",";
- }
- if (!string.IsNullOrWhiteSpace(names))
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["ClientName"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- }
- doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
- //保存合并后的文档
- string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
- string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
- doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
- return Ok(JsonView(true, "成功!", rst));
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
- throw;
- }
- }
- #endregion
- #region 团组增减款项 --> 其他款项
- /// <summary>
- /// 团组增减款项下拉框绑定
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
- if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
- #endregion
- return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
- }
- /// <summary>
- /// 根据团组Id查询团组增减款项
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
- if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
- #endregion
- return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
- }
- /// <summary>
- /// 团组增减款项操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
- {
- JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
- if (groupData.Code != 200)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- #region 应用推送
- //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
- //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
- int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
- int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
- //自动审核
- var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- string content = "";
- var diId = dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
- #endregion
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 团组增减款项操作 删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
- {
- if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
- if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
- var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
- if (res.Code == 0)
- {
- return Ok(JsonView(true, "删除成功!"));
- }
- return Ok(JsonView(false, "删除失败!"));
- }
- /// <summary>
- /// 根据团组增减款项Id查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
- {
- if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
- return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
- }
- /// <summary>
- /// 查询供应商名称
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
- {
- var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
- .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
- ?? new List<Grp_DecreasePayments>();
- dbResult = dbResult.Distinct(new
- ProductComparer()).ToList();
- var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
- {
- x.Id,
- x.SupplierAddress,
- x.SupplierArea,
- x.SupplierContact,
- x.SupplierContactNumber,
- x.SupplierEmail,
- x.SupplierName,
- x.SupplierSocialAccount,
- x.SupplierTypeId,
- }).ToList());
- return Ok(jw);
- }
- /// <summary>
- /// 团组增减款项 OTA匹配
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
- {
- if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
- string fileName = file.FileName;
- if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
- {
- return Ok(JsonView(false, "请上传Excel文件!"));
- }
- //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
- var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
- if (!Directory.Exists(path))
- {
- Directory.CreateDirectory(path);
- }
- var filePath = @$"{path}/{fileName}";
- //保存文件
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
- //读取ExcelFile
- DataTable dt = ConvertExcelToDataTable(filePath);
- if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
- dt.TableName = "TB";
- //修改table列名
- dt.Columns[0].ColumnName = "OrderNo"; // 订单号
- dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
- dt.Columns[2].ColumnName = "PackageName"; // 套餐名
- dt.Columns[3].ColumnName = "IsPay"; // 是否支付
- dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
- dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
- dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
- dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
- dt.Columns[8].ColumnName = "UseTime"; // 使用时间
- dt.Columns[9].ColumnName = "Quantity"; // 台数
- dt.Columns[10].ColumnName = "Days"; // 租赁天数
- dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
- dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
- dt.Columns[13].ColumnName = "GroupName"; // 团组名称
- dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
- var otaOrderNos = new List<string>();
- foreach (DataRow item in dt.Rows)
- {
- otaOrderNos.Add(item["OTAOrderNo"].ToString());
- }
- var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
- .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
- .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
- .Select((dp, di) => new
- {
- dp.PriceName,
- dp.OTAOrderNo,
- dp.FeeTotal,
- di.TeamName,
- })
- .ToListAsync();
- foreach (DataRow item in dt.Rows)
- {
- var otaOrderNo = item["OTAOrderNo"].ToString();
- var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
- if (oaData == null) continue;
- item["GroupName"] = oaData.TeamName;
- item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
- }
- string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- Dictionary<string, object> pairs = new Dictionary<string, object>();
- List<DataTable> datas = new List<DataTable>();
- datas.Add(dt);
- url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
- return Ok(JsonView(true, "操作成功", new { url = url }));
- }
- #region
- private DataTable ConvertExcelToDataTable(string excelFilePath)
- {
- // 创建Workbook对象
- Workbook workbook = new Workbook(excelFilePath);
- // 获取第一个工作表
- Worksheet worksheet = workbook.Worksheets[0];
- // 将工作表转换为DataTable
- DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
- return dataTable;
- }
- #endregion
- #endregion
- #region 文件上传、删除
- /// <summary>
- /// region 文件上传 可以带参数
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UploadProject(IFormFile file)
- {
- //var TypeName = Request.Headers["TypeName"].ToString();
- //if (file == null) return Ok(JsonView(false, "文件不存在!"));
- //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- ////文件名称
- //string projectFileName = file.FileName;
- ////上传的文件的路径
- //string filePath = $"{fileDir}/{projectFileName}";
- //if (TypeName == "A")//A代表团组增减款项
- //{
- // filePath = fileDir + $@"\团组增减款项相关文件";
- // if (!Directory.Exists(filePath))
- // {
- // Directory.CreateDirectory(filePath);
- // }
- // //上传的文件的路径
- // filePath += $@"\{projectFileName}";
- //}
- //else if (TypeName == "B")//B代表商邀相关文件
- //{
- // //上传的文件的路径
- // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
- // if (!Directory.Exists(filePath))
- // {
- // Directory.CreateDirectory(filePath);
- // }
- // //上传的文件的路径
- // filePath = $@"\{projectFileName}";
- //}
- //try
- //{
- // using (FileStream fs = System.IO.File.Create(filePath))
- // {
- // file.CopyTo(fs);
- // fs.Flush();
- // }
- //}
- //catch (Exception ex)
- //{
- // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
- //}
- //return Ok(JsonView(true, "上传成功!", projectFileName));
- try
- {
- var TypeName = Request.Headers["TypeName"].ToString();
- if (file != null)
- {
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- //文件名称
- string projectFileName = file.FileName;
- //上传的文件的路径
- string filePath = $"{fileDir}/{projectFileName}";
- if (TypeName == "A")//A代表团组增减款项
- {
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
- }
- else if (TypeName == "B")//B代表商邀相关文件
- {
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
- }
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- return Ok(JsonView(true, "上传成功!", projectFileName));
- }
- else
- {
- return Ok(JsonView(false, "上传失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- }
- }
- /// <summary>
- /// 删除指定文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelFile(DelFileDto dto)
- {
- try
- {
- var TypeName = Request.Headers["TypeName"].ToString();
- if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
- string filePath = "";
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- // 返回与指定虚拟路径相对应的物理路径即绝对路径
- int id = 0;
- if (TypeName == "A")
- {
- filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
- // 删除该文件
- System.IO.File.Delete(filePath);
- id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
- .Where(a => a.Id == dto.Id)
- .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
- .ExecuteCommandAsync();
- }
- else if (TypeName == "B")
- {
- filePath = fileDir + "/商邀相关文件/" + dto.fileName;
- // 删除该文件
- System.IO.File.Delete(filePath);
- var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
- if (info != null)
- {
- string[] files = new string[] { };
- if (!string.IsNullOrEmpty(info.Attachment))
- {
- try
- {
- files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
- }
- catch (Exception)
- {
- files = new List<string>() { info.Attachment }.ToArray();
- }
- }
- if (files.Length > 0)
- {
- var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
- string filePath2 = string.Empty;
- if (files1.Length > 0)
- {
- filePath2 = JsonConvert.SerializeObject(files1);
- }
- id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
- .Where(a => a.Id == dto.Id)
- .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
- .ExecuteCommandAsync();
- }
- }
- }
- if (id != 0)
- {
- return Ok(JsonView(true, "成功!"));
- }
- else
- {
- return Ok(JsonView(false, "失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 文件上传多个文件 可以带参数
- /// </summary>
- /// <param name="files"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UploadProjects(IFormFile[] files)
- {
- try
- {
- var TypeName = Request.Headers["TypeName"].ToString();
- if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
- if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- var filePahts = new List<string>();
- foreach (var file in files)
- {
- //文件名称
- string projectFileName = file.FileName;
- //上传的文件的路径
- string filePath = $"{fileDir}/{projectFileName}";
- if (TypeName == "A")//A代表团组增减款项
- {
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
- }
- else if (TypeName == "B")//B代表商邀相关文件
- {
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
- }
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- filePahts.Add(projectFileName);
- }
- return Ok(JsonView(true, "上传成功!", filePahts));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- }
- }
- #endregion
- #region 商邀费用录入
- /// <summary>
- /// 根据团组Id查询商邀费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
- {
- Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 商邀费用列表
- /// 下载文件
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
- {
- if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
- var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
- if (info == null) return Ok(JsonView(false, "数据不存在!"));
- if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
- var filePaths = new List<string>();
- var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
- try
- {
- filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
- }
- catch (Exception ex)
- {
- filePaths.Add(info.Attachment);
- }
- if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
- for (int i = 0; i < filePaths.Count; i++)
- {
- filePaths[i] = $"{filePathBase}{filePaths[i]}";
- }
- var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
- var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
- using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
- {
- using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
- {
- foreach (string filePath in filePaths)
- {
- if (System.IO.File.Exists(filePath))
- {
- // 获取文件名
- string fileName = Path.GetFileName(filePath);
- // 将文件添加到ZIP归档中
- zipArchive.CreateEntryFromFile(filePath, fileName);
- }
- }
- }
- }
- return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
- }
- /// <summary>
- /// 商邀费用 Info Page 基础数据源
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
- {
- try
- {
- Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, "操作成功", groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 根据商邀费用ID查询C表和商邀费用数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
- {
- try
- {
- Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 商邀费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
- {
- Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- #region 应用推送
- try
- {
- int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- string content = "";
- var diId = dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
- await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 商邀删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
- {
- try
- {
- _sqlSugar.BeginTran();
- var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
- .SetColumns(it => new Grp_InvitationOfficialActivities()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .Where(it => it.Id == dto.Id)
- .ExecuteCommand();
- if (res1 > 0)
- {
- int _diId = 0;
- var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
- if (_ioaInfo != null)
- {
- _diId = _ioaInfo.DiId;
- }
- var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
- .SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
- .ExecuteCommand();
- if (res2 > 0)
- {
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "删除成功!"));
- }
- }
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "删除失败"));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- }
- #endregion
- #region 票据上传
- /// <summary>
- /// 团组模块文件上传
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
- {
- var jw = JsonView(false);
- long M = 1024 * 1024;
- if (dto.Files == null || dto.Files.Count == 0)
- {
- jw.Msg = "无文件信息!";
- return Ok(jw);
- }
- if (dto.Files.Sum(x => x.Length) > 20 * M)
- {
- jw.Msg = "文件大小超过20M!";
- return Ok(jw);
- }
- //var nameSp = dto.File.FileName.Split(".");
- //if (nameSp.Length < 2)
- //{
- // jw.Msg = "拓展名称有误!";
- // return Ok(jw);
- //}
- //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
- //if (!existsName.Contains(nameSp[1].ToUpper()))
- //{
- // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
- // return Ok(jw);
- //}
- var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
- if (Ctable == null)
- {
- jw.Msg = "Ctable指向有误!";
- return Ok(jw);
- }
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (groupInfo == null)
- {
- jw.Msg = "团组信息不存在!";
- return Ok(jw);
- }
- Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
- var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
- try
- {
- if (!Directory.Exists(fileBase))
- {
- Directory.CreateDirectory(fileBase);
- }
- List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
- foreach (var fileStream in dto.Files)
- {
- var saveFilePath = fileBase + "\\" + fileStream.FileName;
- Grp_GroupModelFile file = new Grp_GroupModelFile()
- {
- Cid = dto.Cid,
- CreateTime = DateTime.Now,
- CreateUserId = dto.Userid,
- Ctable = dto.Ctable,
- Diid = dto.Diid,
- IsDel = 0,
- FilePath = saveFilePath,
- FileName = fileStream.FileName
- };
- using (FileStream fs = System.IO.File.Create(saveFilePath))
- {
- fileStream.CopyTo(fs);
- fs.Flush();
- }
- saveArr.Add(file);
- }
- var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
- //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
- jw = JsonView(true, "保存成功!", new
- {
- count = addResult,
- filesName = saveArr.Select(x => x.FileName)
- });
- }
- catch (Exception ex)
- {
- jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
- {
- count = 0,
- filesName = new string[0],
- });
- }
- return Ok(jw);
- }
- /// <summary>
- /// 查询各模块已保存文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
- {
- var expression = Expressionable.Create<Grp_GroupModelFile>()
- .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
- var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
- if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
- {
- expression = Expressionable.Create<Grp_GroupModelFile>()
- .And(x => visaIds.Contains(x.CreateUserId));
- }
- var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
- .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
- .Where(expression.ToExpression())
- .ToList();
- //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
- return Ok(JsonView(true, "success", dbQuery.Select(x => new
- {
- x.FileName,
- x.Id,
- Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
- CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
- })));
- }
- /// <summary>
- /// 下载该团组下的所有文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ExportGroupZip(ExportGroupZipDto dto)
- {
- var jw = JsonView(false);
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
- if (groupInfo == null)
- {
- jw.Msg = "团组信息不存在!";
- return Ok(jw);
- }
- var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
- var isModule = Convert.ToBoolean(dto.isModule);
- Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
- IOOperatorHelper io = new IOOperatorHelper();
- if (isModule)
- {
- var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
- foreach (var moduleArr in moduleGroup)
- {
- var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
- key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
- foreach (var item in moduleArr)
- {
- if (System.IO.File.Exists(item.FilePath))
- {
- using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
- {
- byte[] bytes = new byte[fileStream.Length];
- fileStream.Read(bytes, 0, bytes.Length);
- fileStream.Close();
- Stream stream = new MemoryStream(bytes);
- chiZips.Add(item.FileName, stream);
- }
- }
- }
- if (chiZips.Count > 0)
- {
- var byts = io.ConvertZipStream(chiZips);
- Stream stream = new MemoryStream(byts);
- Zips.Add(key.Name + "_.zip", stream);
- }
- }
- }
- else
- {
- foreach (var item in dbQuery)
- {
- using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
- {
- byte[] bytes = new byte[fileStream.Length];
- fileStream.Read(bytes, 0, bytes.Length);
- fileStream.Close();
- Stream stream = new MemoryStream(bytes);
- while (Zips.Keys.Contains(item.FileName))
- {
- item.FileName = new Random().Next(100) + "_" + item.FileName;
- }
- Zips.Add(item.FileName, stream);
- }
- }
- }
- groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- if (Zips.Count > 0)
- {
- var byts = io.ConvertZipStream(Zips);
- var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
- io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
- jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
- }
- else
- {
- jw.Msg = "暂无生成文件!";
- }
- return Ok(jw);
- }
- /// <summary>
- /// 下载该团组下此模块的所有文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
- {
- var jw = JsonView(false);
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
- if (groupInfo == null)
- {
- jw.Msg = "团组信息不存在!";
- return Ok(jw);
- }
- var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
- var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
- && x.IsDel == 0);
- if (key == null)
- {
- jw.Msg = "Ctable指向错误!";
- return Ok(jw);
- }
- key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
- RegexOptions.None, TimeSpan.FromSeconds(1.5));
- IOOperatorHelper io = new IOOperatorHelper();
- Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
- foreach (var item in dbQuery)
- {
- if (System.IO.File.Exists(item.FilePath))
- {
- using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
- {
- byte[] bytes = new byte[fileStream.Length];
- fileStream.Read(bytes, 0, bytes.Length);
- fileStream.Close();
- Stream stream = new MemoryStream(bytes);
- while (Zips.Keys.Contains(item.FileName))
- {
- item.FileName = new Random().Next(100) + "_" + item.FileName;
- }
- Zips.Add(item.FileName, stream);
- }
- }
- }
- if (Zips.Count > 0)
- {
- var byts = io.ConvertZipStream(Zips);
- var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
- io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
- jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
- }
- else
- {
- jw.Msg = "暂无生成文件!";
- }
- return Ok(jw);
- }
- /// <summary>
- /// 删除该团组下的指定文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
- {
- var jw = JsonView(false);
- var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
- if (sing == null)
- {
- jw.Msg = "暂无";
- return Ok(jw);
- }
- if (System.IO.File.Exists(sing.FilePath))
- {
- try
- {
- System.IO.File.Delete(sing.FilePath);
- }
- catch (Exception ex)
- {
- jw.Msg = "删除失败!" + ex.Message;
- return Ok(jw);
- }
- }
- sing.IsDel = 1;
- sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- sing.DeleteUserId = dto.UserId;
- _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
- jw = JsonView(true, "删除成功!");
- return Ok(jw);
- }
- #endregion
- #region 共享文件上传
- /// <summary>
- /// 共享文件数据初始化
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public async Task<IActionResult> SharedFileInit(int userid ,int portType)
- {
- var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
- var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
- .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
- .Select(x => x.Id)
- .ToList()
- .Contains(userid);
- var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
- .Where(x => x.STid == 111 && x.IsDel == 0)
- .Select(x => new
- {
- x.Name,
- x.Id,
- }).ToList();
- if (isMarketingDepartment)
- {
- dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
- }
- if (portType == 1)
- {
- var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
- var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
- .Where(x => x.IsDel == 0)
- .OrderByDescending(x=> x.VisitDate )
- .Select(x => new
- {
- x.TeamName,
- x.Id,
- x.CityId,
- })
- .ToList()
- .Select(x=>
- {
- var provinceId = x.CityId;
- var isDefualtVal = true;
- if (provinceId > 0)
- {
- var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
- if (parentId != null)
- {
- isDefualtVal = false;
- provinceId = (int)parentId;
- }
- }
- if (isDefualtVal)
- {
- provinceId = 122; //默认四川
- }
- return new
- {
- x.TeamName,
- x.Id,
- provinceId,
- };
- })
- .ToList();
- return Ok(JsonView(true, "SUCCESS!", new
- {
- dropDownType,
- dropDownGroupList,
- isMarketingDepartment
- }));
- }
- else if (portType == 2 || portType == 3)
- {
- return Ok(JsonView(true, "SUCCESS!", new
- {
- dropDownType,
- isMarketingDepartment
- }));
- }
- else
- {
- return Ok(JsonView(false, "portType有误!"));
- }
- }
- /// <summary>
- /// 共享文件上传
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
- {
- var isGroup = new List<int> { 1412 };
- if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
- {
- return Ok(JsonView(false, "该文件需要关联团组!"));
- }
- if (dto.Files == null || dto.Files.Count == 0)
- {
- return Ok(JsonView(false, "无文件信息!"));
- }
- if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
- {
- return Ok(JsonView(false, "文件大小超过20M!"));
- }
- if (dto.Userid < 1)
- {
- return Ok(JsonView(false, "请传入有效的Userid!"));
- }
- var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
- .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
- .Select((u, j) => new
- {
- u.CnName,
- UserId = u.Id,
- j.JobName,
- })
- .First();
- if (jobInfo == null)
- {
- return Ok(JsonView(false, "请传入有效的Userid!"));
- }
- List<string> commonFileExtensions = new List<string>
- {
- // 文本文件
- ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
- // 图片文件
- ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
- // 视频文件
- ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
- // 音频文件
- ".mp3", ".wav", ".ogg", ".aac", ".flac",
- // 压缩文件
- ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
- // 数据文件
- ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
- };
- try
- {
- var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
- var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
- commonFileExtensions.AddRange(settingExtend);
- }
- catch (Exception)
- { }
- var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
- if (setdata == null)
- {
- return Ok(JsonView(false, "请传入有效的FileType!"));
- }
- List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
- string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
- if (!Directory.Exists(winPath))
- {
- Directory.CreateDirectory(winPath);
- }
- foreach (var item in dto.Files)
- {
- var houzui = Path.GetExtension(item.FileName);
- if (!commonFileExtensions.Contains(houzui))
- {
- return Ok(JsonView(false, "未知后缀名称!"));
- }
- var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
- var saveFilePath = winPath + fileName;
- using (FileStream fs = System.IO.File.Create(saveFilePath))
- {
- item.CopyTo(fs);
- fs.Flush();
- }
- var fileDetail = new Grp_GroupShareFile()
- {
- CreateUserId = dto.Userid,
- CreateTime = DateTime.Now,
- UploadJob = jobInfo.JobName,
- FileName = fileName,
- FileType = dto.FileType,
- Diid = dto.Diid,
- FilePath = winPath + fileName,
- };
- insertList.Add(fileDetail);
- }
- _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
- return Ok(JsonView(true, "保存成功!"));
- }
- /// <summary>
- /// 查询共享文件列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult QuerySharedFile(QuerySharedFileDto dto)
- {
- var isGroup = new List<int> { 1412 };
- if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
- var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
- .And(x => x.Diid == dto.Diid)
- .And(x => x.FileType == dto.FileType)
- .And(x => x.IsDel == 0)
- .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
- .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
- .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
- int totalCount = 0;
- var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
- .Where(queryExpression.ToExpression())
- .OrderBy(x => x.UploadJob)
- .Select(x => new
- {
- x.Id,
- FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
- x.FileName,
- x.FileType,
- x.CreateTime,
- })
- .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
- return Ok(JsonView(true, "SUCCESS!", new
- {
- FileList = dbQuery,
- dto.PageSize,
- dto.PageIndex,
- totalCount
- }));
- }
- /// <summary>
- /// 删除共享文件模块下的指定文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
- {
- var jw = JsonView(false);
- var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
- if (sing == null)
- {
- jw.Msg = "暂无文件信息!";
- return Ok(jw);
- }
- if (sing.CreateUserId != dto.UserId)
- {
- jw.Msg = "只能删除自己上传的文件!";
- return Ok(jw);
- }
- if (System.IO.File.Exists(sing.FilePath))
- {
- try
- {
- System.IO.File.Delete(sing.FilePath);
- }
- catch (Exception ex)
- {
- jw.Msg = "删除失败!" + ex.Message;
- return Ok(jw);
- }
- }
- sing.IsDel = 1;
- sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- sing.DeleteUserId = dto.UserId;
- _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
- jw = JsonView(true, "删除成功!");
- return Ok(jw);
- }
- #endregion
- #region 团组英文资料
- /// <summary>
- /// 查询团组英文所有资料
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
- {
- try
- {
- Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 团组英文资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
- {
- try
- {
- Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 团组英文资料Id查询数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
- {
- try
- {
- Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
- if (_DelegationEnData != null)
- {
- return Ok(JsonView(true, "查询成功!", _DelegationEnData));
- }
- return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 团组英文资料删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
- {
- try
- {
- var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 导出邀请函
- /// <summary>
- /// 导出邀请函页面初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
- {
- try
- {
- List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
- List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
- if (dto.DiId == 0)
- {
- crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
- }
- else
- {
- crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
- }
- return Ok(JsonView(true, "查询成功!", new
- {
- deleClient = crm_Deles,
- delegations = grp_Delegations
- }));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 导出邀请函
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
- {
- #region 参数验证
- //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
- if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
- #endregion
- try
- {
- Dictionary<string, string> transDic = new Dictionary<string, string>();
- string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
- tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
- From Grp_TourClientList tcl
- Left Join
- (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
- cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
- cc2.Area,cc2.IssueDt,cc2.ExpiryDt
- From Crm_DeleClient dc
- Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
- Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
- Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
- Where dc.IsDel = 0) temp
- On temp.DcId =tcl.ClientId
- Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
- var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
- List<string> texts = new List<string>();
- if (datas.Count != 0)
- {
- foreach (TourClientListDetailsView item in datas)
- {
- if (!string.IsNullOrWhiteSpace(item.Pinyin))
- {
- transDic.Add(item.LastName + item.FirstName, item.Pinyin);
- }
- else
- {
- string name = item.LastName + item.FirstName;
- texts.Add(name);
- }
- if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
- {
- if (!transDic.ContainsKey(item.Job))
- {
- texts.Add(item.Job);
- }
- }
- if (!string.IsNullOrEmpty(item.CompanyFullName))
- {
- texts.Add(item.CompanyFullName);
- }
- }
- List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
- if (transData.Count > 0)
- {
- foreach (TranslateResult item in transData)
- {
- if (!transDic.ContainsKey(item.Query))
- {
- transDic.Add(item.Query, item.Translation);
- }
- }
- }
- List<GuestList> list = new List<GuestList>();
- foreach (TourClientListDetailsView dele in datas)
- {
- GuestList guestList = new GuestList();
- if (!string.IsNullOrWhiteSpace(dele.Pinyin))
- {
- guestList.Name = dele.Pinyin;
- }
- else
- {
- string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
- guestList.Name = Name;
- }
- if (dele.Sex == 0)
- {
- guestList.Sex = "Male";
- }
- else if (dele.Sex == 1)
- {
- guestList.Sex = "Female";
- }
- guestList.DOB = dele.BirthDay.Replace('-', '.');
- if (!string.IsNullOrEmpty(dele.Job))
- {
- guestList.Job = dele.Job;
- }
- list.Add(guestList);
- }
- //载入模板
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
- DocumentBuilder builder = new DocumentBuilder(doc);
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < list.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(list[i].Name.ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(list[i].Sex.ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(list[i].DOB.ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(list[i].Job.ToString());
- }
- //删除多余行
- while (tableOne.Rows.Count > list.Count + 1)
- {
- tableOne.Rows.RemoveAt(list.Count + 1);
- }
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
- string filePath = fileDir + $@"商邀相关文件/{fileName}";
- doc.Save(filePath);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- else
- {
- return Ok(JsonView(false, "该团组客户名单暂未录入!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- #endregion
- #region 团组经理模块 出入境费用
- /// <summary>
- /// 团组模块 - 出入境费用 - 省份基础数据源
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
- {
- return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
- {
- var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
- var groupNamFirst = groupNameData.FirstOrDefault();
- //SetDataInfoView
- var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
- var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
- List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
- //验证城市归属并给默认值
- int provinceId = 122;
- if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
- (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
- var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
- var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
- return Ok(JsonView(true, "查询成功!", new
- {
- GroupNameData = groupNameData,
- CurrencyData = _CurrencyData,
- WordTypeData = wordTypeData,
- ExcelTypeData = excelTypeData,
- CurrencyInit = _currencyInfos,
- ViewPermissionData = viewPermissionData
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
- /// </summary>
- /// <returns></returns>
- [HttpGet("{provinceId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
- {
- //验证城市归属并给默认值
- if (provinceId < 1) provinceId = 122;
- /*
- * 122 四川
- * 108 贵州
- * 103 重庆
- * 132 云南
- */
- (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
- return Ok(JsonView(true, "查询成功!", new
- {
- WordTypeData = wordTypeData,
- ExcelTypeData = excelTypeData,
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用
- /// 实时汇率 tips
- /// 签证费用 tips
- /// 机票费用 tips
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
- {
- var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
- //默认币种显示
- var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
- var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
- var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
- return Ok(JsonView(true, "查询成功!", new
- {
- //GroupNameData = groupNameData.Data,
- visaData = visaData.Data,
- airData = airData,
- reteInfos = reteInfos
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - Info
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
- {
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 设置view权限
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
- {
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
- var permissions = new List<Grp_EnterExitCostPermission>();
- foreach (var userId in dto.UserIds)
- {
- permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
- }
- if (permissions.Any())
- {
- _sqlSugar.BeginTran();
- try
- {
- await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
- var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
- if (result < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false));
- }
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - Add And Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
- if (dto.DayOtherPriceData.Any())
- {
- var inserList = dto.DayOtherPriceData
- .Where(x => x.Id == 0)
- .Select(x => new Grp_DayOtherPrice
- {
- Cost = x.Cost,
- Id = x.Id,
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- Currency = x.Currency,
- Diid = x.DiId,
- Index = x.Index,
- IsDel = 0,
- SetDataId = x.SetDataId,
- SubTotal = x.SubTotal,
- Remark = x.Remark
- })
- .ToList();
- var updateList = dto.DayOtherPriceData
- .Where(x => x.Id != 0)
- .Select(x => new Grp_DayOtherPrice
- {
- Cost = x.Cost,
- Id = x.Id,
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- Currency = x.Currency,
- Diid = x.DiId,
- Index = x.Index,
- IsDel = 0,
- SetDataId = x.SetDataId,
- SubTotal = x.SubTotal,
- Remark = x.Remark
- })
- .ToList();
- //添加
- _sqlSugar.BeginTran();
- if (inserList.Any())
- {
- var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
- }
- if (updateList.Any())
- {
- var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
- }
- _sqlSugar.CommitTran();
- }
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- //生成默认文件pdf并且通知人员
- var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
- {
- DiId = dto.DiId,
- ExportType = 1,
- SubTypeId = 1005
- }, "pdf");
- //发送通知
- string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
- int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
- string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
- string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
- //汇率信息记录
- await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - Confirm 费用
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
- {
- //TODO:测试完毕需把对应的用户ID更改
- //1、数据表添加字段
- //2、更改字段接口()
- var _view = await _enterExitCostRep.ConfirmCost(dto);
- //3、确认成功 给财务发送消息
- if (_view.Code == 200)
- {
- if (dto.Type == 1)
- {
- int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
- }
- }
- return Ok(_view);
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - File download
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
- {
- try
- {
- if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
- if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
- if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
- 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
- 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
- 3 团组成员名单 1 团组成员名单", ""));
- var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
- var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
- if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
- var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
- var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
- //数据源
- var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
- var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
- var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
- var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
- var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
- .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
- .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
- .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
- .Select((x, a, b) => new
- {
- x.Index,
- itemName = a.Name,
- CurrencyStr = b.Name,
- x.Cost,
- x.SubTotal,
- x.Remark
- })
- .OrderBy((x) => x.Index)
- .ToList(); //其他款项费用
- var peiceItemCurrencys = new List<string>();
- if (_DayAndCosts.Any())
- {
- var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
- if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
- }
- if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
- var peiceItemCurrencyInfos = new List<CurrencyInfo>();
- if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
- {
- peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
- }
- var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
- var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
- var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
- .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
- .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
- .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
- .Select((tcl, dc, cc) => new ClientInfo
- {
- LastName = dc.LastName,
- FirstName = dc.FirstName,
- Sex = dc.Sex,
- Birthday = dc.BirthDay,
- Company = cc.CompanyFullName,
- Job = dc.Job
- })
- .ToList();
- foreach (var item in DeleClientList)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
- var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
- var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
- var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
- _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
- if (dto.ExportType == 1) //明细表
- {
- if (dto.SubTypeId == 1005) //1005(默认明细表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //利用键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
- decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
- decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
- decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
- decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
- decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
- //境内费用(其他费用)
- if (_EnterExitCosts.ChoiceOne == 1)
- {
- string row1_1 = "";
- if (_EnterExitCosts.Visa > 0)
- {
- //insidePayTotal += _EnterExitCosts.Visa;
- row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
- //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
- //{
- // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
- //}
- }
- string row1_2 = "";
- if (_EnterExitCosts.YiMiao > 0)
- {
- //insidePayTotal += _EnterExitCosts.YiMiao;
- row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.HeSuan > 0)
- {
- //insidePayTotal += _EnterExitCosts.HeSuan;
- row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.Service > 0)
- {
- //insidePayTotal += _EnterExitCosts.Service;
- row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
- }
- string row1_3 = "";
- if (_EnterExitCosts.Safe > 0)
- {
- //insidePayTotal += _EnterExitCosts.Safe;
- row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.Ticket > 0)
- {
- //insidePayTotal += _EnterExitCosts.Ticket;
- row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
- }
- string row1 = "";
- if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
- if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
- if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
- row1 += $"备注:{_EnterExitCosts.Remark}";
- dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
- dic.Add("Row1Str", row1);
- }
- string airTotalStr = string.Empty,
- airPriceStr = string.Empty;
- //经济舱
- if (_EnterExitCosts.SumJJC == 1)
- {
- airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
- airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
- }
- //公务舱
- if (_EnterExitCosts.SumGWC == 1)
- {
- airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
- airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
- }
- //头等舱
- if (_EnterExitCosts.SumTDC == 1)
- {
- airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
- airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
- }
- //汇率描述
- string rateStr = "";
- if (peiceItemCurrencyInfos.Any())
- {
- rateStr = "\r\n汇率描述:";
- foreach (var item in peiceItemCurrencyInfos)
- {
- rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
- }
- }
- string twoItemRemark = "备注:";
- if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
- if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
- dic.Add("AirTotalStr", airTotalStr);
- dic.Add("AirPriceStr", airPriceStr);
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- dic.Add("TwoItemRemark", twoItemRemark);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- int table1Row = 0,
- table2Row = 0,
- table3Row = 0,
- table4Row = 0,
- table5Row = 0;
- //住宿费
- if (_EnterExitCosts.ChoiceThree == 1)
- {
- dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
- table1Row = dac1.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac1.Count; i++)
- {
- Grp_DayAndCost dac = dac1[i];
- if (dac == null) continue;
- builder.MoveToCell(0, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "晚:");
- builder.MoveToCell(0, i, 1, 0);
- //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
- //builder.Write(dac.Place == null ? "" : dac.Place);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(0, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(0, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(0, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- else dic.Add("SubZS", "0.00");
- //删除多余行
- while (table1.Rows.Count > table1Row)
- {
- table1.Rows.RemoveAt(table1Row);
- }
- //伙食费
- Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceFour == 1)
- {
- dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
- table2Row = dac2.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac2.Count; i++)
- {
- Grp_DayAndCost dac = dac2[i];
- if (dac == null) continue;
- builder.MoveToCell(1, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(1, i, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(1, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(1, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(1, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(1, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- else dic.Add("SubHS", "0.00");
- //删除多余行
- while (table2.Rows.Count > table2Row)
- {
- table2.Rows.RemoveAt(table2Row);
- }
- //公杂费
- Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceFive == 1)
- {
- dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
- table3Row = dac3.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac3.Count; i++)
- {
- Grp_DayAndCost dac = dac3[i];
- if (dac == null) continue;
- builder.MoveToCell(2, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(2, i, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(2, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(2, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(2, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(2, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- //删除多余行
- while (table3.Rows.Count > table3Row)
- {
- table3.Rows.RemoveAt(table3Row);
- }
- #endregion
- }
- else dic.Add("SubGZF", "0.00");
- //删除多余行
- while (table3.Rows.Count > table3Row)
- {
- table3.Rows.RemoveAt(table3Row);
- }
- //培训费
- Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceSix == 1)
- {
- string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
- dic.Add("SubPX", pxStr);
- table4Row = dac4.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac4.Count; i++)
- {
- Grp_DayAndCost dac = dac4[i];
- if (dac == null) continue;
- builder.MoveToCell(3, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(3, i, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(3, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(3, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(3, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(3, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
- //删除多余行
- while (table4.Rows.Count > table4Row)
- {
- table4.Rows.RemoveAt(table4Row);
- }
- //其他费用
- Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.OtherExpenses_Checked == 1)
- {
- string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
- dic.Add("titleQi", qtStr);
- table5Row = dac5.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac5.Count; i++)
- {
- var dac = dac5[i];
- if (dac == null) continue;
- builder.MoveToCell(4, i, 0, 0);
- builder.Write("第" + dac.Index.ToString() + "项:");
- builder.MoveToCell(4, i, 1, 0);
- builder.Write(dac.itemName);
- builder.MoveToCell(4, i, 2, 0);
- builder.Write("费用标准:");
- builder.MoveToCell(4, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
- builder.MoveToCell(4, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(4, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- builder.MoveToCell(4, i, 6, 0);
- builder.Write("备注:");
- builder.MoveToCell(4, i, 7, 0);
- builder.Write(dac.Remark);
- }
- #endregion
- }
- //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
- //删除多余行
- while (table5.Rows.Count > table5Row)
- {
- table5.Rows.RemoveAt(table5Row);
- }
- //加上其他费用
- decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
- decimal subJJC = 0.00M,
- subGWC = 0.00M,
- subTDC = 0.00M;
- //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
- string totalLabel = string.Format("全部费用总计:");
- //经济舱
- if (_EnterExitCosts.SumJJC == 1)
- {
- subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
- totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
- }
- //公务舱
- if (_EnterExitCosts.SumGWC == 1)
- {
- subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
- totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
- }
- //头等舱
- if (_EnterExitCosts.SumTDC == 1)
- {
- subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
- totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
- }
- //TotalLabel
- dic.Add("TotalLabel", totalLabel);
- //dic.Add("SubJJC", subJJC.ToString("#0.00"));
- //dic.Add("SubGWC", subGWC.ToString("#0.00"));
- //dic.Add("SubTDC", subTDC.ToString("#0.00"));
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- Bookmark bookmark = doc.Range.Bookmarks[key];
- if (bookmark != null)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- }
- #endregion
- #region 设置页眉
- string userLabel = string.Empty;
- var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (currUserInfo != null)
- {
- var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
- if (userInfo != null)
- {
- string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
- //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
- userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
- }
- }
- //设置页脚
- //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
- #endregion
- //文件名
- string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
- AsposeHelper.removewatermark_v2180();
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
- {
- List<string> list = new List<string>();
- try
- {
- var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
- foreach (var item in spilitArr)
- {
- var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
- var depCode = spDotandEmpty[2].Substring(0, 3);
- var arrCode = spDotandEmpty[2].Substring(3, 3);
- string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
- arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
- list.Add(depName);
- list.Add(arrName);
- }
- list = list.Distinct().ToList();
- dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
- }
- catch (Exception)
- {
- dic.Add("ReturnCode", "行程录入不正确!");
- }
- }
- else
- {
- dic.Add("ReturnCode", "未录入行程!");
- }
- dic.Add("ReturnCodeAir", dic["ReturnCode"]);
- dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
- {
- TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- dic.Add("Day", sp.Days.ToString());
- }
- dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
- //dic.Add("Names", Names);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- decimal dac1totalPrice = 0.00M;
- int accommodationStartIndex = 6, foodandotherStartIndex = 22;
- foreach (var dac in dac1)
- {
- if (dac.SubTotal == 0.00M)
- {
- continue;
- }
- //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
- //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
- builder.MoveToCell(0, accommodationStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, accommodationStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
- builder.Write(currency);//币种
- builder.MoveToCell(0, accommodationStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, accommodationStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, accommodationStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, accommodationStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, accommodationStartIndex, 7, 0);
- decimal rate = 0.00M;
- rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, accommodationStartIndex, 8, 0);
- decimal rbmPrice = dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- accommodationStartIndex++;
- dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
- }
- dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
- {
- table1.Rows.RemoveAt(i - 1);
- foodandotherStartIndex--;
- }
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- decimal dac2totalPrice = 0.00M;
- foreach (var dac in dac2)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
- builder.Write(currency);//币种
- builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
- decimal rate = 0.00M;
- rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
- decimal rbmPrice = dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- foodandotherStartIndex++;
- dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
- }
- dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
- for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
- {
- table1.Rows.RemoveAt(i - 1);
- }
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- string otherFeeStr = "";
- if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
- if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
- if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
- #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
- foreach (var otherInfo in dac5)
- {
- otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
- }
- #endregion
- if (otherFeeStr.Length > 0)
- {
- otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
- otherFeeStr = $"({otherFeeStr})";
- dic.Add("OtherFeeStr", otherFeeStr);
- }
- //总计
- decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
- //国际旅费
- string outsideAir = string.Empty;
- string allPriceAir = string.Empty;
- if (_EnterExitCosts.SumJJC == 1)
- {
- outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
- allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
- }
- if (_EnterExitCosts.SumGWC == 1)
- {
- outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
- allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
- }
- if (_EnterExitCosts.SumTDC == 1)
- {
- outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
- allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
- }
- dic.Add("InTravelPrice", $"({outsideAir})");
- dic.Add("FinalSumPrice", $"({allPriceAir})");
- //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
- //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
- //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(tempPath);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
- {
- List<string> list = new List<string>();
- try
- {
- var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
- foreach (var item in spilitArr)
- {
- var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
- var depCode = spDotandEmpty[2].Substring(0, 3);
- var arrCode = spDotandEmpty[2].Substring(3, 3);
- string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
- arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
- list.Add(depName);
- list.Add(arrName);
- }
- list = list.Distinct().ToList();
- dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
- }
- catch (Exception)
- {
- dic.Add("ReturnCode", "行程录入不正确!");
- }
- }
- else
- {
- dic.Add("ReturnCode", "未录入行程!");
- }
- dic.Add("ReturnCodeAir", dic["ReturnCode"]);
- dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
- {
- TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- dic.Add("Day", sp.Days.ToString());
- }
- dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
- designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
- designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
- designer.SetDataSource("Group", _DelegationInfo.TeamName);
- designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
- designer.SetDataSource("Name", Names);
- designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
- designer.SetDataSource("Day", dic["Day"] + "天");
- designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
- designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
- int startIndex = 10;
- const int startIndexcopy = 10;
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- DataTable dtdac1 = new DataTable();
- List<string> place = new List<string>();
- dtdac1.Columns.AddRange(new DataColumn[] {
- new DataColumn(){ ColumnName = "city"},
- new DataColumn(){ ColumnName = "curr"},
- new DataColumn(){ ColumnName = "criterion"},
- new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
- new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
- new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
- });
- DataTable dtdac2 = new DataTable();
- dtdac2.Columns.AddRange(new DataColumn[] {
- new DataColumn(){ ColumnName = "city"},
- new DataColumn(){ ColumnName = "curr"},
- new DataColumn(){ ColumnName = "criterion"},
- new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
- new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
- new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
- });
- dtdac1.TableName = "tb1";
- dtdac2.TableName = "tb2";
- decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
- foreach (var item in dac1)
- {
- item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
- if (place.Contains(item.Place))
- {
- continue;
- }
- DataRow row = dtdac1.NewRow();
- row["city"] = item.Place;
- string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- row["curr"] = currency;
- row["rate"] = rate.ToString("#0.0000");
- row["criterion"] = item.Cost.ToString("#0.00");
- row["number"] = 1;
- row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
- //row["costRMB"] = rbmPrice;
- dtdac1.Rows.Add(row);
- place.Add(item.Place);
- }
- place = new List<string>();
- foreach (var item in dac2)
- {
- item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
- if (place.Contains(item.Place))
- {
- continue;
- }
- DataRow row = dtdac2.NewRow();
- row["city"] = item.Place;
- string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- row["curr"] = currency;
- row["rate"] = rate.ToString("#0.0000");
- row["criterion"] = item.Cost.ToString("#0.00");
- row["number"] = 1;
- row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
- //row["cost"] = item.SubTotal;
- //row["costRMB"] = rbmPrice;
- dtdac2.Rows.Add(row);
- place.Add(item.Place);
- //dac2totalPrice += rbmPrice;
- }
- dac1totalPrice = dac1.Sum(it => it.SubTotal);
- dac2totalPrice = dac2.Sum(it => it.SubTotal);
- designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- designer.SetDataSource("dac2totalPrice", dac2totalPrice);
- designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
- designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
- string cell4Str1 = string.Empty;
- if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
- if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
- if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
- string cell4Str = $" 4.国际旅费:{cell4Str1}";
- string cellStr = $" 5.其他费用(";
- if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
- if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
- if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
- if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
- if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
- if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
- #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
- var otherPriceTotal = dac5.Sum(x => x.SubTotal);
- foreach (var otherInfo in dac5)
- {
- cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
- }
- #endregion
- if (cellStr.Length > 8)
- {
- cellStr = cellStr.Substring(0, cellStr.Length - 1);
- }
- cellStr += ")";
- decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
- decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
- decimal pxFee = dac4.Sum(it => it.Cost);
- decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
- string celllastStr1 = "";
- if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
- if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
- if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
- celllastStr1 += $",国际旅费 元";
- if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
- string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
- designer.SetDataSource("cell4Str", cell4Str);
- designer.SetDataSource("cellStr", cellStr);
- designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
- designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
- designer.SetDataSource("celllastStr", celllastStr);
- Workbook wb = designer.Workbook;
- var sheet = wb.Worksheets[0];
- //绑定datatable数据集
- designer.SetDataSource(dtdac1);
- designer.SetDataSource(dtdac2);
- designer.Process();
- var rowStart = dtdac1.Rows.Count;
- while (rowStart > 0)
- {
- sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
- sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
- startIndex++;
- rowStart--;
- }
- sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
- startIndex += 1; //总计行
- rowStart = dtdac2.Rows.Count;
- while (rowStart > 0)
- {
- sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
- sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
- startIndex++;
- rowStart--;
- }
- sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
- wb.CalculateFormula(true);
- //模板文件名
- string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("GroupName", _DelegationInfo.TeamName);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- string missionLeader = ""; //团负责人默认接团客户名单第一个人
- string missionLeaderJob = "";//负责人job
- //int groupNumber = 0; //团人数
- if (DeleClientList.Count > 0)
- {
- missionLeader = DeleClientList[0]?.Name ?? "";
- missionLeaderJob = DeleClientList[0]?.Job ?? "";
- }
- dic.Add("MissionLeader", missionLeader); //团负责人
- dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
- dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
- #region MyRegion
- //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
- //{
- // List<string> list = new List<string>();
- // try
- // {
- // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
- // foreach (var item in spilitArr)
- // {
- // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
- // var depCode = spDotandEmpty[2].Substring(0, 3);
- // var arrCode = spDotandEmpty[2].Substring(3, 3);
- // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
- // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
- // list.Add(depName);
- // list.Add(arrName);
- // }
- // list = list.Distinct().ToList();
- // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
- // }
- // catch (Exception)
- // {
- // dic.Add("ReturnCode", "行程录入不正确!");
- // }
- //}
- //else
- //{
- // dic.Add("ReturnCode", "未录入行程!");
- //}
- List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
- dic.Add("ReturnCode", string.Join("、", countrys));
- #endregion
- //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
- //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
- //{
- // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- // dic.Add("Day", sp.Days.ToString());
- //}
- dic.Add("Day", _DelegationInfo.VisitDays.ToString());
- dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
- // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- //培训人员名单
- int cultivateRowIndex = 7;
- foreach (var item in DeleClientList)
- {
- builder.MoveToCell(0, cultivateRowIndex, 0, 0);
- builder.Write(item.Name);
- builder.MoveToCell(0, cultivateRowIndex, 1, 0);
- builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
- builder.MoveToCell(0, cultivateRowIndex, 2, 0);
- string birthDay = "";
- if (item.Birthday != null)
- {
- DateTime dt = Convert.ToDateTime(item.Birthday);
- birthDay = $"{dt.Year}.{dt.Month}";
- }
- builder.Write(birthDay);
- builder.MoveToCell(0, cultivateRowIndex, 3, 0);
- builder.Write(item.Company);
- builder.MoveToCell(0, cultivateRowIndex, 4, 0);
- builder.Write(item.Job);
- cultivateRowIndex++;
- }
- //删除多余行
- //cultivateRowIndex -= 2;
- int delRows = 10 + 7 - cultivateRowIndex;
- if (delRows > 0)
- {
- for (int i = 0; i < delRows; i++)
- {
- table1.Rows.RemoveAt(cultivateRowIndex);
- //cultivateRowIndex++;
- }
- }
- decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
- dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
- decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
- dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
- decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
- dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
- decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
- dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
- decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
- dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
- //其他费用
- decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
- dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
- //其他费用合计
- decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
- decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
- decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
- //公务舱合计
- //国际旅费
- //string outsideJJ = "";
- //string allPriceJJ = "";
- if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
- {
- dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
- dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
- }
- if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
- {
- dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
- dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
- }
- if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
- {
- string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
- dic.Add("AirFeeTotal", airFeeTotalStr);
- string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
- dic.Add("FeeTotal", feeTotalStr);
- }
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- }
- else if (dto.ExportType == 2) //表格
- {
- //利用键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- dic.Add("Day", sp.Days.ToString());
- dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- dic.Add("TeamName", _DelegationInfo.TeamName);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- //dic.Add("TellPhone", _DelegationInfo.TellPhone);
- string missionLeaderName = "",
- missionLeaderJob = "";
- if (DeleClientList.Count > 0)
- {
- missionLeaderName = DeleClientList[0].Name;
- missionLeaderJob = DeleClientList[0].Job;
- }
- dic.Add("MissionLeaderName", missionLeaderName);
- dic.Add("MissionLeaderJob", missionLeaderJob);
- dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
- dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- int rowCount = 10;//总人数行
- int startRowIndex = 7; //起始行
- for (int i = 0; i < DeleClientList.Count; i++)
- {
- builder.MoveToCell(0, startRowIndex, 0, 0);
- builder.Write(DeleClientList[i].Name); //出国人员姓名
- builder.MoveToCell(0, startRowIndex, 1, 0);
- string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
- builder.Write(sex);//性别
- builder.MoveToCell(0, startRowIndex, 2, 0);
- builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
- builder.MoveToCell(0, startRowIndex, 3, 0);
- builder.Write(DeleClientList[i].Company);//工作单位
- builder.MoveToCell(0, startRowIndex, 4, 0);
- builder.Write(DeleClientList[i].Job);//职务及级别
- builder.MoveToCell(0, startRowIndex, 5, 0);
- builder.Write("");//人员属性
- builder.MoveToCell(0, startRowIndex, 6, 0);
- builder.Write("");//上次出国时间
- startRowIndex++;
- }
- int nullRow = rowCount - DeleClientList.Count;//空行
- for (int i = 0; i < nullRow; i++)
- {
- table1.Rows.Remove(table1.Rows[startRowIndex]);
- }
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- dic.Add("GroupClient", _DelegationInfo.ClientUnit);
- var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
- dic.Add("Names", Names);
- int accommodationRows = 12;
- //int foodandotherRows = 12;
- var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
- var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- int accommodationStartIndex = 6;
- decimal dac1totalPrice = 0.00M;
- foreach (var dac in dac1)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
- //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
- builder.MoveToCell(0, accommodationStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
- builder.MoveToCell(0, accommodationStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
- builder.Write(currency);//币种
- builder.MoveToCell(0, accommodationStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, accommodationStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, accommodationStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, accommodationStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, accommodationStartIndex, 7, 0);
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, accommodationStartIndex, 8, 0);
- decimal rbmPrice = rate * dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- accommodationStartIndex++;
- dac1totalPrice += rbmPrice;
- }
- dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- builder.MoveToCell(0, accommodationStartIndex, 1, 0);
- builder.Write("小计");
- builder.MoveToCell(0, accommodationStartIndex, 8, 0);
- builder.Write(dac1totalPrice.ToString("#0.00"));
- accommodationStartIndex++;
- int nullRow = accommodationRows - dac1.Count;
- //删除空行
- //if (nullRow > 0)
- //{
- // int rowIndex = accommodationStartIndex;
- // for (int i = 0; i < nullRow; i++)
- // {
- // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
- // row.Remove();
- // rowIndex++;
- // }
- //}
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- int foodandotherStartIndex = 19;//
- decimal dac2totalPrice = 0.00M;
- foreach (var dac in dac2)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- //foodandotherStartIndex = 12;
- builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
- builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
- builder.Write(currency);//币种
- builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
- decimal rbmPrice = rate * dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- foodandotherStartIndex++;
- dac2totalPrice += rbmPrice;
- }
- dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
- Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
- //删除空行
- //if (dac2.Count < foodandotherRows)
- //{
- // while (table2.Rows.Count > dac2.Count)
- // {
- // table2.Rows.RemoveAt(dac2.Count);
- // }
- //}
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- string otherFeeStr = "";
- if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
- if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
- if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
- if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
- if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
- if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
- #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
- foreach (var otherInfo in dac5)
- {
- otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
- }
- #endregion
- if (otherFeeStr.Length > 0)
- {
- otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
- otherFeeStr = $"({otherFeeStr})";
- dic.Add("OtherFeeStr", otherFeeStr);
- }
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- }
- else if (dto.ExportType == 3)
- {
- if (dto.SubTypeId == 1) //团组成员名单
- {
- if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < DeleClientList.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(DeleClientList[i].Name);
- builder.MoveToCell(0, i + 1, 1, 0);
- string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
- builder.Write(sex);
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(DeleClientList[i].Company);
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(DeleClientList[i].Job);
- }
- //删除多余行
- while (tableOne.Rows.Count > DeleClientList.Count + 1)
- {
- tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
- }
- string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
- //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
- //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- }
- return Ok(JsonView(400, "操作失败!", ""));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(400, ex.Message, ""));
- }
- }
- /// <summary>
- /// 获取三公费用标准city
- /// </summary>
- /// <param name="placeData"></param>
- /// <param name="nationalTravelFeeId"></param>
- /// <returns></returns>
- private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
- {
- string _city = string.Empty;
- if (placeData.Count < 1) return _city;
- var data = placeData.Find(it => it.Id == nationalTravelFeeId);
- if (data == null) return _city;
- string country = data.Country;
- string city = data.City;
- if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
- else _city = city;
- return _city;
- }
- ///// <summary>
- ///// 团组模块 - 出入境费用 - 明细表导出
- ///// </summary>
- ///// <returns></returns>
- //[HttpPost]
- //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
- //{
- // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
- // if (data.Code != 0)
- // {
- // return Ok(JsonView(false, data.Msg));
- // }
- // return Ok(JsonView(true, data.Msg, data.Data));
- //}
- /// <summary>
- /// 团组模块 - 出入境费用 - 一键清空
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
- {
- if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
- if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
- var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
- await _sqlSugar.Updateable<Grp_DayOtherPrice>()
- .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
- .SetColumns(x => new Grp_DayOtherPrice
- {
- IsDel = 1,
- DeleteUserId = dto.UserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .ExecuteCommandAsync();
- if (_view.Code == 0)
- {
- return Ok(JsonView(true, "操作成功"));
- }
- return Ok(JsonView(false, "操作失败"));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 子项删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "操作成功!", data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 删除三公其他费用
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
- public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
- {
- var jw = JsonView(false, "删除失败!");
- var data = new Grp_DayOtherPrice()
- {
- Id = dto.Id,
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
- };
- var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
- if (del > 0)
- {
- jw.Code = 200;
- jw.Msg = "删除成功!";
- }
- return Ok(jw);
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
- {
- int provinceId = dto.ProvinceId;
- if (provinceId < 1) provinceId = 122; //默认四川省数据
- var nftData = await _sqlSugar
- .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
- JoinType.Left, ntf.Currency == sd1.Id,
- JoinType.Left, ntf.LastUpdateUserId == u.Id,
- JoinType.Left, ntf.ProvinceId == c.Id
- ))
- .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
- .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
- {
- Id = ntf.Id,
- ProvinceId = ntf.ProvinceId,
- ProvinceName = c.Name_CN,
- Continent = ntf.Continent,
- Country = ntf.Country,
- City = ntf.City,
- Currency = ntf.Currency,
- CurrencyCode = sd1.Name,
- CurrencyName = sd1.Remark,
- RoomCost = ntf.RoomCost,
- FoodCost = ntf.FoodCost,
- PublicCost = ntf.PublicCost,
- LastUpdateUserId = ntf.LastUpdateUserId,
- LastUpdateUserName = u.CnName,
- LastUpdateTime = ntf.LastUpdateTime
- })
- .ToListAsync();
- return Ok(JsonView(true, "查询成功!", nftData));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 Page List Data Source
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetNationalTravelFeePageDataSource()
- {
- string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
- var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
- List<string> countryData = new List<string>();
- countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
- countryData = countryData.Distinct().ToList();
- List<dynamic> dataSource = new List<dynamic>();
- foreach (var item in countryData)
- {
- var cityData1 = new List<string>();
- cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
- var countryData2 = new
- {
- CountryName = item,
- CityData = cityData1
- };
- if (!dataSource.Contains(countryData2))
- {
- dataSource.Add(countryData2);
- }
- }
- return Ok(JsonView(true, "查询成功!", dataSource));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 Page List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
- {
- int portId = dto.PortType,
- pageIndex = dto.PageIndex,
- pageSize = dto.PageSize;
- if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
- if (pageIndex == 0) pageIndex = 1;
- if (pageSize == 0) pageSize = 10;
- RefAsync<int> total = 0;
- var nationalTravelFeeData = await _sqlSugar
- .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
- JoinType.Left, ntf.Currency == sd1.Id,
- JoinType.Left, ntf.LastUpdateUserId == u.Id,
- JoinType.Left, ntf.ProvinceId == sd2.Id
- ))
- .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
- .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
- .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
- .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
- .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
- .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
- {
- RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
- Id = ntf.Id,
- ProvinceId = ntf.ProvinceId,
- ProvinceName = sd2.Name_CN,
- Continent = ntf.Continent,
- Country = ntf.Country,
- City = ntf.City,
- Currency = ntf.Currency,
- CurrencyCode = sd1.Name,
- CurrencyName = sd1.Remark,
- RoomCost = ntf.RoomCost,
- FoodCost = ntf.FoodCost,
- PublicCost = ntf.PublicCost,
- LastUpdateUserId = ntf.LastUpdateUserId,
- LastUpdateUserName = u.CnName,
- LastUpdateTime = ntf.LastUpdateTime,
- Remark = ntf.Remark
- })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 根据城市查询
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
- {
- if (dto == null) return Ok(JsonView(false, "请传入参数!"));
- int portId = dto.PortType;
- if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
- string whereSql = string.Empty;
- if (!string.IsNullOrEmpty(dto.Country))
- {
- whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
- }
- if (!string.IsNullOrEmpty(dto.City))
- {
- whereSql = string.Format(@"And City = '{0}' ", dto.City);
- }
- string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
- ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
- gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
- From Grp_NationalTravelFee gntf
- Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
- Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
- Where gntf.Isdel = 0 {0} ", whereSql);
- var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
- return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 - Add Or Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
- {
- return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 - Del
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
- {
- Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
- {
- Id = dto.Id,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
- IsDel = 1
- };
- var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
- .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
- .WhereColumns(it => new { it.Id })
- .ExecuteCommandAsync();
- if (delStatus <= 0)
- {
- return Ok(JsonView(false, "删除失败!"));
- }
- return Ok(JsonView(true, "操作成功!"));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
- /// 注:Get 请求Headers 加 Token
- /// </summary>
- /// <param name="groupId"></param>
- /// <returns></returns>
- [HttpGet("{groupId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
- {
- var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
- data.ForEach(x =>
- {
- x.CreateUserId = _currUserInfo.UserId;
- });
- if (data.Any())
- {
- var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
- if (add > 0)
- {
- return Ok(JsonView(true, "操作成功!"));
- }
- }
- return Ok(JsonView(false, "未操作!"));
- }
- #endregion
- #region 团组经理模块 出入境费用-草稿
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
- {
- var provData = await _groupRepository.ProvinceBasicSource();
- return Ok(JsonView(true, "查询成功!", provData));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
- /// </summary>
- /// <returns></returns>
- [HttpGet("{provinceId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
- {
- //验证城市归属并给默认值
- if (provinceId < 1) provinceId = 122;
- /*
- * 122 四川
- * 108 贵州
- * 103 重庆
- * 132 云南
- */
- (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
- return Ok(JsonView(true, "查询成功!", new
- {
- WordTypeData = wordTypeData,
- ExcelTypeData = excelTypeData,
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
- {
- var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
- .Where(x => x.IsDel == 0)
- .OrderByDescending(x => x.CreateTime)
- .Select(x => new { x.Id, x.DraftName })
- .ToListAsync();
- string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
- //SetDataInfoView
- var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
- var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
- var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
- int provinceId = dto.ProvinceId;
- if (provinceId < 1) provinceId = 122;
- /*
- * 122 四川
- * 108 贵州
- * 103 重庆
- * 132 云南
- */
- (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
- //默认币种显示
- var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
- var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
- return Ok(JsonView(true, "查询成功!", new
- {
- DraftNameDatas = draftNameDatas,
- CurrencyData = _CurrencyData,
- WordTypeData = wordTypeData,
- ExcelTypeData = excelTypeData,
- CurrencyInit = _currencyInfos,
- ViewPermissionData = viewPermissionData
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿
- /// 实时汇率 tips
- /// 机票费用 tips
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
- {
- //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
- return Ok(JsonView(true, "查询成功!", new
- {
- //GroupNameData = groupNameData.Data,
- //visaData = visaData.Data,
- //airData = airData.Data,
- reteInfos = await GeneralMethod.EnterExitCostLiveRate()
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿
- /// 签证费用 tips
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
- {
- //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
- var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
- .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
- .Select(x => x.NationalTravelFeeId)
- .Distinct()
- .ToListAsync();
- //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
- var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
- .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
- .Select(x => x.Country)
- .Distinct()
- .ToArrayAsync();
- //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
- (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
- return Ok(JsonView(true, "查询成功!", new
- {
- totalAmt = totalAmt,
- remark = remark
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - Info
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
- {
- return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 设置view权限
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
- {
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
- if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
- var permissions = new List<Grp_EnterExitCostDraftPermission>();
- foreach (var userId in dto.UserIds)
- {
- permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
- }
- if (permissions.Any())
- {
- _sqlSugar.BeginTran();
- try
- {
- await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
- var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
- if (result < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false));
- }
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - Add And Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
- {
- var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
- //汇率信息记录
- await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - File downlaod
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
- {
- try
- {
- var id = dto.Id;
- if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
- if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
- if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
- 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
- 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
- 3 团组成员名单 1 团组成员名单", ""));
- var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
- if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
- var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
- var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
- var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
- var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
- //数据源
- var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
- var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
- var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
- var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
- var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
- .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
- .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
- .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
- .Select((x, a, b) => new
- {
- x.Index,
- itemName = a.Name,
- CurrencyStr = b.Name,
- x.Cost,
- x.SubTotal,
- x.Remark
- })
- .OrderBy((x) => x.Index)
- .ToList(); //其他款项费用
- var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
- var peiceItemCurrencys = new List<string>();
- if (_DayAndCosts.Any())
- {
- var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
- if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
- }
- if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
- var peiceItemCurrencyInfos = new List<CurrencyInfo>();
- if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
- {
- peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
- }
- var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
- var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
- var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
- if (dto.ExportType == 1) //明细表
- {
- if (dto.SubTypeId == 1005) //1005(默认明细表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //利用键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
- decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
- decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
- decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
- decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
- decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
- //境内费用(其他费用)
- if (_EnterExitCosts.ChoiceOne == 1)
- {
- string row1_1 = "";
- if (_EnterExitCosts.Visa > 0)
- {
- //insidePayTotal += _EnterExitCosts.Visa;
- row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
- //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
- //{
- // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
- //}
- }
- string row1_2 = "";
- if (_EnterExitCosts.YiMiao > 0)
- {
- //insidePayTotal += _EnterExitCosts.YiMiao;
- row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.HeSuan > 0)
- {
- //insidePayTotal += _EnterExitCosts.HeSuan;
- row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.Service > 0)
- {
- //insidePayTotal += _EnterExitCosts.Service;
- row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
- }
- string row1_3 = "";
- if (_EnterExitCosts.Safe > 0)
- {
- //insidePayTotal += _EnterExitCosts.Safe;
- row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.Ticket > 0)
- {
- //insidePayTotal += _EnterExitCosts.Ticket;
- row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
- }
- string row1 = "";
- if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
- if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
- if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
- row1 += $"备注:{_EnterExitCosts.Remark}";
- dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
- dic.Add("Row1Str", row1);
- }
- string airTotalStr = string.Empty,
- airPriceStr = string.Empty;
- //经济舱
- if (_EnterExitCosts.SumJJC == 1)
- {
- airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
- airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
- }
- //公务舱
- if (_EnterExitCosts.SumGWC == 1)
- {
- airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
- airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
- }
- //头等舱
- if (_EnterExitCosts.SumTDC == 1)
- {
- airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
- airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
- }
- //汇率描述
- string rateStr = "";
- if (peiceItemCurrencyInfos.Any())
- {
- rateStr = "\r\n汇率描述:";
- foreach (var item in peiceItemCurrencyInfos)
- {
- rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
- }
- }
- string twoItemRemark = "备注:";
- if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
- if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
- dic.Add("AirTotalStr", airTotalStr);
- dic.Add("AirPriceStr", airPriceStr);
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- dic.Add("TwoItemRemark", twoItemRemark);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- int table1Row = 0,
- table2Row = 0,
- table3Row = 0,
- table4Row = 0,
- table5Row = 0;
- //住宿费
- if (_EnterExitCosts.ChoiceThree == 1)
- {
- dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
- table1Row = dac1.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac1.Count; i++)
- {
- var dac = dac1[i];
- if (dac == null) continue;
- builder.MoveToCell(0, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "晚:");
- builder.MoveToCell(0, i, 1, 0);
- //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
- //builder.Write(dac.Place == null ? "" : dac.Place);
- builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(0, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(0, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(0, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- else dic.Add("SubZS", "0.00");
- //删除多余行
- while (table1.Rows.Count > table1Row)
- {
- table1.Rows.RemoveAt(table1Row);
- }
- //伙食费
- Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceFour == 1)
- {
- dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
- table2Row = dac2.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac2.Count; i++)
- {
- var dac = dac2[i];
- if (dac == null) continue;
- builder.MoveToCell(1, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(1, i, 1, 0);
- builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(1, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(1, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(1, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(1, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- else dic.Add("SubHS", "0.00");
- //删除多余行
- while (table2.Rows.Count > table2Row)
- {
- table2.Rows.RemoveAt(table2Row);
- }
- //公杂费
- Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceFive == 1)
- {
- dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
- table3Row = dac3.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac3.Count; i++)
- {
- var dac = dac3[i];
- if (dac == null) continue;
- builder.MoveToCell(2, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(2, i, 1, 0);
- builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(2, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(2, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(2, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(2, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- //删除多余行
- while (table3.Rows.Count > table3Row)
- {
- table3.Rows.RemoveAt(table3Row);
- }
- #endregion
- }
- else dic.Add("SubGZF", "0.00");
- //删除多余行
- while (table3.Rows.Count > table3Row)
- {
- table3.Rows.RemoveAt(table3Row);
- }
- //培训费
- Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.ChoiceSix == 1)
- {
- string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
- dic.Add("SubPX", pxStr);
- table4Row = dac4.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac4.Count; i++)
- {
- var dac = dac4[i];
- if (dac == null) continue;
- builder.MoveToCell(3, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(3, i, 1, 0);
- builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(3, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(3, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(3, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(3, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- #endregion
- }
- //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
- //删除多余行
- while (table4.Rows.Count > table4Row)
- {
- table4.Rows.RemoveAt(table4Row);
- }
- //其他费用
- Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
- if (_EnterExitCosts.OtherExpenses_Checked == 1)
- {
- string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
- dic.Add("titleQi", qtStr);
- table5Row = dac5.Count;
- #region 填充word表格内容
- for (int i = 0; i < dac5.Count; i++)
- {
- var dac = dac5[i];
- if (dac == null) continue;
- builder.MoveToCell(4, i, 0, 0);
- builder.Write("第" + dac.Index.ToString() + "项:");
- builder.MoveToCell(4, i, 1, 0);
- builder.Write(dac.itemName);
- builder.MoveToCell(4, i, 2, 0);
- builder.Write("费用标准:");
- builder.MoveToCell(4, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
- builder.MoveToCell(4, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(4, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- builder.MoveToCell(4, i, 6, 0);
- builder.Write("备注:");
- builder.MoveToCell(4, i, 7, 0);
- builder.Write(dac.Remark);
- }
- #endregion
- }
- //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
- //删除多余行
- while (table5.Rows.Count > table5Row)
- {
- table5.Rows.RemoveAt(table5Row);
- }
- //加上其他费用
- decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
- decimal subJJC = 0.00M,
- subGWC = 0.00M,
- subTDC = 0.00M;
- //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
- string totalLabel = string.Format("全部费用总计:");
- //经济舱
- if (_EnterExitCosts.SumJJC == 1)
- {
- subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
- totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
- }
- //公务舱
- if (_EnterExitCosts.SumGWC == 1)
- {
- subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
- totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
- }
- //头等舱
- if (_EnterExitCosts.SumTDC == 1)
- {
- subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
- totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
- }
- //TotalLabel
- dic.Add("TotalLabel", totalLabel);
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- Bookmark bookmark = doc.Range.Bookmarks[key];
- if (bookmark != null)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- }
- #endregion
- //文件名
- string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
- strFileName = CommonFun.ValidFileName(strFileName);
- AsposeHelper.removewatermark_v2180();
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- string returnCodeLabel = string.Empty;
- if (nationalTravelFeeData.Any())
- {
- List<string> list = new List<string>();
- foreach (var item in nationalTravelFeeData)
- {
- list.Add($"{item.Country}({item.City})");
- }
- list = list.Distinct().ToList();
- returnCodeLabel = string.Join("-", list).TrimEnd('-');
- }
- var countryLabel = string.Empty;
- var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
- if (countryData.Any())
- {
- countryLabel = string.Join("、", countryData);
- }
- dic.Add("ReturnCodeAir", returnCodeLabel);
- dic.Add("VisitStartDate", "-");
- dic.Add("VisitEndDate", "-");
- dic.Add("Day", "-");
- dic.Add("VisitCountry", countryLabel);
- dic.Add("ClientUnit", "-");
- //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
- //dic.Add("Names", Names);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- decimal dac1totalPrice = 0.00M;
- int accommodationStartIndex = 6, foodandotherStartIndex = 22;
- foreach (var dac in dac1)
- {
- if (dac.SubTotal == 0.00M)
- {
- continue;
- }
- //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
- //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
- builder.MoveToCell(0, accommodationStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, accommodationStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
- builder.Write(currency);//币种
- builder.MoveToCell(0, accommodationStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, accommodationStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, accommodationStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, accommodationStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, accommodationStartIndex, 7, 0);
- decimal rate = 0.00M;
- rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, accommodationStartIndex, 8, 0);
- decimal rbmPrice = dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- accommodationStartIndex++;
- dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
- }
- dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
- {
- table1.Rows.RemoveAt(i - 1);
- foodandotherStartIndex--;
- }
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- decimal dac2totalPrice = 0.00M;
- foreach (var dac in dac2)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
- builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
- builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
- builder.Write(currency);//币种
- builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
- decimal rate = 0.00M;
- rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
- decimal rbmPrice = dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- foodandotherStartIndex++;
- dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
- }
- dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
- for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
- {
- table1.Rows.RemoveAt(i - 1);
- }
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- string otherFeeStr = "";
- if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
- if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
- if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
- #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
- foreach (var otherInfo in dac5)
- {
- otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
- }
- #endregion
- if (otherFeeStr.Length > 0)
- {
- otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
- otherFeeStr = $"({otherFeeStr})";
- dic.Add("OtherFeeStr", otherFeeStr);
- }
- //总计
- decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
- //国际旅费
- string outsideAir = string.Empty;
- string allPriceAir = string.Empty;
- if (_EnterExitCosts.SumJJC == 1)
- {
- outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
- allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
- }
- if (_EnterExitCosts.SumGWC == 1)
- {
- outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
- allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
- }
- if (_EnterExitCosts.SumTDC == 1)
- {
- outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
- allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
- }
- dic.Add("InTravelPrice", $"({outsideAir})");
- dic.Add("FinalSumPrice", $"({allPriceAir})");
- //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
- //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
- //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
- strFileName = CommonFun.ValidFileName(strFileName);
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(tempPath);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- string returnCodeLabel = string.Empty;
- if (nationalTravelFeeData.Any())
- {
- List<string> list = new List<string>();
- foreach (var item in nationalTravelFeeData)
- {
- list.Add($"{item.Country}({item.City})");
- }
- list = list.Distinct().ToList();
- returnCodeLabel = string.Join("-", list).TrimEnd('-');
- }
- var countryLabel = string.Empty;
- var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
- if (countryData.Any())
- {
- countryLabel = string.Join("、", countryData);
- }
- dic.Add("ReturnCodeAir", returnCodeLabel);
- dic.Add("VisitStartDate", "-");
- dic.Add("VisitEndDate", "-");
- dic.Add("Day", "0");
- dic.Add("VisitCountry", countryLabel);
- dic.Add("ClientUnit", "-");
- designer.SetDataSource("ClientUnit", "-");
- designer.SetDataSource("VisitCountry", countryLabel);
- designer.SetDataSource("Group", "-");
- designer.SetDataSource("ClientUnitTitle", "-");
- designer.SetDataSource("Name", "-");
- designer.SetDataSource("VisitStartDate", "-");
- designer.SetDataSource("Day", "0");
- designer.SetDataSource("ReturnCode", returnCodeLabel);
- designer.SetDataSource("ReturnCodeAir", "-");
- int startIndex = 10;
- const int startIndexcopy = 10;
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- DataTable dtdac1 = new DataTable();
- List<string> place = new List<string>();
- dtdac1.Columns.AddRange(new DataColumn[] {
- new DataColumn(){ ColumnName = "city"},
- new DataColumn(){ ColumnName = "curr"},
- new DataColumn(){ ColumnName = "criterion"},
- new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
- new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
- new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
- });
- DataTable dtdac2 = new DataTable();
- dtdac2.Columns.AddRange(new DataColumn[] {
- new DataColumn(){ ColumnName = "city"},
- new DataColumn(){ ColumnName = "curr"},
- new DataColumn(){ ColumnName = "criterion"},
- new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
- new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
- new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
- });
- dtdac1.TableName = "tb1";
- dtdac2.TableName = "tb2";
- decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
- foreach (var item in dac1)
- {
- item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
- if (place.Contains(item.Place))
- {
- continue;
- }
- DataRow row = dtdac1.NewRow();
- row["city"] = item.Place;
- string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- row["curr"] = currency;
- row["rate"] = rate.ToString("#0.0000");
- row["criterion"] = item.Cost.ToString("#0.00");
- row["number"] = 1;
- row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
- //row["costRMB"] = rbmPrice;
- dtdac1.Rows.Add(row);
- place.Add(item.Place);
- }
- place = new List<string>();
- foreach (var item in dac2)
- {
- item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
- if (place.Contains(item.Place))
- {
- continue;
- }
- DataRow row = dtdac2.NewRow();
- row["city"] = item.Place;
- string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
- decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
- row["curr"] = currency;
- row["rate"] = rate.ToString("#0.0000");
- row["criterion"] = item.Cost.ToString("#0.00");
- row["number"] = 1;
- row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
- //row["cost"] = item.SubTotal;
- //row["costRMB"] = rbmPrice;
- dtdac2.Rows.Add(row);
- place.Add(item.Place);
- //dac2totalPrice += rbmPrice;
- }
- dac1totalPrice = dac1.Sum(it => it.SubTotal);
- dac2totalPrice = dac2.Sum(it => it.SubTotal);
- designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- designer.SetDataSource("dac2totalPrice", dac2totalPrice);
- designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
- designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
- string cell4Str1 = string.Empty;
- if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
- if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
- if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
- string cell4Str = $" 4.国际旅费:{cell4Str1}";
- string cellStr = $" 5.其他费用(";
- if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
- if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
- if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
- if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
- if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
- if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
- #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
- var otherPriceTotal = dac5.Sum(x => x.SubTotal);
- foreach (var otherInfo in dac5)
- {
- cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
- }
- #endregion
- if (cellStr.Length > 8)
- {
- cellStr = cellStr.Substring(0, cellStr.Length - 1);
- }
- cellStr += ")";
- decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
- decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
- decimal pxFee = dac4.Sum(it => it.Cost);
- decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
- string celllastStr1 = "";
- if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
- if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
- if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
- celllastStr1 += $",国际旅费 元";
- if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
- string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
- designer.SetDataSource("cell4Str", cell4Str);
- designer.SetDataSource("cellStr", cellStr);
- designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
- designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
- designer.SetDataSource("celllastStr", celllastStr);
- Workbook wb = designer.Workbook;
- var sheet = wb.Worksheets[0];
- //绑定datatable数据集
- designer.SetDataSource(dtdac1);
- designer.SetDataSource(dtdac2);
- designer.Process();
- var rowStart = dtdac1.Rows.Count;
- while (rowStart > 0)
- {
- sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
- sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
- startIndex++;
- rowStart--;
- }
- sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
- startIndex += 1; //总计行
- rowStart = dtdac2.Rows.Count;
- while (rowStart > 0)
- {
- sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
- sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
- startIndex++;
- rowStart--;
- }
- sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
- wb.CalculateFormula(true);
- //模板文件名
- string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("GroupName", "-");
- dic.Add("ClientUnit", "-");
- //string missionLeader = ""; //团负责人默认接团客户名单第一个人
- //string missionLeaderJob = "";//负责人job
- //int groupNumber = 0; //团人数
- dic.Add("MissionLeader", "-"); //团负责人
- dic.Add("MissionLeaderJob", "-"); //团负责人job
- dic.Add("GroupNumber", "0"); //团人数
- dic.Add("Day", "0");
- dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
- // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
- dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
- decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
- dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
- decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
- dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
- decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
- dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
- decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
- dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
- //其他费用
- decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
- dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
- //其他费用合计
- decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
- decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
- decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
- //公务舱合计
- //国际旅费
- //string outsideJJ = "";
- //string allPriceJJ = "";
- if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
- {
- dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
- dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
- }
- if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
- {
- dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
- dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
- }
- if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
- {
- string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
- dic.Add("AirFeeTotal", airFeeTotalStr);
- string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
- dic.Add("FeeTotal", feeTotalStr);
- }
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
- strFileName = CommonFun.ValidFileName(strFileName);
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
- else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
- }
- }
- else if (dto.ExportType == 2) //表格
- {
- return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
- }
- else if (dto.ExportType == 3)
- {
- return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
- }
- return Ok(JsonView(400, "只可导出明细表!", ""));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(400, ex.Message, ""));
- }
- }
- /// <summary>
- /// 获取三公费用标准city
- /// </summary>
- /// <param name="placeData"></param>
- /// <param name="nationalTravelFeeId"></param>
- /// <returns></returns>
- private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
- {
- string _city = string.Empty;
- if (!placeData.Any()) return _city;
- var data = placeData.Find(it => it.Id == nationalTravelFeeId);
- if (data == null) return _city;
- string country = data.Country;
- string city = data.City;
- if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
- else _city = city;
- return _city;
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 一键清空
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
- {
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
- if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
- var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
- if (_view.Code == 0)
- {
- return Ok(JsonView(true, "操作成功"));
- }
- return Ok(JsonView(false, "操作失败"));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 子项删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
- {
- var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "操作成功!", data.Data));
- }
- /// <summary>
- /// 三公其他费用草稿 删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
- public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
- {
- var jw = JsonView(false, "删除失败!");
- var data = new Grp_DayOtherPriceDraft()
- {
- Id = dto.Id,
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
- };
- var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
- if (del > 0)
- {
- jw.Code = 200;
- jw.Msg = "删除成功!";
- }
- return Ok(jw);
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> EnterExitCostDraftImportDataInit()
- {
- var jw = JsonView(false);
- var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
- var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
- jw.Code = StatusCodes.Status200OK;
- jw.Msg = "操作成功!";
- jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
- return Ok(jw);
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
- {
- int userId = dto.UserId,
- portId = dto.PortType,
- groupId = dto.GroupId,
- draftId = dto.DraftId;
- _portTypeData.Add(1);
- if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
- if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
- if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
- _sqlSugar.BeginTran();
- try
- {
- var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
- if (draftDatas == null)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "草稿数据为空,不可导入!"));
- }
- //验证可覆盖已有数据 两边创建人需为同一人;
- int draftCreateUserId = draftDatas.CreateUserId,
- formalCreateUserId = 0;
- var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
- if (formalData != null)
- {
- formalCreateUserId = formalData.CreateUserId;
- if (draftCreateUserId != formalCreateUserId)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
- }
- }
- //默认添加查看、编辑权限(创建人、自己)
- await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
- var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
- var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
- var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
- newExterData.DiId = groupId;
- newExterData.CreateUserId = userId;
- newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
- var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
- if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
- var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
- if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
- var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
- //数据如果存在执行删除
- if (enterExitCostInfo != null)
- {
- _sqlSugar.Updateable<Grp_EnterExitCost>()
- .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
- .Where(x => x.Id == enterExitCostInfo.Id)
- .ExecuteCommand();
- _sqlSugar.Updateable<Grp_DayAndCost>()
- .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
- .Where(x => x.DiId == groupId)
- .ExecuteCommand();
- _sqlSugar.Updateable<Grp_DayOtherPrice>()
- .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
- .Where(x => x.Diid == groupId)
- .ExecuteCommand();
- _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
- .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
- .Where(x => x.GroupId == groupId)
- .ExecuteCommand();
- }
- //执行insert
- var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
- if (insertId < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "草稿数据导入失败!"));
- }
- if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
- if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
- #region 默认添加权限
- #endregion
- _sqlSugar.CommitTran();
- //执行操作之后
- //生成默认文件pdf并且通知人员
- var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
- {
- DiId = groupId,
- ExportType = 1,
- SubTypeId = 1005
- }, "pdf");
- //发送通知
- string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
- string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
- string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
- //汇率信息记录
- await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
- return Ok(JsonView(true));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- }
- #endregion
- #region 团组经理模块 出入境费用 移动端(Android/IOS)
- /// <summary>
- /// 获取币种基础数据(含逻辑处理)
- /// </summary>
- /// <returns></returns>
- private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
- {
- return await GeneralMethod.EnterExitCostInitRate();
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
- {
- //验证城市归属并给默认值
- int provinceId = dto.ProvinceId;
- if (provinceId < 1) provinceId = 122;
- var dataSource = await _sqlSugar
- .Queryable<Sys_SetData>()
- .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
- .ToListAsync();
- var fileTypes = new List<EecSetDataInfoView>();
- //三公费用-Word明细类型
- var wordTypeData = dataSource
- .Where(it => it.STid == 72)
- .Select(x => new EecSetDataInfoView
- {
- ParentId = 1,
- Id = x.Id,
- Name = x.Name
- })
- .ToArray();
- if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
- var excelTypeData = dataSource
- .Where(it => it.STid == 73)
- .Select(x => new EecSetDataInfoView
- {
- ParentId = 2,
- Id = x.Id,
- Name = x.Name
- })
- .ToArray();
- if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
- var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
- fileTypes.Add(groupNameList);
- fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
- //默认币种显示
- var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
- var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
- return Ok(JsonView(true, "查询成功!", new
- {
- FileTypeData = fileTypes,
- CurrencyInit = _currencyInfos,
- viewPermissionData = viewPermissionData
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- RefAsync<int> total = 0;
- int diId = 0;
- var status = int.TryParse(dto.GroupName, out diId);
- var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
- var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
- .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
- .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
- .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
- .OrderByDescending(x => x.VisitStartDate)
- .Select(x => new EnterExitCostMobileGroupView()
- {
- Id = x.Id,
- GroupName = x.TeamName,
- IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
- IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
- ProvinceId = x.CityId
- })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- //处理省份Id
- if (data.Any())
- {
- var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
- if (provCityDatas.Any())
- {
- foreach (var item in data)
- {
- var provinceId = item.ProvinceId;
- var isDefualtVal = true;
- if (provinceId > 0)
- {
- var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
- if (parentId != null)
- {
- isDefualtVal = false;
- item.ProvinceId = (int)parentId;
- }
- }
- if (isDefualtVal)
- {
- item.ProvinceId = 122; //默认四川
- }
- }
- }
- }
- //处理是否显示
- if (basicUserId.Any(x => x.Id == dto.CurrUserId))
- {
- foreach (var item in data)
- {
- item.IsView = true;
- }
- }
- return Ok(JsonView(true, "查询成功!", data, total));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- RefAsync<int> total = 0;
- var data = await _sqlSugar.Queryable<Sys_SetData>()
- .Where(x => x.IsDel == 0 && x.STid == 66)
- .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
- .Select(x => new
- {
- id = x.Id,
- name = x.Name,
- remark = x.Remark,
- })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, "查询成功!", data, total));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
- if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
- var groupOtherRateData = groupRateData.TeamRates;
- var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
- if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
- var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
- groupOtherRateData = groupOtherRateData
- .Select(x => new TeamRateDescAddCurrencyIdView
- {
- CurrencyId = x.CurrencyId,
- CurrencyName = x.CurrencyName,
- CurrencyCode = x.CurrencyCode,
- Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
- }).ToList();
- var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
- return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
- var tipsData = new List<int>() { 1, 2, 3 };
- if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
- if (dto.TipsType == 1)
- {
- return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
- }
- else if (dto.TipsType == 2)
- {
- var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
- return Ok(JsonView(true, "查询成功!", visaData.Data));
- }
- else if (dto.TipsType == 3)
- {
- var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
- return Ok(JsonView(true, "查询成功!", airData));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准-移动端 List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
- {
- Stopwatch sw = new Stopwatch();
- sw.Start();
- int provinceId = dto.ProvinceId;
- if (provinceId < 1) provinceId = 122; // 默认四川
- RefAsync<int> total = 0;
- var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
- .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
- .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
- .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
- .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
- .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
- .Select((ntf, sd, u, sd1) => new
- {
- Id = ntf.Id,
- Area = $"{ntf.Country}-{ntf.City}",
- Currency = ntf.Currency,
- CurrencyCode = sd.Name,
- CurrencyName = sd.Remark,
- RoomCost = ntf.RoomCost,
- FoodCost = ntf.FoodCost,
- PublicCost = ntf.PublicCost,
- TrainCost = ntf.TrainCost,
- LastUpdateUserId = ntf.LastUpdateUserId,
- LastUpdateUserName = u.CnName,
- LastUpdateTime = ntf.LastUpdateTime
- })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- sw.Stop();
- return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - Info
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
- return Ok(data);
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - ParentInfo
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
- var mobileInfo = new EnterExitCostMobileParentInfoView();
- mobileInfo.DiId = dto.DiId;
- mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
- if (eecInfo == null) return Ok(mobileInfo);
- //验证查看权限
- (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
- if (!isView) return Ok(JsonView(false, "没有查看权限!"));
- mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
- mobileInfo.IsAssignPerm = isSet;
- var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
- .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
- {
- SubId = dac.Id,
- DiId = dac.DiId,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToList();
- mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
- mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
- mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
- mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
- mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
- mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
- mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
- mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
- mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
- //其他款项
- var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
- .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
- .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
- .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
- .OrderBy((dop, sd1, sd2) => dop.Index)
- .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
- {
- SubId = dop.Id,
- DiId = dop.Diid,
- Index = dop.Index,
- SetDataId = dop.SetDataId,
- SetDataName = sd1.Name,
- Cost = dop.Cost,
- Currency = dop.Currency,
- CurrencyName = sd2.Remark,
- SubTotal = dop.SubTotal,
- Remark = dop.Remark,
- })
- .ToArray();
- mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
- return Ok(mobileInfo);
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 查看权限用户
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
- {
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- //验证查看权限
- (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
- if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
- var userIds = await _sqlSugar
- .Queryable<Grp_EnterExitCostPermission>()
- .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
- .Select(x => x.UserId)
- .ToArrayAsync();
- var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
- var perUsersView = new List<dynamic>();
- foreach (var item in perUsers)
- {
- bool isView1 = false;
- if (userIds.Any(x => x == item.Id)) isView1 = true;
- perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
- }
- return Ok(JsonView(perUsersView));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - SubInfo
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
- if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
- //验证查看权限
- //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
- //if (!isView) return Ok(JsonView(false, msg));
- var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
- if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
- var subType = dto.SubType;
- if (subType == 1) //1:境内费用
- {
- var oneData = new ChoiceOneMobileSubInfoView()
- {
- Id = eecInfo.Id,
- ChoiceOne = eecInfo.ChoiceOne,
- ChoiceOneTotalCost = eecInfo.InsidePay,
- Visa = eecInfo.Visa,
- VisaRemark = eecInfo.VisaRemark,
- YiMiao = eecInfo.YiMiao,
- HeSuan = eecInfo.HeSuan,
- Service = eecInfo.Service,
- Ticket = eecInfo.Ticket,
- Safe = eecInfo.Safe,
- FirstItemRemark = eecInfo.FirstItemRemark
- };
- return Ok(JsonView(oneData));
- }
- else if (subType == 2) //2:国际旅费
- {
- var twoData = new ChoiceTwoMobileSubInfoView()
- {
- Id = eecInfo.Id,
- ChoiceTwoJJ = eecInfo.SumJJC,
- OutsideJJPay = eecInfo.OutsideJJPay,
- ChoiceTwoGW = eecInfo.SumGWC,
- OutsideGWPay = eecInfo.OutsideGWPay,
- ChoiceTwoTD = eecInfo.SumTDC,
- OutsideTDPay = eecInfo.OutsideTDPay,
- AirJJ = eecInfo.AirJJ,
- AirGW = eecInfo.AirGW,
- AirTD = eecInfo.AirTD,
- CityTranffic = eecInfo.CityTranffic,
- TwoItemRemark = eecInfo.TwoItemRemark
- };
- return Ok(JsonView(twoData));
- }
- else if (subType == 3) //3:住宿费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
- .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
- {
- SubId = dac.Id,
- DiId = dac.DiId,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceThree,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 4) //4:伙食费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
- .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
- {
- SubId = dac.Id,
- DiId = dac.DiId,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceFour,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 5) //5:公杂费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
- .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
- {
- SubId = dac.Id,
- DiId = dac.DiId,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceFive,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 6) //6:培训费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
- .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
- {
- SubId = dac.Id,
- DiId = dac.DiId,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceSix,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 7) //7:其他
- {
- //其他款项
- var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
- .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
- .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
- .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
- .OrderBy((dop, sd1, sd2) => dop.Index)
- .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
- {
- SubId = dop.Id,
- DiId = dop.Diid,
- Index = dop.Index,
- SetDataId = dop.SetDataId,
- SetDataName = sd1.Name,
- Cost = dop.Cost,
- Currency = dop.Currency,
- CurrencyName = sd2.Name,
- SubTotal = dop.SubTotal,
- Remark = dop.Remark,
- })
- .ToArray();
- var data = new ChoiceSevenMobileSubInfoView()
- {
- ParentId = eecInfo.Id,
- OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
- OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
- Details = otherData
- };
- return Ok(JsonView(data));
- }
- return Ok(JsonView(false));
- }
- #region op
- /// <summary>
- /// 移动端更新费用消息通知
- /// </summary>
- /// <param name="diid"></param>
- /// <param name="id"></param>
- /// <param name="currUserId"></param>
- private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
- {
- try
- {
- ////生成默认文件pdf并且通知人员
- //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
- //{
- // DiId = diid,
- // ExportType = 1,
- // SubTypeId = 1005
- //}, "pdf");
- ////发送通知
- //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
- //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
- //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
- //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
- ////汇率信息记录
- //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
- }
- catch (Exception ex)
- {
- //记录日志
- throw;
- }
- }
- /// <summary>
- /// 验证出入境费用数据是否存在
- /// 不存在添加
- /// </summary>
- /// <param name="diId"></param>
- /// <param name="currUserId"></param>
- /// <returns></returns>
- /// <exception cref="CustomException"></exception>
- private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
- {
- var parentId = 0;
- var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
- if (info != null)
- {
- parentId = info.Id;
- }
- else
- {
- var currencys = await EnterExitCostMobileGetCurrencyInit();
- int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
- if (addId < 1) throw new CustomException("出入境费用添加失败!");
- parentId = addId;
- }
- return parentId;
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 设置view权限
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
- {
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
- //验证编辑权限
- //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
- //if (!isEdit) return Ok(JsonView(false, msg));
- var permissions = new List<Grp_EnterExitCostPermission>();
- foreach (var userId in dto.UserIds)
- {
- permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
- }
- if (permissions.Any())
- {
- if (!permissions.Any(x => x.UserId == dto.CurrUserId))
- {
- permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
- }
- _sqlSugar.BeginTran();
- await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
- var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
- if (result < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false));
- }
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
- var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
- int id = dto.Id;
- if (id <= 0) //add
- {
- //int provinceId = dto.ProvinceId;
- int groupId = dto.DiId;
- //if (provinceId < 1) provinceId = 122;
- var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
- var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- id = add;
- }
- else //update
- {
- ////验证编辑权限
- //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
- //if (!isEdit) return Ok(JsonView(false, msg));
- var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- #region 汇率变更时更改币种相关费用
- var opDayCosts = new List<Grp_DayAndCost>();
- var opDayOtherCosts = new List<Grp_DayOtherPrice>();
- var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
- var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
- .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
- .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
- .Select((dac, sd) => new
- {
- dac.Id,
- dac.DiId,
- CurrencyCode = sd.Name,
- dac.Cost
- })
- .ToList();
- var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
- .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
- .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
- .Select((dop, sd) => new
- {
- dop.Id,
- dop.Diid,
- CurrencyCode = sd.Name,
- dop.Cost
- })
- .ToList();
- if (dayCosts.Count > 0)
- {
- var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
- foreach (var dc in new_dayCosts)
- {
- var thisCurrency = dc.Key.ToUpper();
- var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
- if (thisRate == 0.00M) continue;
- foreach (var dcSub in dc)
- {
- opDayCosts.Add(new Grp_DayAndCost()
- {
- Id = dcSub.Id,
- DiId = dcSub.DiId,
- Cost = dcSub.Cost,
- SubTotal = dcSub.Cost * thisRate,
- Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
- });
- }
- }
- if (opDayCosts.Count > 0)
- {
- await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
- }
- }
- if (dayOtherCosts.Count > 0)
- {
- var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
- foreach (var dc in new_dayOtherCosts)
- {
- var thisCurrency = dc.Key.ToUpper();
- var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
- if (thisRate == 0.00M) continue;
- foreach (var dcSub in dc)
- {
- opDayOtherCosts.Add(new Grp_DayOtherPrice()
- {
- Id = dcSub.Id,
- Diid = dcSub.Diid,
- Cost = dcSub.Cost,
- SubTotal = dcSub.Cost * thisRate,
- // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
- });
- }
- }
- if (opDayOtherCosts.Count > 0)
- {
- await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
- }
- }
- #endregion
- //消息通知
- await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- //汇率信息记录
- await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
- return Ok(JsonView(new { parentId = id }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
- var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
- int id = dto.Id;
- if (id <= 0) //add
- {
- checkboxInfo.CreateUserId = dto.CurrUserId;
- checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- else //update
- {
- ////验证编辑权限
- //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
- //if (!isEdit) return Ok(JsonView(false, msg));
- var upd = await _sqlSugar.Updateable(checkboxInfo)
- .UpdateColumns(x => new
- {
- x.ChoiceOne,
- x.ChoiceTwo,
- x.SumJJC,
- x.SumGWC,
- x.SumTDC,
- x.ChoiceThree,
- x.ChoiceFour,
- x.ChoiceFive,
- x.ChoiceSix,
- x.OtherExpenses_Checked
- })
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- return Ok(JsonView(new { parentId = id }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
- {
- int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
- // if (provinceId < 1) provinceId = 122;
- var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
- var checkboxInfo = new Grp_EnterExitCost()
- {
- Id = id,
- //ProvinceId = provinceId,
- DiId = diId,
- CreateUserId = currUserId
- };
- if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
- else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
- else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
- else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
- else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
- if (id <= 0) //add
- {
- checkboxInfo.CreateUserId = dto.CurrUserId;
- checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- else //update
- {
- ////验证编辑权限
- //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
- //if (!isEdit) return Ok(JsonView(false, msg));
- var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
- .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
- .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
- .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
- .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
- .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- return Ok(JsonView(new { parentId = id }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
- var info = _mapper.Map<Grp_EnterExitCost>(dto);
- info.FirstItemRemark = dto.FirstItemRemark;
- info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
- int id = dto.Id;
- if (id <= 0) //add
- {
- info.CreateUserId = dto.CurrUserId;
- info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
- if (add < 1) return Ok(JsonView(false));
- id = add;
- }
- else //update
- {
- ////验证编辑权限
- //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
- //if (!isEdit) return Ok(JsonView(false, msg));
- var upd = await _sqlSugar.Updateable(info)
- .UpdateColumns(x => new
- {
- x.ChoiceOne,
- x.InsidePay,
- x.VisaRemark,
- x.Visa,
- x.Service,
- x.Safe,
- x.Ticket,
- x.HeSuan,
- x.YiMiao,
- x.FirstItemRemark
- })
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- //消息通知
- await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
- var info = _mapper.Map<Grp_EnterExitCost>(dto);
- info.DiId = dto.DiId;
- //info.ProvinceId = dto.ProvinceId;
- info.OutsideJJPay = dto.OutsideJJPay;
- info.OutsideGWPay = dto.OutsideGWPay;
- info.OutsideTDPay = dto.OutsideTDPay;
- info.AirJJ = dto.AirJJ;
- info.AirGW = dto.AirGW;
- info.AirTD = dto.AirTD;
- info.CityTranffic = dto.CityTranffic;
- info.TwoItemRemark = dto.TwoItemRemark;
- info.SumJJC = dto.ChoiceTwoJJ;
- info.SumGWC = dto.ChoiceTwoGW;
- info.SumTDC = dto.ChoiceTwoTD;
- int id = dto.Id;
- decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
- if (id <= 0) //add
- {
- info.CreateUserId = dto.CurrUserId;
- info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
- if (addId <= 0) return Ok(JsonView(false));
- id = addId;
- }
- else //update
- {
- ////验证编辑权限
- //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
- //if (!isEdit) return Ok(JsonView(false, msg));
- var upd = await _sqlSugar.Updateable(info)
- .UpdateColumns(x => new
- {
- x.SumJJC,
- x.OutsideJJPay,
- x.SumGWC,
- x.OutsideGWPay,
- x.SumTDC,
- x.OutsideTDPay,
- x.AirJJ,
- x.AirGW,
- x.AirTD,
- x.CityTranffic,
- x.TwoItemRemark
- })
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- jjcItemTotal = info.AirJJ + info.CityTranffic;
- gwcItemTotal = info.AirGW + info.CityTranffic;
- tdcItemTotal = info.AirTD + info.CityTranffic;
- //消息通知
- await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new
- {
- parentId = id,
- choiceTwoJJ = dto.ChoiceTwoJJ,
- jjcItemTotal = jjcItemTotal,
- choiceTwoGW = dto.ChoiceTwoGW,
- gwcItemTotal = gwcItemTotal,
- choiceTwoTD = dto.ChoiceTwoTD,
- tdcItemTotal = tdcItemTotal
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ApiExplorerSettings(IgnoreApi = true)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
- var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
- if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
- var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
- var infos = infos1.Select(x => new Grp_DayAndCost
- {
- Id = x.Id,
- DiId = dto.DiId,
- Type = dto.FeeType,
- Days = x.Days,
- NationalTravelFeeId = x.NationalTravelFeeId,
- Cost = x.Cost,
- Currency = x.Currency,
- SubTotal = x.SubTotal,
- CreateUserId = dto.CurrUserId
- })
- .ToList();
- var adds = infos.Where(x => x.Id <= 0).ToList();
- var upds = infos.Where(x => x.Id > 0).ToList();
- if (adds.Count > 0)
- {
- var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- if (upds.Count > 0)
- {
- var upd = await _sqlSugar.Updateable(adds)
- .UpdateColumns(x => new
- {
- x.Days,
- x.NationalTravelFeeId,
- x.Cost,
- x.Currency,
- x.SubTotal
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
- //消息通知
- var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
- await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new { itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
- {
- var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
- int subId = dto.SubId, feeType = dto.FeeType;
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
- var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
- subInfo.Id = subId;
- subInfo.DiId = dto.DiId;
- if (feeType == 3) subInfo.Type = 1;
- else if (feeType == 4) subInfo.Type = 2;
- else if (feeType == 5) subInfo.Type = 3;
- else if (feeType == 6) subInfo.Type = 4;
- subInfo.CreateUserId = dto.CurrUserId;
- int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
- if (parentId < 1) return Ok(JsonView(false));
- //子表op
- if (subId < 1)
- {
- var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
- if (subAdd < 1) return Ok(JsonView(false));
- }
- else
- {
- ////验证编辑权限
- //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
- //if (!isEdit) return Ok(JsonView(false, msg));
- var subUpd = await _sqlSugar.Updateable(subInfo)
- .UpdateColumns(x => new
- {
- x.Days,
- x.NationalTravelFeeId,
- x.Cost,
- x.Currency,
- x.SubTotal
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (subUpd < 1) return Ok(JsonView(false));
- }
- var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
- await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
- return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ApiExplorerSettings(IgnoreApi = true)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
- var infos = infos1.Select(x => new Grp_DayOtherPrice()
- {
- Id = x.Id,
- Diid = dto.DiId,
- SetDataId = x.SetDataId,
- Index = x.Index,
- Cost = x.Cost,
- Currency = x.Currency,
- SubTotal = x.SubTotal,
- CreateUserId = dto.CurrUserId,
- Remark = x.Remark
- }).ToList();
- var adds = infos.Where(x => x.Id <= 0).ToList();
- var upds = infos.Where(x => x.Id > 0).ToList();
- if (adds.Count > 0)
- {
- var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- if (upds.Count > 0)
- {
- var upd = await _sqlSugar.Updateable(adds)
- .UpdateColumns(x => new
- {
- x.Index,
- x.SetDataId,
- x.Cost,
- x.Currency,
- x.SubTotal,
- x.Remark
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
- //消息通知
- var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
- await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new { itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
- {
- int subId = dto.SubId;
- int diId = dto.Diid;
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
- subInfo.Id = subId;
- subInfo.Diid = dto.Diid;
- subInfo.CreateUserId = dto.CurrUserId;
- int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
- if (parentId < 1) return Ok(JsonView(false));
- #region 子表op
- if (subId < 1)//add
- {
- var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
- if (subAdd < 1) return Ok(JsonView(false));
- }
- else //upd
- {
- ////验证编辑权限
- //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
- //if (!isEdit) return Ok(JsonView(false, msg));
- var subUpd = await _sqlSugar.Updateable(subInfo)
- .UpdateColumns(x => new
- {
- x.Index,
- x.SetDataId,
- x.Cost,
- x.Currency,
- x.SubTotal,
- x.Remark
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (subUpd < 1) return Ok(JsonView(false));
- }
- #endregion
- var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
- //消息通知
- await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
- return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
- {
- var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "操作成功!", data.Data));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-移动端 - 其他费用删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
- {
- var data = new Grp_DayOtherPrice()
- {
- Id = dto.Id,
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
- };
- var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
- if (del > 0) return Ok(JsonView(true, "删除成功!"));
- return Ok(JsonView(false, "删除失败!"));
- }
- #endregion
- #endregion
- #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
- /// <summary>
- /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
- {
- var provData = await _groupRepository.ProvinceBasicSource();
- return Ok(JsonView(true, "查询成功!", provData));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- RefAsync<int> total = 0;
- var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
- .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
- .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
- .Select(x => new
- {
- Id = x.Id,
- DraftName = x.DraftName,
- IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
- .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
- .Any()
- })
- .OrderByDescending(x => x.Id)
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, "查询成功!", data, total));
- }
- /// <summary>
- /// 出入境费用-草稿 移动端
- /// 获取币种基础数据(含逻辑处理)
- /// </summary>
- /// <returns></returns>
- private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
- {
- return await GeneralMethod.EnterExitCostInitRate();
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
- {
- //验证城市归属并给默认值
- int provinceId = dto.ProvinceId;
- if (provinceId < 1) provinceId = 122;
- var dataSource = await _sqlSugar
- .Queryable<Sys_SetData>()
- .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
- .ToListAsync();
- //三公费用-Word明细类型
- var wordTypeData = dataSource.Where(it => it.STid == 72)
- .Select(x => new SetDataInfoView
- {
- Id = x.Id,
- Name = x.Name,
- Remark = x.Remark
- })
- .ToList();
- //三公费用-Excel明细类型
- var excelTypeData = dataSource.Where(it => it.STid == 73)
- .Select(x => new SetDataInfoView
- {
- Id = x.Id,
- Name = x.Name,
- Remark = x.Remark
- })
- .ToList();
- //默认币种显示
- var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
- var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
- return Ok(JsonView(true, "查询成功!", new
- {
- WordTypeData = wordTypeData,
- ExcelTypeData = excelTypeData,
- CurrencyInit = _currencyInfos,
- viewPermissionData = viewPermissionData
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- RefAsync<int> total = 0;
- int diId = 0;
- var status = int.TryParse(dto.GroupName, out diId);
- var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
- .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
- .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
- .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
- .OrderByDescending(x => x.VisitStartDate)
- .Select(x => new
- {
- Id = x.Id,
- GroupName = x.TeamName
- })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, "查询成功!", data, total));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- RefAsync<int> total = 0;
- var data = await _sqlSugar.Queryable<Sys_SetData>()
- .Where(x => x.IsDel == 0 && x.STid == 66)
- .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
- .Select(x => new
- {
- id = x.Id,
- name = x.Name,
- remark = x.Remark,
- })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, "查询成功!", data, total));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
- var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
- if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
- var groupOtherRateData = groupRateData.TeamRates;
- var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
- if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
- var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
- groupOtherRateData = groupOtherRateData
- .Select(x => new TeamRateDescAddCurrencyIdView
- {
- CurrencyId = x.CurrencyId,
- CurrencyName = x.CurrencyName,
- CurrencyCode = x.CurrencyCode,
- Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
- }).ToList();
- var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
- return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
- {
- int portType = dto.PortType;
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- var tipsData = new List<int>() { 1, 2, 3 };
- if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
- if (dto.TipsType == 1)
- {
- return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
- }
- else if (dto.TipsType == 2)
- {
- if (portType == 2)
- {
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
- }
- var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
- .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
- .Select(x => x.NationalTravelFeeId)
- .Distinct()
- .ToListAsync();
- if (portType == 2)
- {
- if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
- }
- var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
- .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
- .Select(x => x.Country)
- .Distinct()
- .ToArrayAsync();
- if (portType == 2)
- {
- if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
- }
- (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
- return Ok(JsonView(true, "查询成功!", new
- {
- totalAmt = totalAmt,
- remark = remark
- }));
- }
- else if (dto.TipsType == 3)
- {
- return Ok(JsonView(false, "暂无机票费用提示信息!"));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 创建
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
- {
- if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.ProvinceId < 1) dto.ProvinceId = 122;
- var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
- if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
- var rateInfos = await EnterExitCostMobileGetCurrencyInit();
- var info = new Grp_EnterExitCostDraft()
- {
- ProvinceId = dto.ProvinceId,
- DraftName = dto.DraftName,
- CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
- CreateUserId = dto.CurrUserId
- };
- _sqlSugar.BeginTran();
- var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
- if (draftId < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "草稿创建失败!"));
- }
- //添加默认权限
- await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
- _sqlSugar.CommitTran();
- (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
- var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
- mobileInfo.Id = draftId;
- mobileInfo.DraftName = dto.DraftName;
- mobileInfo.Currencys = rateInfos;
- mobileInfo.IsAssignPerm = assignPerm;
- return Ok(JsonView(mobileInfo));
- }
- /// <summary>
- /// 出入境费用-草稿-移动端 查看编辑提示消息
- /// </summary>
- private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
- {
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
- var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
- mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
- if (eecInfo == null) return Ok(JsonView(mobileInfo));
- //验证查看编辑权限
- (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
- if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
- mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
- mobileInfo.ProvinceId = eecInfo.ProvinceId;
- mobileInfo.IsAssignPerm = assignPerm;
- var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
- .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
- {
- ParentId = dac.ParentId,
- SubId = dac.Id,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToList();
- mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
- mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
- mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
- mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
- mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
- mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
- mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
- mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
- mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
- //其他款项
- var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
- .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
- .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
- .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
- .OrderBy((dop, sd1, sd2) => dop.Index)
- .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
- {
- ParentId = dop.ParentId,
- SubId = dop.Id,
- Index = dop.Index,
- SetDataId = dop.SetDataId,
- SetDataName = sd1.Name,
- Cost = dop.Cost,
- Currency = dop.Currency,
- CurrencyName = sd2.Remark,
- SubTotal = dop.SubTotal,
- Remark = dop.Remark,
- })
- .ToArray();
- mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
- return Ok(mobileInfo);
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
- if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
- //验证查看编辑权限
- (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
- if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
- var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
- if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
- var subType = dto.SubType;
- if (subType == 1) //1:境内费用
- {
- var oneData = new ChoiceOneMobileSubInfoView()
- {
- Id = eecInfo.Id,
- ChoiceOne = eecInfo.ChoiceOne,
- ChoiceOneTotalCost = eecInfo.InsidePay,
- Visa = eecInfo.Visa,
- VisaRemark = eecInfo.VisaRemark,
- YiMiao = eecInfo.YiMiao,
- HeSuan = eecInfo.HeSuan,
- Service = eecInfo.Service,
- Ticket = eecInfo.Ticket,
- Safe = eecInfo.Safe,
- FirstItemRemark = eecInfo.FirstItemRemark
- };
- return Ok(JsonView(oneData));
- }
- else if (subType == 2) //2:国际旅费
- {
- var twoData = new ChoiceTwoMobileSubInfoView()
- {
- Id = eecInfo.Id,
- ChoiceTwoJJ = eecInfo.SumJJC,
- OutsideJJPay = eecInfo.OutsideJJPay,
- ChoiceTwoGW = eecInfo.SumGWC,
- OutsideGWPay = eecInfo.OutsideGWPay,
- ChoiceTwoTD = eecInfo.SumTDC,
- OutsideTDPay = eecInfo.OutsideTDPay,
- AirJJ = eecInfo.AirJJ,
- AirGW = eecInfo.AirGW,
- AirTD = eecInfo.AirTD,
- CityTranffic = eecInfo.CityTranffic,
- TwoItemRemark = eecInfo.TwoItemRemark
- };
- return Ok(JsonView(twoData));
- }
- else if (subType == 3) //3:住宿费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
- .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
- {
- ParentId = dac.ParentId,
- SubId = dac.Id,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceDraftMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceThree,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 4) //4:伙食费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
- .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
- {
- ParentId = dac.ParentId,
- SubId = dac.Id,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceDraftMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceFour,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 5) //5:公杂费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
- .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
- {
- ParentId = dac.ParentId,
- SubId = dac.Id,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceDraftMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceFive,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 6) //6:培训费
- {
- var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
- .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
- .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
- .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
- .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
- {
- ParentId = dac.ParentId,
- SubId = dac.Id,
- Type = dac.Type,
- Days = dac.Days,
- NationalTravelFeeId = dac.NationalTravelFeeId,
- Arae = $"{ntf.Country}-{ntf.City}",
- Cost = dac.Cost,
- Currency = dac.Currency,
- CurrencyName = sd.Name,
- SubTotal = dac.SubTotal,
- })
- .ToArray();
- var data = new ChoiceDraftMobileSubInfo3To6View()
- {
- ParentId = eecInfo.Id,
- Choice = eecInfo.ChoiceSix,
- TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
- Details = dayAndCostDatas
- };
- return Ok(JsonView(data));
- }
- else if (subType == 7) //7:其他
- {
- //其他款项
- var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
- .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
- .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
- .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
- .OrderBy((dop, sd1, sd2) => dop.Index)
- .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
- {
- ParentId = dop.ParentId,
- SubId = dop.Id,
- Index = dop.Index,
- SetDataId = dop.SetDataId,
- SetDataName = sd1.Name,
- Cost = dop.Cost,
- Currency = dop.Currency,
- CurrencyName = sd2.Name,
- SubTotal = dop.SubTotal,
- Remark = dop.Remark,
- })
- .ToArray();
- var data = new ChoiceSevenDraftMobileSubInfoView()
- {
- ParentId = eecInfo.Id,
- OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
- OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
- Details = otherData
- };
- return Ok(JsonView(data));
- }
- return Ok(JsonView(false));
- }
- #region op
- /// <summary>
- /// 移动端更新费用消息通知
- /// </summary>
- /// <param name="draftId"></param>
- /// <param name="id"></param>
- /// <param name="currUserId"></param>
- private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
- {
- try
- {
- ////生成默认文件pdf并且通知人员
- //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
- //{
- // DiId = draftId,
- // ExportType = 1,
- // SubTypeId = 1005
- //}, "pdf");
- ////发送通知
- //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
- //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
- //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
- //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
- ////汇率信息记录
- //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
- }
- catch (Exception ex)
- {
- //记录日志
- throw;
- }
- }
- /// <summary>
- /// 验证出入境费用数据是否存在
- /// 不存在添加
- /// </summary>
- /// <param name="draftId"></param>
- /// <param name="currUserId"></param>
- /// <returns></returns>
- /// <exception cref="CustomException"></exception>
- private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
- {
- var parentId = 0;
- var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
- if (info != null) parentId = info.Id;
- else
- {
- var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
- int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
- if (addId < 1) throw new CustomException("出入境费用添加失败!");
- parentId = addId;
- }
- return parentId;
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
- {
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- //验证查看权限
- (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
- if (!isView) return Ok(JsonView(false, _viewPermStr));
- var userIds = await _sqlSugar
- .Queryable<Grp_EnterExitCostDraftPermission>()
- .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
- .Select(x => x.UserId)
- .ToArrayAsync();
- var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
- var perUsersView = new List<dynamic>();
- var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
- var viewPermissionData = new List<PermissionViewUserview>();
- if (feeBasePerm.Any())
- {
- foreach (var item in feeBasePerm)
- {
- if (item.Users.Any())
- {
- viewPermissionData.AddRange(item.Users);
- }
- }
- }
- foreach (var item in perUsers)
- {
- bool isView1 = false;
- if (userIds.Any(x => x == item.Id)) isView1 = true;
- else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
- perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
- }
- return Ok(JsonView(perUsersView));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
- {
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
- if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
- //验证查看编辑权限
- (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
- if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
- var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
- foreach (var userId in dto.UserIds)
- {
- permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
- }
- if (permissions.Any())
- {
- if (!permissions.Any(x => x.UserId == dto.CurrUserId))
- {
- permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
- }
- _sqlSugar.BeginTran();
- await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
- var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
- if (result < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false));
- }
- _sqlSugar.CommitTran();
- return Ok(JsonView(true));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
- int id = dto.DraftId;
- if (id <= 0) //add
- {
- if (dto.ProvinceId < 1) dto.ProvinceId = 122;
- var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- id = add;
- }
- else //update
- {
- //验证查看编辑权限
- (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
- if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
- var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- return Ok(JsonView(new { parentId = id }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
- var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
- int id = dto.DraftId;
- if (id <= 0) //add
- {
- if (dto.ProvinceId < 1) dto.ProvinceId = 122;
- var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- id = add;
- }
- else //update
- {
- //验证查看编辑权限
- (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
- if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
- var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- #region 汇率变更时更改币种相关费用
- var opDayCosts = new List<Grp_DayAndCostDraft>();
- var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
- var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
- var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
- .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
- .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
- .Select((dac, sd) => new
- {
- dac.Id,
- dac.ParentId,
- CurrencyCode = sd.Name,
- dac.Cost
- })
- .ToList();
- var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
- .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
- .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
- .Select((dop, sd) => new
- {
- dop.Id,
- dop.ParentId,
- CurrencyCode = sd.Name,
- dop.Cost
- })
- .ToList();
- if (dayCosts.Count > 0)
- {
- var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
- foreach (var dc in new_dayCosts)
- {
- var thisCurrency = dc.Key.ToUpper();
- var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
- if (thisRate == 0.00M) continue;
- foreach (var dcSub in dc)
- {
- opDayCosts.Add(new Grp_DayAndCostDraft()
- {
- Id = dcSub.Id,
- ParentId = dcSub.ParentId,
- Cost = dcSub.Cost,
- SubTotal = dcSub.Cost * thisRate,
- Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
- });
- }
- }
- if (opDayCosts.Count > 0)
- {
- await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
- }
- }
- if (dayOtherCosts.Count > 0)
- {
- var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
- foreach (var dc in new_dayOtherCosts)
- {
- var thisCurrency = dc.Key.ToUpper();
- var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
- if (thisRate == 0.00M) continue;
- foreach (var dcSub in dc)
- {
- opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
- {
- Id = dcSub.Id,
- ParentId = dcSub.ParentId,
- Cost = dcSub.Cost,
- SubTotal = dcSub.Cost * thisRate,
- // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
- });
- }
- }
- if (opDayOtherCosts.Count > 0)
- {
- await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
- }
- }
- #endregion
- ////消息通知
- //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- ////汇率信息记录
- //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
- return Ok(JsonView(new { parentId = id }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
- if (dto.ProvinceId < 1) dto.ProvinceId = 122;
- int id = dto.DraftId;
- if (id <= 0) //add
- {
- checkboxInfo.ProvinceId = dto.ProvinceId;
- checkboxInfo.CreateUserId = dto.CurrUserId;
- checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
- var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- else //update
- {
- var upd = await _sqlSugar.Updateable(checkboxInfo)
- .UpdateColumns(x => new
- {
- x.ChoiceOne,
- x.ChoiceTwo,
- x.SumJJC,
- x.SumGWC,
- x.SumTDC,
- x.ChoiceThree,
- x.ChoiceFour,
- x.ChoiceFive,
- x.ChoiceSix,
- x.OtherExpenses_Checked
- })
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- return Ok(JsonView(new { parentId = id }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
- {
- int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
- var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
- if (dto.ProvinceId < 1) dto.ProvinceId = 122;
- var checkboxInfo = new Grp_EnterExitCostDraft()
- {
- Id = draftId,
- ProvinceId = dto.ProvinceId,
- CreateUserId = currUserId
- };
- if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
- else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
- else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
- else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
- else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
- if (draftId <= 0) //add
- {
- checkboxInfo.CreateUserId = dto.CurrUserId;
- checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- else //update
- {
- var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
- .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
- .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
- .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
- .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
- .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
- .Where(x => x.Id == draftId)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- return Ok(JsonView(new { parentId = draftId }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
- {
- int id = dto.DraftId, currUserId = dto.CurrUserId;
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.ProvinceId < 1) dto.ProvinceId = 122;
- var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
- info.ProvinceId = dto.ProvinceId;
- info.FirstItemRemark = dto.FirstItemRemark;
- info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
- if (id <= 0) //add
- {
- info.CreateUserId = dto.CurrUserId;
- info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
- if (add < 1) return Ok(JsonView(false));
- id = add;
- }
- else //update
- {
- var upd = await _sqlSugar.Updateable(info)
- .UpdateColumns(x => new
- {
- x.ChoiceOne,
- x.InsidePay,
- x.VisaRemark,
- x.Visa,
- x.Service,
- x.Safe,
- x.Ticket,
- x.HeSuan,
- x.YiMiao,
- x.FirstItemRemark
- })
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- ////消息通知
- //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
- {
- int id = dto.DraftId;
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.ProvinceId < 1) dto.ProvinceId = 122;
- var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
- info.ProvinceId = dto.ProvinceId;
- info.OutsideJJPay = dto.OutsideJJPay;
- info.OutsideGWPay = dto.OutsideGWPay;
- info.OutsideTDPay = dto.OutsideTDPay;
- info.AirJJ = dto.AirJJ;
- info.AirGW = dto.AirGW;
- info.AirTD = dto.AirTD;
- info.CityTranffic = dto.CityTranffic;
- info.TwoItemRemark = dto.TwoItemRemark;
- info.SumJJC = dto.ChoiceTwoJJ;
- info.SumGWC = dto.ChoiceTwoGW;
- info.SumTDC = dto.ChoiceTwoTD;
- decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
- if (id <= 0) //add
- {
- info.CreateUserId = dto.CurrUserId;
- info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
- var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
- if (addId <= 0) return Ok(JsonView(false));
- id = addId;
- }
- else //update
- {
- var upd = await _sqlSugar.Updateable(info)
- .UpdateColumns(x => new
- {
- x.SumJJC,
- x.OutsideJJPay,
- x.SumGWC,
- x.OutsideGWPay,
- x.SumTDC,
- x.OutsideTDPay,
- x.AirJJ,
- x.AirGW,
- x.AirTD,
- x.CityTranffic,
- x.TwoItemRemark
- })
- .Where(x => x.Id == id)
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- jjcItemTotal = info.AirJJ + info.CityTranffic;
- gwcItemTotal = info.AirGW + info.CityTranffic;
- tdcItemTotal = info.AirTD + info.CityTranffic;
- ////消息通知
- //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new
- {
- parentId = id,
- choiceTwoJJ = dto.ChoiceTwoJJ,
- jjcItemTotal = jjcItemTotal,
- choiceTwoGW = dto.ChoiceTwoGW,
- gwcItemTotal = gwcItemTotal,
- choiceTwoTD = dto.ChoiceTwoTD,
- tdcItemTotal = tdcItemTotal
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ApiExplorerSettings(IgnoreApi = true)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
- var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
- if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
- var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
- var infos = infos1.Select(x => new Grp_DayAndCostDraft
- {
- Id = x.Id,
- ParentId = dto.DraftId,
- Type = dto.FeeType,
- Days = x.Days,
- NationalTravelFeeId = x.NationalTravelFeeId,
- Cost = x.Cost,
- Currency = x.Currency,
- SubTotal = x.SubTotal,
- CreateUserId = dto.CurrUserId
- })
- .ToList();
- var adds = infos.Where(x => x.Id <= 0).ToList();
- var upds = infos.Where(x => x.Id > 0).ToList();
- if (adds.Count > 0)
- {
- var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- if (upds.Count > 0)
- {
- var upd = await _sqlSugar.Updateable(adds)
- .UpdateColumns(x => new
- {
- x.Days,
- x.NationalTravelFeeId,
- x.Cost,
- x.Currency,
- x.SubTotal
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
- ////消息通知
- //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
- //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new { itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
- {
- var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
- int subId = dto.SubId, feeType = dto.FeeType;
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
- var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
- subInfo.Id = subId;
- subInfo.ParentId = dto.DraftId;
- if (feeType == 3) subInfo.Type = 1;
- else if (feeType == 4) subInfo.Type = 2;
- else if (feeType == 5) subInfo.Type = 3;
- else if (feeType == 6) subInfo.Type = 4;
- subInfo.CreateUserId = dto.CurrUserId;
- int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
- if (parentId < 1) return Ok(JsonView(false));
- //子表op
- if (subId < 1)
- {
- var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
- if (subAdd < 1) return Ok(JsonView(false));
- }
- else
- {
- var subUpd = await _sqlSugar.Updateable(subInfo)
- .UpdateColumns(x => new
- {
- x.Days,
- x.NationalTravelFeeId,
- x.Cost,
- x.Currency,
- x.SubTotal
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (subUpd < 1) return Ok(JsonView(false));
- }
- var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
- return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ApiExplorerSettings(IgnoreApi = true)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
- {
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
- var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
- {
- Id = x.Id,
- ParentId = dto.DraftId,
- SetDataId = x.SetDataId,
- Index = x.Index,
- Cost = x.Cost,
- Currency = x.Currency,
- SubTotal = x.SubTotal,
- CreateUserId = dto.CurrUserId,
- Remark = x.Remark
- }).ToList();
- var adds = infos.Where(x => x.Id <= 0).ToList();
- var upds = infos.Where(x => x.Id > 0).ToList();
- if (adds.Count > 0)
- {
- var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
- if (add < 1) return Ok(JsonView(false));
- }
- if (upds.Count > 0)
- {
- var upd = await _sqlSugar.Updateable(adds)
- .UpdateColumns(x => new
- {
- x.Index,
- x.SetDataId,
- x.Cost,
- x.Currency,
- x.SubTotal,
- x.Remark
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (upd < 1) return Ok(JsonView(false));
- }
- var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
- //消息通知
- //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
- //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
- return Ok(JsonView(new { itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
- {
- int subId = dto.SubId, id = dto.DraftId;
- if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
- if (id < 1) return Ok(JsonView(false, MsgTips.Id));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
- subInfo.Id = subId;
- subInfo.ParentId = id;
- subInfo.CreateUserId = dto.CurrUserId;
- int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
- if (parentId < 1) return Ok(JsonView(false));
- #region 子表op
- if (subId < 1)//add
- {
- var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
- if (subAdd < 1) return Ok(JsonView(false));
- }
- else //upd
- {
- var subUpd = await _sqlSugar.Updateable(subInfo)
- .UpdateColumns(x => new
- {
- x.Index,
- x.SetDataId,
- x.Cost,
- x.Currency,
- x.SubTotal,
- x.Remark
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (subUpd < 1) return Ok(JsonView(false));
- }
- #endregion
- var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
- ////消息通知
- //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
- return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
- {
- var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "操作成功!", data.Data));
- }
- /// <summary>
- /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
- {
- var data = new Grp_DayOtherPriceDraft()
- {
- Id = dto.Id,
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
- };
- var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
- if (del > 0) return Ok(JsonView(true, "删除成功!"));
- return Ok(JsonView(false, "删除失败!"));
- }
- #endregion
- #endregion
- #region 团组经理模块 出入境费用报价表
- /// <summary>
- /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
- {
- var initRates = await GeneralMethod.EnterExitCostInitRate();
- var liveRates = await GeneralMethod.EnterExitCostLiveRate();
- var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
- initRates.Insert(0, cnyInfo);
- liveRates.Insert(0, cnyInfo);
- return Ok(JsonView(true, "查询成功!", new
- {
- InitRates = initRates,
- LiveRates = liveRates
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用报价表 - 报价表名称列表
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
- {
- return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
- }
- /// <summary>
- /// 团组模块 - 出入境费用报价表 - 团组名称列表
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
- {
- return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
- }
- /// <summary>
- /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
- {
- int groupId = dto.DiId,
- currUserId = dto.CurrUserId;
- if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
- if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
- //验证报价数据是否存在
- var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
- if (isNull != null)
- {
- var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
- if (!info1.Rates.Any())
- {
- var rates = await GeneralMethod.EnterExitCostInitRate();
- rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
- info1.Rates = rates.ToArray();
- }
- return Ok(JsonView(info1));
- }
- var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
- result.GroupId = groupId;
- //处理报价名称
- var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
- if (groupInfo != null)
- {
- var visitCountry = groupInfo.VisitCountry;
- if (!string.IsNullOrEmpty(visitCountry))
- {
- string quoteName = string.Empty;
- if (visitCountry.Contains("|"))
- {
- var countrys = visitCountry.Split("|");
- quoteName = string.Join("、", countrys);
- }
- else quoteName = visitCountry;
- quoteName += $"团组报价表";
- result.Name = quoteName;
- }
- }
- var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
- if (info.Code != StatusCodes.Status200OK)
- {
- if (!result.Rates.Any())
- {
- var rates = await GeneralMethod.EnterExitCostInitRate();
- result.Rates = rates.ToArray();
- }
- return Ok(JsonView(true, $"出入境费用明细未填写!", result));
- }
- var infoView = info.Data as EnterExitCostInfoView;
- if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
- var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
- var cityFilter = new List<string>() { "全部城市", "其他城市" };
- var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
- var eecRates = infoView.Currencys;
- //默认添加人名币
- if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
- {
- eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
- }
- //处理团组人数
- int pplNum = 1;
- if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
- var views = new List<QuoteSubItemInfo>();
- #region 数据填充
- var intTravelCosts = new List<QuoteSubItemInfo>();
- #region 机票费用 1354
- int intTravelIndex = 1;
- if (infoView.SumJJC == 1)
- {
- intTravelCosts.Add(new QuoteSubItemInfo
- {
- ItemId = 1354,
- Index = intTravelIndex,
- FeeName = "经济舱",
- UnitPrice = infoView.AirJJ,
- Currency = "CNY",
- Quantity = 1,
- PplNum = 1,
- TotalAmt = infoView.AirJJ,
- Remark = "",
- });
- intTravelIndex++;
- }
- if (infoView.SumGWC == 1)
- {
- intTravelCosts.Add(new QuoteSubItemInfo
- {
- ItemId = 1354,
- Index = intTravelIndex,
- FeeName = "公务舱",
- UnitPrice = infoView.AirGW,
- Currency = "CNY",
- Quantity = 1,
- PplNum = 1,
- TotalAmt = infoView.AirGW,
- Remark = "",
- });
- intTravelIndex++;
- }
- if (infoView.SumTDC == 1)
- {
- intTravelCosts.Add(new QuoteSubItemInfo
- {
- ItemId = 1354,
- Index = intTravelIndex,
- FeeName = "头等舱",
- UnitPrice = infoView.AirTD,
- Currency = "CNY",
- Quantity = 1,
- PplNum = 1,
- TotalAmt = infoView.AirTD,
- Remark = "",
- });
- intTravelIndex++;
- }
- intTravelCosts.Add(new QuoteSubItemInfo
- {
- ItemId = 1354,
- Index = intTravelIndex,
- FeeName = "城市间交通费用",
- UnitPrice = infoView.CityTranffic,
- Currency = "CNY",
- Quantity = 1,
- PplNum = pplNum,
- TotalAmt = infoView.CityTranffic * pplNum,
- Remark = "",
- });
- views.AddRange(intTravelCosts);
- #endregion
- var accomCosts = new List<QuoteSubItemInfo>();
- #region 住宿费 1355
- if (infoView.QuarterageData.Any())
- {
- int accomIndex = 1;
- int accomItemTypeId = 1355;
- var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
- foreach (var item in groupData)
- {
- string feeName = string.Empty;
- var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
- if (countryInfo != null)
- {
- feeName = countryInfo.Country;
- var city = countryInfo.City;
- if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
- {
- feeName += $"-{city}";
- }
- }
- var hotelInfo = item.FirstOrDefault();
- if (hotelInfo == null) continue;
- var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
- var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
- int quantity = item.ToList().Count;
- accomCosts.Add(new QuoteSubItemInfo
- {
- ItemId = accomItemTypeId,
- Index = accomIndex,
- FeeName = feeName,
- UnitPrice = hotelInfo.Cost,
- Currency = thisCurrency,
- Quantity = quantity,
- PplNum = pplNum,
- TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
- Remark = "",
- });
- accomIndex++;
- }
- views.AddRange(accomCosts);
- }
- #endregion
- var mealCosts = new List<QuoteSubItemInfo>();
- #region 餐饮费 1356
- if (infoView.BoardWagesData.Any())
- {
- var mealIndex = 1;
- int mealItemTypeId = 1356;
- var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
- foreach (var item in groupData)
- {
- string feeName = string.Empty;
- var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
- if (countryInfo != null)
- {
- feeName = countryInfo.Country;
- var city = countryInfo.City;
- if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
- {
- feeName += $"-{city}";
- }
- }
- var mealInfo = item.FirstOrDefault();
- if (mealInfo == null) continue;
- var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
- var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
- int quantity = item.ToList().Count;
- mealCosts.Add(new QuoteSubItemInfo
- {
- ItemId = mealItemTypeId,
- Index = mealIndex,
- FeeName = feeName,
- UnitPrice = mealInfo.Cost,
- Currency = thisCurrency,
- Quantity = quantity,
- PplNum = pplNum,
- TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
- Remark = "",
- });
- mealIndex++;
- }
- views.AddRange(mealCosts);
- }
- #endregion
- var miscCosts = new List<QuoteSubItemInfo>();
- #region 公杂费 1364
- if (infoView.MiscellaneousFeeData.Any())
- {
- var miscIndex = 1;
- int miscItemTypeId = 1364;
- var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
- foreach (var item in groupData)
- {
- string feeName = string.Empty;
- var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
- if (countryInfo != null)
- {
- feeName = countryInfo.Country;
- var city = countryInfo.City;
- if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
- {
- feeName += $"-{city}";
- }
- }
- var miscInfo = item.FirstOrDefault();
- if (miscInfo == null) continue;
- var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
- var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
- int quantity = item.ToList().Count;
- miscCosts.Add(new QuoteSubItemInfo
- {
- ItemId = miscItemTypeId,
- Index = miscIndex,
- FeeName = feeName,
- UnitPrice = miscInfo.Cost,
- Currency = thisCurrency,
- Quantity = quantity,
- PplNum = pplNum,
- TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
- Remark = "",
- });
- miscIndex++;
- }
- views.AddRange(miscCosts);
- }
- #endregion
- #region 签证+保险 1362
- int visaInsIndex = 1;
- int visaInsItemTypeId = 1362;
- if (infoView.Visa > 0)
- {
- views.Add(new QuoteSubItemInfo()
- {
- ItemId = visaInsItemTypeId,
- Index = visaInsIndex,
- FeeName = $"签证",
- UnitPrice = infoView.Visa,
- Currency = $"CNY",
- Quantity = 1,
- PplNum = pplNum,
- TotalAmt = infoView.Visa * pplNum,
- Remark = "",
- });
- visaInsIndex++;
- }
- if (infoView.Safe > 0)
- {
- views.Add(new QuoteSubItemInfo()
- {
- ItemId = visaInsItemTypeId,
- Index = visaInsIndex,
- FeeName = $"保险",
- UnitPrice = infoView.Safe,
- Currency = $"CNY",
- Quantity = 1,
- PplNum = pplNum,
- TotalAmt = infoView.Safe * pplNum,
- Remark = "",
- });
- }
- #endregion
- #region 服务费 1363
- int serviceFeeIndex = 1;
- int serviceFeeItemTypeId = 1363;
- if (infoView.Service > 0)
- {
- views.Add(new QuoteSubItemInfo()
- {
- ItemId = serviceFeeItemTypeId,
- Index = serviceFeeIndex,
- FeeName = $"服务费",
- UnitPrice = infoView.Service,
- Currency = $"CNY",
- Quantity = 1,
- PplNum = pplNum,
- TotalAmt = infoView.Service * pplNum,
- Remark = "",
- });
- }
- #endregion
- #endregion
- if (result.FeeItems.Any())
- {
- result.FeeItems.Select(x =>
- {
- var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
- if (feeInfos.Any()) x.Infos = feeInfos;
- return x;
- }
- ).OrderBy(x => x.Index)
- .ToList();
- if (!result.Rates.Any())
- {
- if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
- else
- {
- var rates = await GeneralMethod.EnterExitCostInitRate();
- rates.Insert(0,new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
- result.Rates = rates.ToArray();
- }
- }
- }
- return Ok(JsonView(result));
- }
- /// <summary>
- /// 团组模块 - 出入境费用报价表 - Info
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
- {
- var info = await _enterExitCostQuoteRep.InfoAsync(dto);
- if (!info.Rates.Any())
- {
- var rates = await GeneralMethod.EnterExitCostInitRate();
- rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
- info.Rates = rates.ToArray();
- }
- return Ok(JsonView(info));
- }
- /// <summary>
- /// 团组模块 - 出入境费用报价表 - OP
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
- {
- return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
- }
- /// <summary>
- /// 团组模块 - 出入境费用报价表 - 删除 项
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
- {
- if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
- }
- /// <summary>
- /// 团组模块 - 出入境费用报价表 - 导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
- {
- if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
- if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
- var rates = info.Rates;
- var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
- var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
- var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
- var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
- var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
- var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
- var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
- var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
- var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
- var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
- var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
- var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
- //获取模板
- string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
- var designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(tempPath);
- designer.SetDataSource("QuoteName", info.Name);
- designer.SetDataSource("CompanyTitle", "公司名称");
- designer.SetDataSource("CompanyLabel", "");
- #region 国际旅费
- designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
- if (intTravelCosts != null && intTravelCosts.Infos.Any())
- {
- var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
- StringBuilder label = new StringBuilder();
- var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
- if (infos.Any())
- {
- label.Append(infos.Sum(x => x.PplNum));
- label.Append("人全程机票:");
- label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
- label.AppendLine("元");
- }
- foreach (var item in intTravelCosts.Infos)
- {
- label.Append(item.FeeName);
- label.Append(":");
- label.Append(item.UnitPrice.TruncDecimals(2));
- label.Append("元/人*");
- label.Append(item.PplNum);
- label.AppendLine("人");
- }
- if (label.HasValue())
- {
- label.Append("\r\n以上小计:");
- label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
- label.Append("元");
- }
- designer.SetDataSource("IntTravelLabel", label.ToString());
- }
- #endregion
- #region 住宿费
- designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
- if (accomCosts!=null && accomCosts.Infos.Any())
- {
- string currencyName = string.Empty,
- countryName = string.Empty;
- decimal rate = 1.0000M;
- StringBuilder label = new StringBuilder();
- label.AppendLine("全程五星酒店,每人1间房");
- foreach (var item in accomCosts.Infos)
- {
- //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
- string name = string.Empty, thisCountryName = string.Empty;
- if (item.FeeName.Contains("-"))
- {
- var feeName = item.FeeName.Split('-');
- thisCountryName = feeName[0];
- if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
- name = feeName[1];
- }
- else name = item.FeeName;
- string thisFeeName = string.Empty;
- if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
- else thisFeeName = $"\r\n{name}:";
- var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
- currencyName = rateInfo?.CurrencyName ?? "UnKnow";
- rate = rateInfo?.Rate ?? 1.0000M;
- string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
- label.AppendLine(subLabel);
- }
- if (label.HasValue())
- {
- //以上小计:52440元(美金汇率:7.5 )
- string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
- label.AppendLine(subLabel);
- }
- designer.SetDataSource("AccomLabel", label.ToString());
- }
- #endregion
- #region 餐饮费
- designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
- if (mealCosts != null && mealCosts.Infos.Any())
- {
- string currencyName = string.Empty;
- decimal rate = 1.0000M;
- StringBuilder label = new StringBuilder();
- label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
- foreach (var item in mealCosts.Infos)
- {
- string name = string.Empty;
- if (item.FeeName.Contains("-"))
- {
- var feeName = item.FeeName.Split('-');
- name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
- }
- else name = $"\r\n{item.FeeName}:";
- var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
- currencyName = rateInfo?.CurrencyName ?? "UnKnow";
- rate = rateInfo?.Rate ?? 1.0000M;
- label.Append(name);
- label.Append(item.UnitPrice.TruncDecimals(2));
- label.Append(currencyName);
- label.Append("/天*");
- label.Append(item.Quantity.ToString("#0"));
- label.Append("*");
- label.Append(item.PplNum);
- label.Append("人\r\n");
- }
- if (label.HasValue())
- {
- label.Append("\r\n以上小计:");
- label.Append(accomCosts.TotalAmt.TruncDecimals(2));
- label.Append("元\r\n(");
- label.Append("汇率:");
- label.Append(rate.TruncDecimals(4));
- label.Append(")");
- }
- designer.SetDataSource("MealLabel", label.ToString());
- }
- #endregion
- #region 车辆安排
- designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
- if (vehArranges!=null&&vehArranges.Infos.Any())
- {
- string currencyName = string.Empty;
- //decimal rate = 1.0000M;
- StringBuilder label = new StringBuilder();
- foreach (var item in vehArranges.Infos)
- {
- label.AppendLine();
- label.AppendLine();
- label.Append(item.FeeName);
- label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
- }
- designer.SetDataSource("VehArrangeLabel", label.ToString());
- }
- #endregion
- #region 邀请函发放对象
- designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
- designer.SetDataSource("InviteToContent", "");
- #endregion
- #region 邀请函费
- designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
- StringBuilder is_label = new StringBuilder();
- if (inviteCosts != null&&inviteCosts.Infos.Any())
- {
- string currencyName = string.Empty;
- decimal rate = 1.0000M;
- foreach (var item in inviteCosts.Infos)
- {
- //乌兹别克斯坦:2000美金
- currencyName = item.Currency;
- rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
- string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
- is_label.AppendLine(label);
- }
- if (is_label.HasValue())
- {
- //以上小计:28500元(美金汇率:7.5)
- string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2),"元", currencyName, rate.TruncDecimals(4));
- is_label.AppendLine(label);
- }
- }
- designer.SetDataSource("InviteCostContent", is_label.ToString());
- #endregion
- #region 邀请函发放时间
- designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
- designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
- #endregion
- #region 公务活动(含翻译)
- designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
- StringBuilder oa_label = new StringBuilder();
- if (officialActs != null && officialActs.Infos.Any())
- {
- string currencyName = string.Empty;
- decimal rate = 1.0000M;
- string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
- foreach (var item in officialActs.Infos)
- {
- //乌兹别克斯坦:1000美金/场
- currencyName = item.Currency;
- rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
- string label_remark = string.Empty;
- if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
- label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
- }
- label_content += "*总费用中未含超出公务活动价格";
- //8场公务活动(以上小计:60000元)
- var quantity = officialActs.Infos.Sum(x => x.Quantity);
- label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
- oa_label.AppendLine(label_title);
- oa_label.AppendLine(label_content);
- }
- designer.SetDataSource("OfficialActsContent", oa_label.ToString());
- #endregion
- #region 签证+保险
- designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
- StringBuilder vi_label = new StringBuilder();
- if (visaIns != null && visaIns.Infos.Any())
- {
- foreach (var item in visaIns.Infos)
- {
- //签证:500元/人
- string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
- vi_label.AppendLine(label);
- }
- if (vi_label.HasValue())
- {
- //以上小计:6000元
- string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
- vi_label.AppendLine(label);
- }
- }
- designer.SetDataSource("VisaInsContent", vi_label.ToString());
- #endregion
- #region 服务费
- designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
- designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
- #endregion
- #region 公杂费
- designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
- StringBuilder pm_label = new StringBuilder();
- if (pubMiscs != null && pubMiscs.Infos.Any())
- {
- string currencyName = string.Empty,
- countryName = string.Empty;
- decimal rate = 1.0000M;
- foreach (var item in pubMiscs.Infos)
- {
- //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
- string name = string.Empty, thisCountryName = string.Empty;
- if (item.FeeName.Contains("-"))
- {
- var feeName = item.FeeName.Split('-');
- thisCountryName = feeName[0];
- if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
- name = feeName[1];
- }
- else name = item.FeeName;
- string thisFeeName = string.Empty;
- if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
- else thisFeeName = $"\r\n{name}:";
- var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
- currencyName = rateInfo?.CurrencyName ?? "UnKnow";
- rate = rateInfo?.Rate ?? 1.0000M;
- string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
- pm_label.AppendLine(label);
- }
- if (pm_label.HasValue())
- {
- //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
- pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
- pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
- pm_label.AppendLine(string.Format("部分发放成员"));
- }
- }
- designer.SetDataSource("PubMiscsContent", pm_label.ToString());
- #endregion
- #region 税费
- designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
- designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
- #endregion
- #region 合计(单位:元)
- designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
- designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
- #endregion
- #region 汇率 Remark
- var rate_label = new StringBuilder();
- var rateGroups = rates.GroupBy(x => x.CurrencyName);
- foreach (var item in rateGroups)
- {
- //美元汇率按\r\n1:7.5
- string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
- rate_label.AppendLine(label);
- }
- designer.SetDataSource("RateLabel", rate_label.ToString());
- #endregion
- designer.Process();
- //文件名
- string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
- string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
- return Ok(JsonView(true, "成功", url));
- }
- #endregion
- #region 签证费用录入
- /// <summary>
- /// 根据diid查询签证费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
- {
- Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
-
- /// <summary>
- /// 根据签证费用Id查询单条数据及c表数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
- {
- Result groupData = await _visaPriceRep.PostVisaById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
-
- /// <summary>
- /// 签证费用删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
- {
- _sqlSugar.BeginTran();
- var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "删除失败"));
- }
- var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
- .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
- .SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .ExecuteCommand();
- if (resSub < 1)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "删除失败"));
- }
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "删除成功!"));
- }
-
- /// <summary>
- /// 签证费用录入下拉框初始化
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaPriceAddSelect()
- {
- //支付方式
- List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
- //币种
- List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
- //乘客类型
- List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
- //卡类型
- List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
- //代办费类型
- var agencyFeeTypeData = new List<dynamic>() {
- new { id = 0 , Text = "未选择" },
- new { id = 1 , Text = "小公务" },
- new { id = 2 , Text = "大公务" },
- };
- //签证费用标准国家Data
- var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
- var data = new
- {
- Payment = _Payment,
- CurrencyList = _CurrencyList,
- PassengerType = _PassengerType,
- BankCard = _BankCard,
- AgencyFeeType = agencyFeeTypeData,
- CountryFeeData = visaCountryFeeData
- };
- return Ok(JsonView(true, "查询成功!", data));
- }
- /// <summary>
- /// 签证费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
- {
- Result groupData = await _visaPriceRep.OpVisaPrice(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- #region 应用推送
- try
- {
- int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- string content = "";
- var diId = dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
- else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
- await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- #endregion
- #region 签证提成录入
- /// <summary>
- /// 签证提成录入
- /// 基础数据
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionInit()
- {
- return Ok(await _visaCommissionRep.Init());
- }
- /// <summary>
- /// 签证提成录入
- /// Item
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
- {
- var validator = new VisaCommissionItemDtoValidator();
- var validatorRes = await validator.ValidateAsync(_dto);
- if (!validatorRes.IsValid)
- {
- StringBuilder sb = new StringBuilder();
- foreach (var item in validatorRes.Errors)
- {
- sb.AppendLine(item.ErrorMessage);
- }
- return Ok(JsonView(false, sb.ToString()));
- }
- return Ok(await _visaCommissionRep.Item(_dto));
- }
- /// <summary>
- /// 签证提成录入
- /// Save
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
- {
- //参数验证
- if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
- foreach (var item in _dto.Items)
- {
- if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
- if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
- if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
- //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
- }
- return Ok(await _visaCommissionRep.Save(_dto));
- }
- /// <summary>
- /// 签证提成录入
- /// Create
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
- {
- var validator = new VisaCommissionCreateDtoValidator();
- var validatorRes = await validator.ValidateAsync(_dto);
- if (!validatorRes.IsValid)
- {
- StringBuilder sb = new StringBuilder();
- foreach (var item in validatorRes.Errors)
- {
- sb.AppendLine(item.ErrorMessage);
- }
- return Ok(JsonView(false, sb.ToString()));
- }
- return Ok(await _visaCommissionRep.Create(_dto));
- }
- /// <summary>
- /// 签证提成录入
- /// Put(编辑)
- /// </summary>
- /// <param name="id"></param>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPut]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
- {
- if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
- var validator = new VisaCommissionCreateDtoValidator();
- var validatorRes = await validator.ValidateAsync(_dto);
- if (!validatorRes.IsValid)
- {
- StringBuilder sb = new StringBuilder();
- foreach (var item in validatorRes.Errors)
- {
- sb.AppendLine(item.ErrorMessage);
- }
- return Ok(JsonView(false, sb.ToString()));
- }
- return Ok(await _visaCommissionRep.Edit(id, _dto));
- }
- /// <summary>
- /// 签证提成录入
- /// Del
- /// </summary>
- /// <param name="id"></param>
- /// <param name="currUserId"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
- {
- if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
- if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
- return Ok(await _visaCommissionRep.Del(id, currUserId));
- }
- #endregion
- #region op费用录入
- /// <summary>
- /// 根据diid查询op费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
- {
- Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 根据op费用Id查询单条数据及c表数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
- {
- try
- {
- Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
- Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
- var data = new
- {
- CarTouristGuideGround = _groupData,
- CreditCardPayment = _creditCardPayment
- };
- return Ok(JsonView(true, "查询成功!", data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- }
- }
- /// <summary>
- /// op费用删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
- {
- try
- {
- _sqlSugar.BeginTran();
- var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- #region 删除超支相关数据
- //删除导入的超支数据
- var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
- var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommand();
- count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommand();
- count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommand();
- #endregion
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "程序错误!" + ex.Message));
- }
- }
- /// <summary>
- /// op费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
- {
- Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 填写费用详细页面初始化绑定
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
- {
- try
- {
- Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 根据op费用Id查询详细数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
- {
- try
- {
- Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// OP费用录入填写详情
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
- {
- try
- {
- #region 参数校验
- if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
- var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
- if (di == null) return Ok(JsonView(false, "团组错误!"));
- #endregion
- Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- //自动审核
- await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
- #region 应用推送
- try
- {
- int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- var diId = dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
- await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 获取三公详细所有城市
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public IActionResult OpCarCityResult()
- {
- var jw = JsonView(false);
- var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
- {
- x.Id,
- x.Country,
- x.City,
- }).ToList();
- if (data.Count > 0)
- {
- jw = JsonView(true, "获取成功!", data);
- }
- else
- {
- jw.Msg = "城市数据为空!";
- jw.Data = new string[0];
- }
- return Ok(jw);
- }
- /// <summary>
- /// 导出地接费用明细
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
- {
- var jw = JsonView(false);
- if (dto.Diid < 1)
- {
- jw.Msg = "请输入正确的diid!";
- return Ok(jw);
- }
- var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (group == null)
- {
- jw.Msg = "未找到团组信息!";
- return Ok(jw);
- }
- var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
- if (localGuideArr.Count == 0)
- {
- jw.Msg = "该团组暂无地接信息!";
- return Ok(jw);
- }
- var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
- var overspendSoure = new Dictionary<int, int>
- {
- { 91, 982 }, //车
- { 92 , 1059} ,//导游
- { 994 , 1073}, //翻译
- { 988 , 1074 }, //早餐
- { 93 , 1075 }, //午餐
- { 989 , 1076 }, //晚餐
- };
- Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
- foreach (var groupArr in localGroup)
- {
- var keyValue = groupArr.Key;
- if (int.TryParse(keyValue, out int cityid))
- {
- var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
- keyValue = city == null ? keyValue : city.Country + "-" + city.City;
- }
- List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
- foreach (var item in groupArr)
- {
- var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
- ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
- new Grp_CarTouristGuideGroundReservationsContentExtend
- {
- Count = a.Count,
- CreateTime = a.CreateTime,
- CreateUserId = a.CreateUserId,
- CTGGRId = a.CTGGRId,
- Currency = a.Currency,
- DatePrice = a.DatePrice,
- DeleteTime = a.DeleteTime,
- DeleteUserId = a.DeleteUserId,
- DiId = a.DiId,
- Id = a.Id,
- IsDel = a.IsDel,
- Price = a.Price,
- PriceContent = a.PriceContent,
- Remark = a.Remark,
- SId = a.SId,
- SidName = b.Name,
- Units = a.Units,
- }
- ).ToList();
- if (content.Count > 0)
- {
- contentArr.Add(content);
- }
- }
- //open excel
- //set excel
- //save excel
- try
- {
- string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
- IWorkbook workbook;
- if (Path.GetExtension(filePath).ToLower() == ".xls")
- {
- workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
- }
- else
- {
- workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
- }
- ISheet sheet = workbook.GetSheetAt(0);
- var rowStartIndex = 2;
- var clounmCount = 10;
- var initStyleRow = sheet.GetRow(2);
- var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
- //var overspendArrDetail =
- var existsId = new List<CarCompare>();
- var lastElem = arr.Last();
- var thisSid = -1;
- var curr = arr.Count > 0 ? arr[0].Currency : -1;
- var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
- {
- Name = "未知币种!",
- Remark = "未知币种!",
- };
- sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
- Action cloneRowFn = () =>
- {
- rowStartIndex++;
- var cloneRow = sheet.CreateRow(rowStartIndex);
- // 复制样式
- for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
- {
- ICell sourceCell = initStyleRow.GetCell(i);
- ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
- // 确保单元格存在样式
- if (sourceCell.CellStyle != null)
- {
- targetCell.CellStyle = sourceCell.CellStyle;
- }
- }
- };
- var mergeRow = () =>
- {
- for (int i = 2; i < sheet.LastRowNum; i++)
- {
- var row = sheet.GetRow(i);
- var cellFirst = row.GetCell(0);
- var thisIndex = i + 1;
- while (thisIndex < sheet.LastRowNum)
- {
- var nextRow = sheet.GetRow(thisIndex);
- var nextCellFirst = nextRow.GetCell(0);
- if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
- {
- thisIndex++;
- }
- else
- {
- break;
- }
- }
- thisIndex--;
- if (thisIndex != i)
- {
- //合并row
- CellRangeAddress cellRangeAddress = new CellRangeAddress(
- i, // 起始行索引(0-based)
- thisIndex, // 结束行索引(0-based)
- 0, // 起始列索引(0-based)
- 0 // 结束列索引(0-based)
- );
- sheet.AddMergedRegion(cellRangeAddress);
- i = thisIndex;
- }
- }
- };
- var chaoshiNumber = 0;
- var totalNumber = 0.00M;
- string lastStr = "";
- var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
- .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
- {
- b.IsAuditGM,
- x.Id,
- x.Area,
- b.PayPercentage,
- b.PayMoney,
- }).ToList();
- string yesPayment = "", noPayment = "";
- foreach (var item in queryCarArrByCityAndDiid)
- {
- if (item.IsAuditGM == 1)
- {
- yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
- }
- else
- {
- noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
- }
- }
- lastStr = yesPayment + noPayment;
- foreach (var item in arr)
- {
- if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
- {
- if (thisSid != item.SId)
- {
- if (thisSid == -1)
- {
- thisSid = item.SId;
- }
- else
- {
- //合并小计行
- //创建合并区域的实例
- CellRangeAddress cellRangeAddress = new CellRangeAddress(
- rowStartIndex, // 起始行索引(0-based)
- rowStartIndex, // 结束行索引(0-based)
- 0, // 起始列索引(0-based)
- 3 // 结束列索引(0-based)
- );
- sheet.AddMergedRegion(cellRangeAddress);
- var CellStyle = workbook.CreateCellStyle();
- CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
- CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
- CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
- for (int i = 0; i <= clounmCount; i++)
- {
- if (i > 6)
- {
- var CellStyle1 = workbook.CreateCellStyle();
- CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
- IFont Font = workbook.CreateFont(); // 创建字体
- Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
- Font.Color = IndexedColors.Red.Index; // 选择字体颜色
- CellStyle1.SetFont(Font);
- sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
- }
- else
- {
- sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
- }
- }
- sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
- sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
- //超时合计
- sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
- //超时数
- sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
- //超时合计费用
- sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
- thisSid = item.SId;
- cloneRowFn();
- chaoshiNumber = 0;
- totalNumber = 0;
- }
- }
- IRow row = sheet.GetRow(rowStartIndex);
- var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
- var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
- List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
- if (isOpenOverspendSoure)
- {
- overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
- chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
- totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
- }
- for (int i = 0; i <= clounmCount; i++)
- {
- var cell = row.GetCell(i);
- var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
- if (cell == null)
- {
- cell = row.CreateCell(i);
- }
- var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
- fontRed.CloneStyleFrom(cell.CellStyle);
- IFont Font = workbook.CreateFont(); // 创建字体
- Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
- Font.Color = IndexedColors.Red.Index; // 选择字体颜色
- fontRed.SetFont(Font);
- byte[] rgb = new byte[3] { 255, 242, 204 };
- var BackgroundColor255_242_204 = workbook.CreateCellStyle();
- BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
- byte[] rgb1 = new byte[3] { 189, 215, 238 };
- if (workbook is XSSFWorkbook)
- {
- BackgroundColor255_242_204.FillForegroundColor = 0;
- ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
- BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
- }
- else
- {
- BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
- }
- if (i == 1 || i > 6)
- {
- if (i > 6)
- {
- fontRed.FillForegroundColor = 0;
- ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
- fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
- }
- cell.CellStyle = fontRed;
- }
- if (i > 2 && i < 7)
- {
- cell.CellStyle = BackgroundColor255_242_204;
- }
- cell.SetCellValue(setCellValue); //写入单元格
- }
- if (overspendSoure.ContainsKey(thisSid))
- {
- var overspendId = overspendSoure[thisSid];
- whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
- }
- cloneRowFn();
- existsId.Add(new CarCompare
- {
- DataPrice = item.DatePrice.ObjToDate(),
- Sid = item.SId
- });
- }
- if (item.Equals(lastElem))
- {
- //合并小计行
- //创建合并区域的实例
- CellRangeAddress cellRangeAddress = new CellRangeAddress(
- rowStartIndex, // 起始行索引(0-based)
- rowStartIndex, // 结束行索引(0-based)
- 0, // 起始列索引(0-based)
- 3 // 结束列索引(0-based)
- );
- sheet.AddMergedRegion(cellRangeAddress);
- var CellStyle = workbook.CreateCellStyle();
- CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
- CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
- CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
- for (int i = 0; i <= clounmCount; i++)
- {
- if (i > 6)
- {
- var CellStyle1 = workbook.CreateCellStyle();
- CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
- IFont Font = workbook.CreateFont(); // 创建字体
- Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
- Font.Color = IndexedColors.Red.Index; // 选择字体颜色
- CellStyle1.SetFont(Font);
- sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
- }
- else
- {
- sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
- }
- }
- sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
- sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
- //超时合计
- sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
- //超时数
- sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
- //超时合计费用
- sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
- cloneRowFn();
- // 创建合并区域的实例
- cellRangeAddress = new CellRangeAddress(
- rowStartIndex, // 起始行索引(0-based)
- rowStartIndex, // 结束行索引(0-based)
- 0, // 起始列索引(0-based)
- initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
- );
- // 添加合并区域
- sheet.AddMergedRegion(cellRangeAddress);
- sheet.GetRow(rowStartIndex).Height = 30 * 30;
- sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
- }
- }
- mergeRow();
- // 保存修改后的Excel文件到新文件
- //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
- // new FileStream(newFilePath, FileMode.CreateNew)
- using (var stream = new MemoryStream())
- {
- workbook.Write(stream, true);
- stream.Flush();
- stream.Seek(0, SeekOrigin.Begin);
- MemoryStream memoryStream = new MemoryStream();
- stream.CopyTo(memoryStream);
- memoryStream.Seek(0, SeekOrigin.Begin);
- Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
- }
- workbook.Close();
- workbook.Dispose();
- }
- catch (Exception ex)
- {
- jw.Msg = "出现异常!" + ex.Message;
- return Ok(jw);
- }
- }
- if (Zips.Count > 0)
- {
- IOOperatorHelper io = new IOOperatorHelper();
- var byts = io.ConvertZipStream(Zips);
- io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
- //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
- jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
- }
- else
- {
- jw.Msg = "暂无生成文件!";
- }
- return Ok(jw);
- }
- private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
- {
- string outStr = string.Empty;
- switch (i)
- {
- case 0:
- outStr = arr[0].SidName;
- break;
- case 1:
- outStr = arr[0].DataPriceStr;
- break;
- case 2:
- outStr = string.Join("-", arr.Select(x => x.PriceContent));
- break;
- case 4:
- outStr = arr.Sum(x => x.Subtotal).ToString("F2");
- break;
- case 7:
- if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
- {
- var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
- var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
- outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
- }
- break;
- case 8:
- if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
- {
- outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
- }
- break;
- case 9:
- if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
- {
- outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
- }
- break;
- case 10:
- if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
- {
- outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
- }
- break;
- }
- return outStr;
- }
- #region OP行程单
- /// <summary>
- /// OP行程单初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult InitOpTravel(InitOpTravelDto dto)
- {
- var jw = JsonView(false);
- var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
- var group = groupList.First();
- var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
- if (group == null)
- {
- jw.Msg = "暂无团组!";
- return Ok(jw);
- }
- group = groupList.Find(x => x.Id == diid);
- if (group == null)
- {
- jw.Msg = "请输入正确的团组ID!";
- return Ok(jw);
- }
- string city = string.Empty;
- var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
- if (blackCode.Count > 0)
- {
- var black = blackCode.First();
- black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
- var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
- if (blackSp.Length > 0)
- {
- try
- {
- var cityArrCode = new List<string>(20);
- foreach (var item in blackSp)
- {
- var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
- var IndexSelect = itemSp[2];
- var cityArrCodeLength = cityArrCode.Count - 1;
- var startCity = IndexSelect.Substring(0, 3);
- if (cityArrCodeLength > 0)
- {
- var arrEndCity = cityArrCode[cityArrCodeLength];
- if (arrEndCity != startCity)
- {
- cityArrCode.Add(startCity.ToUpper());
- }
- }
- else
- {
- cityArrCode.Add(startCity.ToUpper());
- }
- var endCity = IndexSelect.Substring(3, 3);
- cityArrCode.Add(endCity.ToUpper());
- }
- var cityThree = string.Empty;
- cityArrCode.ForEach(x => cityThree += "'" + x + "',");
- cityThree = cityThree.TrimEnd(',');
- if (string.IsNullOrWhiteSpace(cityThree))
- {
- throw new
- Exception("error");
- }
- string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
- var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
- foreach (var item in cityArrCode)
- {
- var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
- if (find != null)
- {
- city += find.City + "/";
- }
- else
- {
- city += item + "三字码未收入/";
- }
- }
- city = city.TrimEnd('/');
- }
- catch (Exception e)
- {
- city = "黑屏代码格式不正确!";
- }
- }
- }
- else
- {
- city = "未录入黑屏代码";
- }
- var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
- {
- Date = x.Date,
- Days = x.Days,
- Diffgroup = x.Diffgroup,
- Diid = x.Diid,
- Traffic_First = x.Traffic_First,
- Traffic_Second = x.Traffic_Second,
- Trip = x.Trip,
- WeekDay = x.WeekDay,
- Id = x.Id
- }).ToList();
- jw.Data = new
- {
- groupList = groupList.Select(x => new
- {
- x.Id,
- x.TeamName,
- x.TourCode
- }).ToList(),
- groupInfo = new
- {
- group.VisitDays,
- group.TourCode,
- group.VisitPNumber,
- group.TeamName,
- city
- },
- OpTravelList
- };
- jw.Code = 200;
- jw.Msg = "操作成功!";
- return Ok(jw);
- }
- /// <summary>
- /// 删除团组行程单
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public IActionResult DelTravel(DelOpTravelDto dto)
- {
- var jw = JsonView(false);
- if (dto.UserId <= 0 || dto.Diid <= 0)
- {
- jw.Msg = "请输入正确的参数!";
- return Ok(jw);
- }
- var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
- .SetColumns(x => new Grp_TravelList
- {
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
- DeleteUserId = dto.UserId,
- IsDel = 1,
- }).ExecuteCommand();
- jw = JsonView(true);
- return Ok(jw);
- }
- /// <summary>
- /// 行程单保存
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public IActionResult TravelSave(TravelSaveDto dto)
- {
- var jw = JsonView(false);
- if (dto.Arr.Count > 0)
- {
- try
- {
- var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
- .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
- .ToList();
- _sqlSugar.BeginTran();
- foreach (var item in dto.Arr)
- {
- if (item.Id == 0)
- {
- throw new Exception("请传入正确的Id");
- }
- //比较上一次的差异
- var findTravel = travelList_DB.Find(x => x.Id == item.Id);
- if (findTravel != null)
- {
- item.Trip = item.Trip.Replace("[++]", string.Empty);
- findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
- item.Trip = CheckStr(findTravel.Trip, item.Trip);
- }
- _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
- .SetColumns(x => new Grp_TravelList
- {
- Trip = item.Trip
- }).ExecuteCommand();
- }
- _sqlSugar.CommitTran();
- jw = JsonView(true);
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- jw.Msg = "程序异常!" + ex.Message;
- }
- }
- else
- {
- jw.Msg = "请传入正确的参数!";
- }
- return Ok(jw);
- }
- private string CheckStr(string original, string changed)
- {
- // 创建diff_match_patch对象
- var dmp = new diff_match_patch();
- // 计算差异
- List<Diff> diffs = dmp.diff_main(original, changed);
- // 清理和合并差异
- dmp.diff_cleanupSemantic(diffs);
- // 使用StringBuilder构建最终的字符串
- StringBuilder finalString = new StringBuilder();
- // 输出差异结果,并构建变动后的字符串
- foreach (Diff diff in diffs)
- {
- switch (diff.operation)
- {
- case Operation.EQUAL:
- // 相等的部分,直接添加到最终字符串
- finalString.Append(diff.text);
- break;
- case Operation.INSERT:
- // 插入的部分,添加标记并添加到最终字符串
- finalString.Append("[++]" + diff.text + "[++]");
- break;
- case Operation.DELETE:
- // 删除的部分,不添加到最终字符串
- //finalString.Append("[++]" + diff.text + "[++]");
- break;
- }
- }
- // 输出变动后的字符串
- return finalString.ToString();
- }
- private class tagContent
- {
- public DateTime Date { get; set; }
- public string StartTag { get; set; }
- public string EndTag { get; set; }
- public string Content { get; set; }
- public static int tagLength { get { return 3; } }
- public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
- public string QueryTag { get { return this.StartTag + this.EndTag; } }
- public bool IsFinally { get; set; }
- }
- private List<string> ExtractContentBetweenTags(string input, string tag)
- {
- List<string> results = new List<string>();
- // 构造正则表达式,匹配形如 [++]内容[++] 的部分
- string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
- // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
- MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
- string[] strValueArr = new string[1];
- foreach (System.Text.RegularExpressions.Match match in matches)
- {
- var strValue = match.Groups[1].Value;
- strValueArr = Regex.Split(strValue, @"\r\n|\n");
- }
- results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
- return results;
- }
- /// <summary>
- /// 导出行程单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ExportTravel(ExportTravelDto dto)
- {
- var jw = JsonView(false);
- jw.Data = "";
- int diid = 0;
- var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
- if (Find == null)
- {
- jw.Msg = "请选择正确的团组!";
- return Ok(jw);
- }
- else
- {
- diid = Find.Id;
- }
- //数据源
- List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
- DataTable dtBlack = null;
- try
- {
- dtBlack = GeneralMethod.GetTableByBlackCode(diid);
- }
- catch (Exception)
- {
- jw.Msg = "机票黑屏代码有误!";
- return Ok(jw);
- }
- string CityStr = string.Empty;
- if (dtBlack.Rows.Count == 0)
- {
- jw.Msg = "机票黑屏代码有误!";
- return Ok(jw);
- }
- else
- {
- foreach (DataRow row in dtBlack.Rows)
- {
- if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
- {
- jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
- return Ok(jw);
- }
- }
- CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
- _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
- }
- // 指定的文字
- var targetTextDic = new Dictionary<string, List<string>>();
- //创建数据源Table
- DataTable dtSource = new DataTable();
- dtSource.Columns.Add("Days", typeof(string));
- dtSource.Columns.Add("Date", typeof(string));
- dtSource.Columns.Add("Week", typeof(string));
- dtSource.Columns.Add("Traffic", typeof(string));
- dtSource.Columns.Add("Trip", typeof(string));
- //获取数据,放到datatable
- foreach (var item in _travelList)
- {
- targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
- item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
- .Replace(tagContent.TagFormat.Item2, string.Empty)
- .Replace("[++]", string.Empty);
- DataRow dr = dtSource.NewRow();
- dr["Days"] = item.Days;
- dr["Date"] = item.Date;
- dr["Week"] = item.WeekDay;
- dr["Traffic"] = item.Traffic_First
- + "\r\n"
- + item.Traffic_Second;
- dr["Trip"] = item.Trip;
- dtSource.Rows.Add(dr);
- }
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
- dic.Add("City", CityStr);
- dic.Add("Days", Find.VisitDays.ToString());
- dic.Add("DeleCode", Find.TourCode);
- dic.Add("Pnum", Find.VisitPNumber.ToString());
- //模板路径
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
- //载入模板
- Document doc = null;
- DocumentBuilder builder = null;
- try
- {
- //载入模板
- doc = new Document(tempPath);
- builder = new DocumentBuilder(doc);
- }
- catch (Exception)
- {
- jw.Msg = "模板位置不存在!";
- return Ok(jw);
- }
- foreach (var key in dic.Keys)
- {
- Bookmark bookmark = doc.Range.Bookmarks[key];
- if (bookmark != null)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- }
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- try
- {
- //循环赋值
- for (int i = 0; i < dtSource.Rows.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(dtSource.Rows[i]["Days"].ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(dtSource.Rows[i]["Traffic"].ToString());
- var trip = dtSource.Rows[i]["Trip"].ToString();
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(trip);
- var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
- var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
- // 获取特定索引的段落
- Paragraph paragraph = (Paragraph)paragraphs[0];
- Run run = paragraph.Runs[0];
- Aspose.Words.Font font = run.Font;
- font.Name = "黑体";
- //设置双休红色
- cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
- paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
- paragraph = (Paragraph)paragraphs[1];
- if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
- {
- run = paragraph.Runs[0];
- font = run.Font;
- font.Color = Color.Red;
- }
- }
- }
- catch (Exception ex)
- {
- }
- //删除多余行
- while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
- {
- tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
- }
- var targetTextList = new List<string>();
- // 遍历文档中的表格
- foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
- {
- foreach (Aspose.Words.Tables.Row row in table.Rows)
- {
- var cellIndex = 0;
- foreach (Cell cell in row.Cells)
- {
- if (cellIndex == 1 && row.Cells.Count == 4)
- {
- foreach (var target in targetTextDic.Keys)
- {
- if (cell.GetText().Contains(target))
- {
- targetTextList = targetTextDic[target];
- break;
- }
- }
- }
- // 遍历单元格中的所有段落
- foreach (Paragraph paragraph in cell.Paragraphs)
- {
- // 使用临时列表存储原始 Runs,避免修改时影响遍历
- List<Run> runs = new List<Run>();
- foreach (Run run in paragraph.Runs)
- {
- runs.Add(run);
- }
- foreach (Run run in runs)
- {
- foreach (var targetText in targetTextList)
- {
- // 检查文字是否包含指定文字
- if (run.Text.Contains(targetText))
- {
- // 将包含的部分设置为红色
- HighlightText(run, targetText, Color.Red);
- }
- }
- }
- }
- cellIndex++;
- }
- }
- }
- string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
- if (!Directory.Exists(savePath))
- {
- try
- {
- Directory.CreateDirectory(savePath);
- }
- catch
- {
- }
- }
- string path = savePath + Find.TeamName + "出访日程";
- string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
- try
- {
- Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
- string postfix = ".docx";
- if (dto.IsPDF == 1)
- {
- saveFormat = Aspose.Words.SaveFormat.Pdf;
- postfix = ".pdf";
- }
- doc.Save(path + postfix, saveFormat);
- jw = JsonView(true, "导出成功", ftpPath + postfix);
- }
- catch (Exception)
- {
- jw = JsonView(false);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 根据大写数字返回小写数字或根据小写数字返回大写数字
- /// </summary>
- /// <param name="num"></param>
- /// <returns></returns>
- string GetNum(string num)
- {
- string str = "";
- switch (num)
- {
- case "1":
- str = "一";
- break;
- case "2":
- str = "二";
- break;
- case "3":
- str = "三";
- break;
- case "4":
- str = "四";
- break;
- case "5":
- str = "五";
- break;
- case "6":
- str = "六";
- break;
- case "7":
- str = "七";
- break;
- case "8":
- str = "八";
- break;
- case "9":
- str = "九";
- break;
- case "10":
- str = "十";
- break;
- case "11":
- str = "十一";
- break;
- case "12":
- str = "十二";
- break;
- case "一":
- str = "1";
- break;
- case "二":
- str = "2";
- break;
- case "三":
- str = "3";
- break;
- case "四":
- str = "4";
- break;
- case "五":
- str = "5";
- break;
- case "六":
- str = "6";
- break;
- case "七":
- str = "7";
- break;
- case "八":
- str = "8";
- break;
- case "九":
- str = "9";
- break;
- case "十":
- str = "10";
- break;
- case "十一":
- str = "11";
- break;
- case "十二":
- str = "12";
- break;
- }
- return str;
- }
- // 高亮包含指定文字的部分
- void HighlightText(Run run, string targetText, Color color)
- {
- string text = run.Text;
- int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
- if (startIndex >= 0)
- {
- Paragraph parentParagraph = (Paragraph)run.ParentNode;
- // 前部分
- if (startIndex > 0)
- {
- Run beforeRun = (Run)run.Clone(true);
- beforeRun.Text = text.Substring(0, startIndex);
- parentParagraph.InsertBefore(beforeRun, run);
- }
- // 匹配部分
- Run matchRun = (Run)run.Clone(true);
- matchRun.Text = text.Substring(startIndex, targetText.Length);
- matchRun.Font.Color = color;
- parentParagraph.InsertBefore(matchRun, run);
- // 后部分
- if (startIndex + targetText.Length < text.Length)
- {
- Run afterRun = (Run)run.Clone(true);
- afterRun.Text = text.Substring(startIndex + targetText.Length);
- parentParagraph.InsertBefore(afterRun, run);
- }
- // 删除原始Run
- run.Remove();
- }
- }
- #endregion
- #endregion
- #region 团组成本
- /// <summary>
- /// 团组成本数据初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
- {
- var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
- Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
- WHEN COUNT(*) >= 0 THEN 'True'
- ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
- Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
- ").ToList(); //团组列表
- int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
- var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
- List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
- var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
- if (groupinfoValue != null)
- {
- var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
- var spArr = new string[1] { countryArr };
- if (countryArr.Contains("|"))
- {
- spArr = countryArr.Split("|");
- }
- else if (countryArr.Contains("、"))
- {
- spArr = countryArr.Split("、");
- }
- foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
- {
- var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
- if (dbQueryCountry != null)
- {
- visaCountryInfoArr.Add(dbQueryCountry);
- }
- }
- }
- var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
- var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
- #region 屏蔽黑屏代码生成
- //var create = _GroupCostRepository.
- // CreateGroupCostByBlackCode(dto.Diid);
- //if (groupCost.Count == 0 && create.Code == 0)
- //{
- // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
- //}
- #endregion
- var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
- var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
- var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
- groupCostMap = groupCostMap.Select(x =>
- {
- if (DateTime.TryParse(x.Date, out DateTime dataForamt))
- {
- x.Date = dataForamt.ToString("yyyy-MM-dd");
- }
- return x;
- }).ToList();
- //GroupCostParameter.Add(new
- // Grp_GroupCostParameter());
- var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
- bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
- return Ok(JsonView(new
- {
- groupList,
- groupInfo,
- groupChecks,
- groupCost = groupCostMap,
- hotelNumber,
- GroupCostParameter = GroupCostParameterMap,
- visaCountryInfoArr = visaCountryInfoArr.Select(x => new
- {
- x.VisaCountry,
- x.VisaPrice,
- x.Id,
- }).ToList(),
- baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
- blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
- hotelIsTrue = hotelIsTrue,
- }));
- }
- /// <summary>
- /// 团组成本信息保存
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
- {
- if (dto.Diid <= 0 || dto.Userid <= 0)
- {
- return Ok(JsonView(false));
- }
- JsonView jw = null;
- bool isTrue = false;
- #region 复制团组成本
- //if (dto.Diid == 2581)
- //{
- // dto.Diid = 2599;
- // dto.CheckBoxs.ForEach(x =>
- // {
- // x.Diid = 2599;
- // });
- // dto.GroupCosts.ForEach(x =>
- // {
- // x.Diid = 2599;
- // });
- // dto.CostTypeHotelNumbers.ForEach(x =>
- // {
- // x.Diid = 2599;
- // });
- // dto.GroupCostParameters.ForEach(x =>
- // {
- // x.DiId = 2599;
- // });
- //}
- #endregion
- var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
- Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
- var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
- Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
- var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
- var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
- try
- {
- _sqlSugar.BeginTran();
- isTrue = await _GroupCostRepository.
- SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
- isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
- isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
- isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
- _sqlSugar.CommitTran();
- jw = JsonView(true, "保存成功!", isTrue);
- }
- catch (Exception)
- {
- _sqlSugar.RollbackTran();
- jw = JsonView(false);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 复制团组成本信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
- {
- if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
- {
- return Ok(JsonView(false,"参数有误!"));
- }
- #region 复制团组成本
- dto.Diid = dto.ToGroupId;
- dto.CheckBoxs.ForEach(x =>
- {
- x.Diid = dto.ToGroupId;
- });
- dto.GroupCosts.ForEach(x =>
- {
- x.Diid = dto.ToGroupId;
- });
- dto.CostTypeHotelNumbers.ForEach(x =>
- {
- x.Diid = dto.ToGroupId;
- });
- dto.GroupCostParameters.ForEach(x =>
- {
- x.DiId = dto.ToGroupId;
- });
- #endregion
- JsonView jw = null;
- bool isTrue = false;
- var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
- Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
- var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
- Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
- var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
- var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
- try
- {
- _sqlSugar.BeginTran();
- isTrue = await _GroupCostRepository.
- SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
- isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
- isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
- isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
- _sqlSugar.CommitTran();
- jw = JsonView(true, "保存成功!", isTrue);
- }
- catch (Exception)
- {
- _sqlSugar.RollbackTran();
- jw = JsonView(false);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 司兼导数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetCarGuides(CarGuidesDto dto)
- {
- JsonView jw = null;
- var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
- jw = JsonView(true, "获取成功!", Data);
- return Ok(jw);
- }
- /// <summary>
- /// 导游数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetGuidesInfo(CarGuidesDto dto)
- {
- JsonView jw = null;
- //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
- // 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
- // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
- var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
- jw = JsonView(true, "获取成功!", Data);
- return Ok(jw);
- }
- /// <summary>
- /// 成本车数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetCarInfo(CarGuidesDto dto)
- {
- JsonView jw = null;
- var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
- jw = JsonView(true, "获取成功!", Data);
- return Ok(jw);
- }
- /// <summary>
- /// 景点数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
- {
- var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
- return Ok(JsonView(true, "获取成功!", Data));
- }
- /// <summary>
- /// 成本通知
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
- {
- if (dto.Diid < 0)
- {
- return Ok(JsonView(false));
- }
- JsonView jw = null;
- var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
- if (GroupCostParameter != null)
- {
- int IsShare = 0;
- if (GroupCostParameter.IsShare == 0) IsShare = 1;
- else if (GroupCostParameter.IsShare == 1) IsShare = 0;
- bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
- string msg = string.Empty;
- if (isTrue)
- {
- if (IsShare == 0)
- {
- msg = "禁止通知,其他模块操作人员不可见此成本信息!";
- }
- else
- {
- #region 企微通知对应岗位用户
- try
- {
- await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
- }
- catch (Exception ex)
- {
- }
- #endregion
- msg = "通知成功,其他模块操作人员可见此成本信息!";
- }
- jw = JsonView(isTrue, msg, new { IsShare });
- }
- else
- {
- msg = "修改失败!";
- jw = JsonView(isTrue, msg);
- }
- }
- else
- {
- jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
- }
- return Ok(jw);
- }
- /// <summary>
- /// 导出报价单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
- {
- if (dto.Diid == 0)
- {
- return Ok(JsonView(false, "请传递团组id"));
- }
- var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
- if (deleInfo.Code != 0)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- var di = deleInfo.Data as DelegationInfoWebView;
- if (di != null)
- {
- di.TeamName = di.TeamName.Replace("|", "、");
- di.VisitCountry = di.VisitCountry.Replace("|", "、");
- //文件名
- string strFileName = di.TeamName + "-收款账单.doc";
- //获取模板
- string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
- //载入模板
- Document doc = new Document(tmppath);
- decimal TotalPrice = 0.00M;
- string itemStr = string.Empty;
- Dictionary<string, string> airSouer = new Dictionary<string, string>();
- //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
- airSouer.Add("JJCTBR", "经济舱及酒店双人间");
- airSouer.Add("JJCSGR", "经济舱及酒店单人间");
- airSouer.Add("GWCSGR", "公务舱及酒店单人间");
- airSouer.Add("GWCJSES", "公务舱及酒店小套房");
- airSouer.Add("GWCSUITE", "公务舱及酒店套房");
- airSouer.Add("JJCSUITE", "经济舱及酒店套房");
- var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
- foreach (var cost in groupCostType)
- {
- var List = cost.ToList();
- if (cost.Key == "A")
- {
- foreach (var ListItem in List)
- {
- if (ListItem.number > 0)
- {
- if (ListItem.code.Contains("TBR"))
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- else
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- TotalPrice += (ListItem.number * ListItem.price);
- }
- }
- }
- else
- {
- itemStr = itemStr.Insert(0, "A段\r\n");
- itemStr += "B段\r\n";
- foreach (var ListItem in List)
- {
- if (ListItem.number > 0)
- {
- if (ListItem.code.Contains("TBR"))
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- else
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- TotalPrice += (ListItem.number * ListItem.price);
- }
- }
- }
- }
- #region 替换Word模板书签内容
- Dictionary<string, string> marks = new Dictionary<string, string>();
- marks.Add("To", di.ClientUnit);//付款方
- marks.Add("ToTel", di.TellPhone);//付款方电话
- marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
- marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
- marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
- marks.Add("PayDay", (di.PayDay).ToString());//付款预期
- marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
- marks.Add("WeChat", di.WeChatNo ?? "");//微信号
- marks.Add("PayItemContent", itemStr);//详细信息
- marks.Add("Total", TotalPrice.ToString("F2"));//合计
- #endregion
- ////注
- //if (doc.Range.Bookmarks["Attention"] != null)
- //{
- // Bookmark mark = doc.Range.Bookmarks["Attention"];
- // mark.Text = frList[0].Attention;
- //}
- foreach (var item in marks.Keys)
- {
- if (doc.Range.Bookmarks[item] != null)
- {
- Bookmark mark = doc.Range.Bookmarks[item];
- mark.Text = marks[item];
- }
- }
- byte[] bytes = null;
- using (MemoryStream stream = new MemoryStream())
- {
- doc.Save(stream, Aspose.Words.SaveFormat.Doc);
- bytes = stream.ToArray();
- }
- //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
- return Ok(JsonView(true, "", new
- {
- Data = bytes,
- strFileName,
- }));
- }
- else
- {
- return Ok(JsonView(false, "团组信息不存在!"));
- }
- }
- /// <summary>
- /// 导出团组成本
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
- {
- var jw = JsonView(false);
- if (dto.Diid == 0)
- {
- return Ok(JsonView(false, "请传递团组id"));
- }
- var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
- if (deleInfo.Code != 0)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- var di = deleInfo.Data as DelegationInfoWebView;
- if (di == null)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
- var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
- for (int i = 0; i < List_GC.Count; i++)
- {
- GroupCost_Excel gc = new GroupCost_Excel();
- gc.Id = List_GC[i].Id;
- gc.Diid = List_GC[i].Diid.ToString();
- gc.DAY = List_GC[i].DAY;
- string week = "";
- if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
- week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
- gc.Date = (List_GC[i].Date + "\n" + week).ToString();
- gc.ITIN = List_GC[i].ITIN;
- gc.CarType = List_GC[i].CarType;
- gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
- gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
- gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
- gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
- gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
- gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
- gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
- gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
- gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
- gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
- gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
- gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
- gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
- gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
- gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
- gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
- gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
- gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
- gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
- gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
- gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
- gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
- gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
- gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
- gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
- gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
- gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
- gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
- gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
- gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
- gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
- gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
- gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
- List_GC1.Add(gc);
- }
- var dt = CommonFun.GetDataTableFromIList(List_GC1);
- dt.TableName = "TB";
- //报表标题等不用dt的值
- designer.SetDataSource("TeamName", dto.title.TeamName);
- designer.SetDataSource("Pnumber", dto.title.GroupNumber);
- designer.SetDataSource("Tax", dto.title.Tax);
- //designer.SetDataSource("FFYS", lblHotelCB.Text);
- designer.SetDataSource("Currency", dto.title.Currency);
- //designer.SetDataSource("HotelXS", txtHotelXS.Text);
- designer.SetDataSource("Rate", dto.title.Rate);
- var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
- var Aparams = hotels.Find(x => x.Type == "Default");
- if (Aparams == null)
- {
- return Ok(jw);
- }
- //酒店数量
- var txtSGRNumber = Aparams.SGR.ToString();
- var txtTBRNumber = Aparams.TBR.ToString();
- var txtJSESNumber = Aparams.JSES.ToString();
- var txtSUITENumbe = Aparams.SUITE.ToString();
- if (dto.costType == "B")
- {
- Aparams = hotels.Find(x => x.Type == "A");
- var Bparams = hotels.Find(x => x.Type == "B");
- if (Aparams == null || Bparams == null)
- {
- return Ok(jw);
- }
- txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
- txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
- txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
- txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
- }
- designer.SetDataSource("SGRNumber", txtSGRNumber);
- designer.SetDataSource("TBRNumber", txtTBRNumber);
- designer.SetDataSource("JSESNumber", txtJSESNumber);
- designer.SetDataSource("SUITENumber", txtSUITENumbe);
- var ws = designer.Workbook.Worksheets[0];
- int Row = List_GC.Count;
- int startIndex = 11;
- int HideRows = 0;
- List<int> hideRowsList = new List<int>();
- decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
- #region A段left数据
- var left = dto.leftInfo.Find(x => x.Type == "A");
- if (left == null)
- {
- return Ok(jw);
- }
- var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
- if (leftBindData != null)
- {
- designer.SetDataSource("VisaDRCB", leftBindData.cb);
- designer.SetDataSource("VisaRS", leftBindData.rs);
- designer.SetDataSource("VisaXS", leftBindData.xs);
- designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BXDRCB", leftBindData.cb);
- designer.SetDataSource("BXRS", leftBindData.rs);
- designer.SetDataSource("BXXS", leftBindData.xs);
- designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
- if (leftBindData != null)
- {
- designer.SetDataSource("HSDRCB", leftBindData.cb);
- designer.SetDataSource("HSRS", leftBindData.rs);
- designer.SetDataSource("HSXS", leftBindData.xs);
- designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("JPJJCCB", leftBindData.cb);
- designer.SetDataSource("JPJJCPnum", leftBindData.rs);
- designer.SetDataSource("JPJJCXS", leftBindData.xs);
- designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("JPGWCCB", leftBindData.cb);
- designer.SetDataSource("JPGWCPNum", leftBindData.rs);
- designer.SetDataSource("JPGWCXS", leftBindData.xs);
- designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("JPTDCCB", leftBindData.cb);
- designer.SetDataSource("JPTDCPNum", leftBindData.rs);
- designer.SetDataSource("JPTDCXS", leftBindData.xs);
- designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
- if (leftBindData != null)
- {
- ////TBR
- designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
- designer.SetDataSource("HotelTBRRS", leftBindData.rs);
- designer.SetDataSource("HotelTBRXS", leftBindData.xs);
- designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
- if (leftBindData != null)
- {
- ////SGR
- designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
- designer.SetDataSource("HotelSGRRS", leftBindData.rs);
- designer.SetDataSource("HotelSGRXS", leftBindData.xs);
- designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
- if (leftBindData != null)
- {
- ////JS/ES
- designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
- designer.SetDataSource("HotelJSESRS", leftBindData.rs);
- designer.SetDataSource("HotelJSESXS", leftBindData.xs);
- designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
- if (leftBindData != null)
- {
- ////SUITE
- designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
- designer.SetDataSource("HotelSUITERS", leftBindData.rs);
- designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
- designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
- if (leftBindData != null)
- {
- designer.SetDataSource("DJDRCB", leftBindData.cb);
- designer.SetDataSource("DJRS", leftBindData.rs);
- designer.SetDataSource("DJXS", leftBindData.xs);
- designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("HCPCB", leftBindData.cb);
- designer.SetDataSource("HCPRS", leftBindData.rs);
- designer.SetDataSource("HCPXS", leftBindData.xs);
- designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("CPCB", leftBindData.cb);
- designer.SetDataSource("CPRS", leftBindData.rs);
- designer.SetDataSource("CPXS", leftBindData.xs);
- designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
- if (leftBindData != null)
- {
- designer.SetDataSource("GWDRCD", leftBindData.cb);
- designer.SetDataSource("GWRS", leftBindData.rs);
- designer.SetDataSource("GWXS", leftBindData.xs);
- designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
- if (leftBindData != null)
- {
- designer.SetDataSource("LYJDRCB", leftBindData.cb);
- designer.SetDataSource("LYJRS", leftBindData.rs);
- designer.SetDataSource("LYJXS", leftBindData.xs);
- designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- #endregion
- #region A段Right信息
- var right = dto.rightInfo.Find(x => x.Type == "A");
- if (right == null)
- {
- return Ok(jw);
- }
- HideRows += 4;
- var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
- if (rightBindData != null)
- {
- //经济舱 + 双人间 TBR
- designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
- designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
- designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
- designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
- if (rightBindData != null)
- {
- //经济舱 + 单人间 SGR
- designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
- designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
- designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
- if (rightBindData != null)
- {
- //公务舱 + 单人间 SGR
- designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
- designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
- designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
- designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
- designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
- designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
- designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
- if (rightBindData != null)
- {
- //经济舱 + 大套房
- designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
- designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
- if (rightBindData != null)
- {
- //头等舱 + 小套房 JSES
- designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
- designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
- designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
- designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
- if (rightBindData != null)
- {
- //头等舱 + 大套房
- designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
- designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- #endregion
- #region B段标题清空
- designer.SetDataSource("CostBDRCB", "");
- designer.SetDataSource("CostBRS", "");
- designer.SetDataSource("CostBXS", "");
- designer.SetDataSource("CostBZCB", "");
- designer.SetDataSource("CostBDRBJ", "");
- designer.SetDataSource("CostBZBJ", "");
- designer.SetDataSource("CostBDRLR", "");
- designer.SetDataSource("CostBZLR", "");
- designer.SetDataSource("CostBDRCBOM", "");
- designer.SetDataSource("CostBRSOM", "");
- designer.SetDataSource("CostBZCBOM", "");
- designer.SetDataSource("CostBDRBJOM", "");
- designer.SetDataSource("CostBZBJOM", "");
- designer.SetDataSource("CostBDRLROM", "");
- designer.SetDataSource("CostBZLROM", "");
- #endregion
- designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
- designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
- designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
- designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
- designer.SetDataSource("DJName", "地接(CNY)");
- designer.SetDataSource("HCPName", "地接-火车票(CNY)");
- designer.SetDataSource("CPName", "地接-船票(CNY)");
- designer.SetDataSource("GWName", "公务(CNY)");
- designer.SetDataSource("YQHName", "邀请函(CNY)");
- designer.SetDataSource("LYJName", "零用金(CNY)");
- designer.SetDataSource("HSName", "核酸检测(CNY)");
- designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
- designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
- designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
- designer.SetDataSource("BXName", "保险(CNY)");
- designer.SetDataSource("VisaName", "签证(CNY)");
- #region B段基本数据
- if (dto.costType == "B")
- {
- left = dto.leftInfo.Find(x => x.Type == "B");
- if (left == null)
- {
- return Ok(jw);
- }
- #region B段left数据
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHSDRCB", leftBindData.cb);
- designer.SetDataSource("BHSRS", leftBindData.rs);
- designer.SetDataSource("BHSXS", leftBindData.xs);
- designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BJPJJCCB", leftBindData.cb);
- designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
- designer.SetDataSource("BJPJJCXS", leftBindData.xs);
- designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BJPGWCCB", leftBindData.cb);
- designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
- designer.SetDataSource("BJPGWCXS", leftBindData.xs);
- designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BJPTDCCB", leftBindData.cb);
- designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
- designer.SetDataSource("BJPTDCXS", leftBindData.xs);
- designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHCPCB", leftBindData.cb);
- designer.SetDataSource("BHCPRS", leftBindData.rs);
- designer.SetDataSource("BHCPXS", leftBindData.xs);
- designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BCPCB", leftBindData.cb);
- designer.SetDataSource("BCPRS", leftBindData.rs);
- designer.SetDataSource("BCPXS", leftBindData.xs);
- designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //TBR
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
- designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
- designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //SGR
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
- designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
- designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //JS/ES
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
- designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
- designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //SUITE
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
- designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
- designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BDJDRCB", leftBindData.cb);
- designer.SetDataSource("BDJRS", leftBindData.rs);
- designer.SetDataSource("BDJXS", leftBindData.xs);
- designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BGWDRCD", leftBindData.cb);
- designer.SetDataSource("BGWRS", leftBindData.rs);
- designer.SetDataSource("BGWXS", leftBindData.xs);
- designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- #region 优化方案
- //Dictionary<string, object> excelBind = new Dictionary<string, object>();
- //excelBind.Add("零用金", new {
- //cb="",
- //rs="",
- //xs ="",
- //zcb = "",
- //});
- #endregion
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BLYJDRCB", leftBindData.cb);
- designer.SetDataSource("BLYJRS", leftBindData.rs);
- designer.SetDataSource("BLYJXS", leftBindData.xs);
- designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- #endregion
- #region B段Right信息
- right = dto.rightInfo.Find(x => x.Type == "B");
- if (right == null)
- {
- return Ok(jw);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
- if (rightBindData != null)
- {
- //经济舱 + 双人间 TBR
- designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
- designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
- if (rightBindData != null)
- {
- //经济舱 + 单人间 SGR
- designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
- designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
- if (rightBindData != null)
- {
- //公务舱 + 单人间 SGR
- designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
- designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
- designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
- designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
- designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
- if (rightBindData != null)
- {
- //经济舱 + 大套房
- designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
- designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
- if (rightBindData != null)
- {
- //头等舱 + 小套房 JSES
- designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
- designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
- if (rightBindData != null)
- {
- //头等舱 + 大套房
- designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
- designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- #endregion
- #region 标题
- designer.SetDataSource("CostBDRCB", "单人成本");
- designer.SetDataSource("CostBRS", "人数");
- designer.SetDataSource("CostBXS", "系数");
- designer.SetDataSource("CostBZCB", "总成本");
- designer.SetDataSource("CostBDRBJ", "单人报价");
- designer.SetDataSource("CostBZBJ", "总报价");
- designer.SetDataSource("CostBDRLR", "单人利润");
- designer.SetDataSource("CostBZLR", "总利润");
- designer.SetDataSource("CostBDRCBOM", "单人成本");
- designer.SetDataSource("CostBRSOM", "人数");
- designer.SetDataSource("CostBZCBOM", "总成本");
- designer.SetDataSource("CostBDRBJOM", "单人报价");
- designer.SetDataSource("CostBZBJOM", "总报价");
- designer.SetDataSource("CostBDRLROM", "单人利润");
- designer.SetDataSource("CostBZLROM", "总利润");
- #endregion
- }
- #endregion
- designer.SetDataSource("TzZCB2", TzZCB2);
- designer.SetDataSource("TzZBJ2", TzZBJ2);
- designer.SetDataSource("TzZLR2", TzZLR2);
- string[] dataSourceKeys = new string[]
- {
- "VF",
- "TGS",
- "TGOF",
- "TGM",
- "TGA",
- "TGTF",
- "TGEF",
- "CFM",
- "CFOF",
- "B",
- "L",
- "D",
- "TBR",
- "SGR",
- "JSES",
- "Suite",
- "TV",
- "1L",
- "IF",
- "EF",
- "BRF",
- "TE",
- "TGT",
- "DRVT",
- "PC",
- "TLF",
- "ECT"
- };
- foreach (var item in dataSourceKeys)
- {
- var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
- if (find != null)
- {
- designer.SetDataSource(item, find.text);
- }
- else
- {
- designer.SetDataSource(item, 0);
- }
- }
- designer.SetDataSource(dt);
- //根据数据源处理生成报表内容
- designer.Process();
- designer.Workbook.Worksheets[0].Name = "清单";
- Worksheet sheet = designer.Workbook.Worksheets[0];
- foreach (var Rowindex in hideRowsList)
- {
- ws.Cells.HideRows(Rowindex, 2);
- }
- byte[] bytes = null;
- string strFileName = di.TeamName + "-团组-成本.xls";
- using (MemoryStream stream = new MemoryStream())
- {
- designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
- bytes = stream.ToArray();
- }
- return Ok(JsonView(true, "", new
- {
- Data = bytes,
- strFileName,
- }));
- }
- /// <summary>
- /// 导出客户报表
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
- {
- var jw = JsonView(false);
- if (dto.Diid == 0)
- {
- return Ok(JsonView(false, "请传递团组id"));
- }
- var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
- if (deleInfo.Code != 0)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- var di = deleInfo.Data as DelegationInfoWebView;
- if (di == null)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- //文件名
- //string strFileName = di.TeamName + "-团组-客户报价.doc";
- //获取模板
- string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
- //载入模板
- Document doc = new Document(tmppath);
- Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
- Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
- DickeyValue.Add("DickeyValue", di.TeamName); //团组名
- var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
- var AParameter = ParameterList.Find(x => x.CostType == "A");
- var BParameter = ParameterList.Find(x => x.CostType == "B");
- if (AParameter == null)
- {
- return Ok(JsonView(false, "系数不存在!"));
- }
- string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
- , TzAirDesc, TzZCost;
- CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
- = TzAirDesc = TzZCost = string.Empty;
- TzNumber = AParameter.CostTypenumber.ToString();
- CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
- CarGuides1 = dto.CarGuides1;
- Meal = dto.Meal;
- SubsidizedMeals = dto.SubsidizedMeals;
- NightRepair = dto.NightRepair;
- AttractionsTickets = dto.AttractionsTickets;
- MiscellaneousFees = dto.MiscellaneousFees;
- ATip = dto.ATip;
- TzHotelDesc = "";
- Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
- PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
- Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
- TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
- TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
- TzAirDesc = "";
- TzZCost = dto.TzZCost;
- var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
- var TzAirDescArr = new string[] { "经济舱", "公务舱" };
- var index = 1;
- var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
- foreach (var item in TzHotelDescArr)
- {
- if (AinfoArr != null)
- {
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- var hotelText = string.Empty;
- switch (item)
- {
- case "SGR":
- hotelText = "单人间";
- break;
- case "JSES":
- hotelText = "小套房";
- break;
- case "SUITE":
- hotelText = "套房";
- break;
- case "TBR":
- hotelText = "双人间";
- break;
- }
- if (item != "TBR")
- {
- 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";
- }
- else
- {
- 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";
- }
- index++;
- }
- }
- }
- index = 1;
- foreach (var item in TzAirDescArr)
- {
- if (AinfoArr != null)
- {
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- 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";
- index++;
- }
- }
- }
- if (dto.costType == "B")
- {
- if (BParameter == null)
- {
- return Ok(JsonView(false, "B段系数不存在!"));
- }
- CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
- Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
- PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
- Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
- TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
- TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
- AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
- foreach (var item in TzHotelDescArr)
- {
- if (AinfoArr != null)
- {
- TzHotelDesc += "B段信息 \r\n";
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- var hotelText = string.Empty;
- switch (item)
- {
- case "SGR":
- hotelText = "单人间";
- break;
- case "JSES":
- hotelText = "小套房";
- break;
- case "SUITE":
- hotelText = "套房";
- break;
- case "TBR":
- hotelText = "双人间";
- break;
- }
- if (item != "TBR")
- {
- 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";
- }
- else
- {
- 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";
- }
- index++;
- }
- TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
- }
- }
- index = 1;
- foreach (var item in TzAirDescArr)
- {
- if (AinfoArr != null)
- {
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- 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";
- index++;
- }
- }
- }
- }
- Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
- DickeyValue.Add("TzNumber", TzNumber); //团组人数
- DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
- DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
- DickeyValue.Add("Meal", Meal); // 地接 - 餐费
- DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
- DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
- DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
- DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
- DickeyValue.Add("ATip", ATip); // 地接 - 小费
- DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
- DickeyValue.Add("Offcial", Offcial); // 公务单人报价
- DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
- DickeyValue.Add("Visa", Visa); // 签证单人报价
- DickeyValue.Add("TrainTicket", TrainTicket); //火车票
- DickeyValue.Add("TicketPrice", TicketPrice); //船票
- DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
- DickeyValue.Add("TzZCost", TzZCost);
- foreach (var key in DickeyValue.Keys)
- {
- if (doc.Range.Bookmarks[key] != null)
- {
- Bookmark mark = doc.Range.Bookmarks[key];
- mark.Text = DickeyValue[key];
- }
- }
- byte[] bytes = null;
- string strFileName = di.TeamName + "-客户报价.doc";
- using (MemoryStream stream = new MemoryStream())
- {
- doc.Save(stream, Aspose.Words.SaveFormat.Doc);
- bytes = stream.ToArray();
- }
- return Ok(JsonView(true, "", new
- {
- Data = bytes,
- strFileName,
- }));
- }
- /// <summary>
- /// 团组成本 各模块(酒店,地接,机票)成本提示
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
- {
- try
- {
- #region 参数验证
- if (dto.DiId < 0)
- {
- return Ok(JsonView(false, "请传入有效的DiId参数!"));
- }
- List<int> cTableIds = new List<int>() {
- 76 ,//酒店预订
- 77 ,//行程
- 79 ,//车/导游地接
- 80 ,//签证
- 81 ,//邀请/公务活
- 82 ,//团组客户保险
- 85 ,//机票预订
- 98 ,//其他款项
- 285 ,//收款退还
- 751 ,//酒店早餐
- 1015 // 超支费用
- };
- if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
- {
- return Ok(JsonView(false, "请传入有效的CTable参数!"));
- }
- #endregion
- //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
- var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
- if (_GroupCostParameters.Count <= 0)
- {
- return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
- }
- if (_GroupCostParameters[0].IsShare == 0)
- {
- return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
- }
- var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
- //处理date为空问题
- if (_GroupCosts.Count > 0)
- {
- for (int i = 0; i < _GroupCosts.Count; i++)
- {
- if (string.IsNullOrEmpty(_GroupCosts[i].Date))
- {
- if (i > 0)
- {
- _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
- }
- }
- }
- }
- GroupCostModulePromptView _view = new GroupCostModulePromptView();
- List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
- var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
- string currCode = "";
- #region currCode 验证
- bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
- if (isInt)
- {
- var currData = currDatas.Find(it => it.Id == intCurrency);
- if (currData != null)
- {
- currCode = currData.Name;
- }
- }
- else
- {
- currCode = _GroupCostParameters[0].Currency.Trim();
- }
- #endregion
- //op,酒店单段模式存储
- GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
- {
- CurrencyCode = currCode,
- Rate = _GroupCostParameters[0].Rate,
- CostType = _GroupCostParameters[0].CostType,
- CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
- CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
- CostTypeNumber = _GroupCostParameters[0].CostTypenumber
- };
- List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
- if (_GroupCostParameters.Count == 2)
- {
- _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
- }
- foreach (var item in _GroupCostParameters)
- {
- decimal _rate = 1;
- decimal _rate1 = item.Rate;
- decimal _scale = 1;
- //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
- #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
- //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- //if (userInfo != null)
- //{
- // if (userInfo.DepId == 1 || userInfo.DepId == 7)
- // {
- // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
- // {
- // _scale = 1.00M;
- // }
- // }
- //}
- #endregion
- GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
- {
- CurrencyCode = currCode,
- Rate = _rate1,
- CostType = item.CostType,
- CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
- CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
- CostTypeNumber = item.CostTypenumber
- };
- if (_GroupCostParameters.Count > 1)
- {
- modulePromptInfo.CostTypeNumber = item.CostTypenumber;
- }
- else
- {
- modulePromptInfo.CostTypeNumber = item.LYJRS;
- }
- if (dto.CTable == 79)//
- {
- modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
- modulePromptInfo.TotalCost = item.DJCB;
- }
- List<string> costTypes = new List<string>() { "A", "B" };
- List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
- var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
- if (_GroupCostsDuplicates.Count() == 1)
- {
- _GroupCostsTypeData = _GroupCosts;
- }
- else
- {
- _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
- Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
- }
- /*
- * 76 酒店预订
- * 77 行程
- * 79 车/导游地接
- * 80 签证
- * 81 邀请/公务活动
- * 82 团组客户保险
- * 85 机票预订
- * 98 其他款项
- * 285 收款退还
- * 751 酒店早餐
- * 1015 超支费用
- */
- switch (dto.CTable)
- {
- case 76: // 酒店预订
- _ModuleSubPromptInfo.AddRange(
- _GroupCostsTypeData.Select(it => new
- {
- it.DAY,
- it.Date,
- it.ACCON,
- it.ITIN,
- it.SGR,
- it.TBR,
- it.JS_ES,
- it.Suite
- })
- );
- break;
- case 79: // 车/导游地接
- _ModuleSubPromptInfo.AddRange(
- _GroupCostsTypeData.Select(it => new
- {
- Date = it.Date, //日期
- CarFee = it.CarCost * _rate * _scale, //车费用
- CarType = it.CarType, //车型
- DriverFee = it.CFS * _rate * _scale, //司机工资
- DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
- DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
- DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
- GuideFee = it.TGS * _rate * _scale, //导游费用
- GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
- GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
- GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
- GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
- GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
- GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
- Breakfast = it.B * _rate * _scale, //早餐费
- Lunch = it.L * _rate * _scale, //午餐费
- Dinner = it.D * _rate * _scale, //晚餐费
- OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
- OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
- InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
- TicketFee = it.EF * _rate * _scale, //门票费
- TicketRemark = it.EFR, //门票费描述
- DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
- TravelSupplies = it.TE * _rate * _scale, //出行物资
- SpentCash = it.PC * _rate * _scale, //零用金
- LeadersFee = it.TLF * _rate * _scale, //领队费
- ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
- })
- );
- break;
- case 85: // 机票
- List<dynamic> datas = new List<dynamic>();
- datas.Add(
- new
- {
- AirType = "经济舱",
- AirNum = item.JJCRS,
- AirDRCB = item.JJCCB,
- AirZCB = (item.JJCRS * item.JJCCB)
- }
- );
- datas.Add(
- new
- {
- AirType = "公务舱",
- AirNum = item.GWCRS,
- AirDRCB = item.GWCCB,
- AirZCB = (item.GWCRS * item.GWCCB)
- }
- );
- var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
- var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
- modulePromptInfo.Data = new
- {
- airFeeData = datas,
- airInitData = initDatas
- };
- _ModulePromptInfos.Add(modulePromptInfo);
- break;
- default:
- break;
- }
- }
- if (dto.CTable != 85)
- {
- _ModulePromptInfo.Data = _ModuleSubPromptInfo;
- _ModulePromptInfos.Add(_ModulePromptInfo);
- }
- _view.ModulePromptInfos = _ModulePromptInfos;
- return Ok(JsonView(true, "操作成功!", _view));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 根据黑屏代码重新生成行程
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
- {
- var jw = JsonView(false,"Error");
- var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
- .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
- .Select(x=> new
- {
- x.Id,
- x.Title
- })
- .ToList();
- if (Create.Any())
- {
- jw.Msg = "获取成功!";
- jw.Code = 200;
- jw.Data = new
- {
- BlackCodeListSelect = Create,
- blackCodeIsTrue = true
- };
- }
- else
- {
- jw.Code = 400;
- jw.Data = new
- {
- BlackCodeListSelect = Create,
- blackCodeIsTrue = false,
- };
- }
- return Ok(jw);
- }
- /// <summary>
- /// 根据黑屏代码Id重新生成行程
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
- {
- var jw = JsonView(false, "Error");
- var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
- if (result.Code == 0)
- {
- jw.Msg = "获取成功!";
- jw.Code = 200;
- jw.Data = new
- {
- groupCost = result.Data,
- blackCodeIsTrue = true
- };
- }
- else
- {
- jw.Code = 400;
- jw.Data = new
- {
- groupCost = result.Data,
- blackCodeIsTrue = false,
- };
- }
- return Ok(jw);
- }
- /// <summary>
- /// 成本获取OP历史车费用
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
- {
- var jw = JsonView(false);
- try
- {
- List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
- //获取现有所有车的数据
- if (!dto.Param.IsNullOrWhiteSpace())
- {
- string sql = $@"
- SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
- FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
- gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
- 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
- AND gctggr.ServiceEndTime is not NULL
- ORDER by gctggrc.id DESC
- ";
- dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
- var numeberResult = await Task.Run(() =>
- {
- var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
- _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
- return numberArr;
- });
- var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
- foreach (var item in numeberResult)
- {
- var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
- {
- Country = "数据异常!",
- City = string.Empty,
- };
- item.Area = find.Country + " " + find.City;
- }
- dbResult.AddRange(numeberResult);
- if (dto.Param.Contains("、"))
- {
- var sp = dto.Param.Split("、");
- dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
- .Where(x =>
- {
- return System.Array.Exists(sp, e =>
- {
- bool where = false;
- if (x.Area != null)
- {
- where = x.Area.Contains(e);
- if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
- {
- return false;
- }
- }
- if (x.PriceName != null && !where)
- {
- where = x.PriceName.Contains(e);
- if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
- {
- return false;
- }
- }
- return where;
- });
- }).ToList();
- }
- else
- {
- dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
- .Where(x =>
- {
- bool where = false;
- if (x.Area != null)
- {
- where = x.Area.Contains(dto.Param);
- if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
- {
- return false;
- }
- }
- if (x.PriceName != null && !where)
- {
- where = x.PriceName.Contains(dto.Param);
- if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
- {
- return false;
- }
- }
- return where;
- }
- )
- .ToList();
- }
- }
- var view = dbResult.Select(x =>
- {
- decimal dp = 0.00M;
- var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
- var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
- if (string.IsNullOrWhiteSpace(x.DatePrice))
- {
- if (startB && endB)
- {
- var timesp = endD.Subtract(startD);
- if ((timesp.Days + 1) != 0)
- {
- dp = x.Price / (timesp.Days + 1);
- }
- }
- }
- else
- {
- dp = x.Price;
- }
- return new
- {
- start = startB ? startD.ToString("yyyy-MM-dd") : "",
- end = endB ? endD.ToString("yyyy-MM-dd") : "",
- x.Area,
- x.id,
- price = x.Price.ToString("F2"),
- x.PriceName,
- x.PriceContent,
- x.TeamName,
- x.DatePrice,
- dayPrice = dp.ToString("F2"),
- };
- }).OrderByDescending(x => x.id).ToList();
- jw = JsonView(true, "获取成功!", view);
- }
- catch (Exception e)
- {
- jw = JsonView(false, e.Message);
- }
- return Ok(jw);
- }
- [HttpPost]
- public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
- {
- var jw = JsonView(true);
- List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
- if (string.IsNullOrWhiteSpace(dto.Keyword))
- {
- matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
- Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
- WHEN COUNT(*) >= 0 THEN 'True'
- ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
- Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
- ")
- .ToList();
- }
- else
- {
- string likeKey = string.Empty;
- foreach (var item in dto.Keyword)
- {
- likeKey += "%" + item;
- }
- likeKey += "%";
- matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
- Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
- WHEN COUNT(*) >= 0 THEN 'True'
- ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
- Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
- ")
- .ToList();
- }
- if (matches.Any())
- {
- jw.Data = matches;
- }
- else
- {
- jw.Code = 201;
- jw.Msg = "empty list";
- jw.Data = new List<string>(1);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 报价Word下载
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
- {
- var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
- .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
- if (di == null)
- {
- return Ok(JsonView(false, "团组不存在!"));
- }
- var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
- if (mainPrice == null || mainPrice.IsShare == 0)
- {
- return Ok(JsonView(false, "团组成本不存在!"));
- }
- var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
- .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
- if (costTypeHotelNumbers == null)
- {
- return Ok(JsonView(false, "团组成本不存在!"));
- }
- //文件名
- string strFileName = di.TeamName + "-收款账单.doc";
- //获取模板
- string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
- //载入模板
- Document doc = new Document(tmppath);
- decimal allPrice = 0.00M;
- string itemStr = string.Empty;
- Dictionary<string, string> airSouer = new Dictionary<string, string>();
- airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
- airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
- airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
- airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
- airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
- airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
- airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
- airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
- airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
- var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
- {
- ("VisaRS", "VisaCB", "VisaXS", "qz"),
- ("BXRS", "BXCB", "BXXS", "bx"),
- ("HCPRS", "HCPCB", "HCPXS", "hcp"),
- ("JJCRS", "JJCCB", "JJCXS", "jjc"),
- ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
- ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
- ("CPRS", "CPCB", "CPXS", "cp") ,
- ("HSRS", "HSCB", "HSXS", "hsjc") ,
- ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
- ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
- ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
- ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
- ("DJRS", "DJCB", "DJXS", "dj") ,
- ("GWRS", "GWCB", "GWXS", "gw") ,
- ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
- };
- var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
- var rightSum = 0.00M;
- foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
- {
- var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
- var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
- var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
- if (prefix == "tbr")
- {
- rsValue *= 2;
- cbValue /= 2;
- }
- if (OtherCostPropertyBJ.Contains(prefix))
- {
- rightSum += cbValue * xsValue;
- }
- }
- var hotelRooms = new Dictionary<string, int>
- {
- { "SGR", costTypeHotelNumbers.SGR },
- { "TBR", costTypeHotelNumbers.TBR },
- { "JSES", costTypeHotelNumbers.JSES },
- { "SUITE", costTypeHotelNumbers.SUITE }
- };
- var flights = new Dictionary<string, int>
- {
- { "经济舱", mainPrice.JJCRS },
- { "公务舱", mainPrice.GWCRS },
- { "头等舱", mainPrice.TDCRS }
- };
- var flightRoomMatchingRules = new Dictionary<string, string[]>
- {
- { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
- { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
- { "头等舱", new[] { "SUITE", "JSES" } }
- };
- var result = new Dictionary<string, int>();
- List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
- foreach (var flight in flights.Keys)
- {
- // 获取当前舱位的匹配规则
- if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
- {
- MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
- }
- }
- #region right计算
- if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
- {
- var air = mainPrice.JJCCB * mainPrice.JJCXS;
- var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
- airHotelPriceList.Add(new
- AirHotelPrice
- {
- Name = "经济舱TBR",
- Price = rightSum + air + hotel,
- Count = result["经济舱TBR"] * 2
- });
- allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
- }
- if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
- {
- var air = mainPrice.JJCCB * mainPrice.JJCXS;
- var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
- airHotelPriceList.Add(new
- AirHotelPrice
- {
- Name = "经济舱SGR",
- Price = rightSum + air + hotel,
- Count = result["经济舱SGR"]
- });
- allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
- }
- if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
- {
- var air = mainPrice.GWCCB * mainPrice.GWCXS;
- var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
- airHotelPriceList.Add(new
- AirHotelPrice
- {
- Name = "公务舱SGR",
- Price = rightSum + air + hotel,
- Count = result["公务舱SGR"]
- });
- allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
- }
- if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
- {
- var air = mainPrice.GWCCB * mainPrice.GWCXS;
- var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
- airHotelPriceList.Add(new
- AirHotelPrice
- {
- Name = "公务舱JSES",
- Price = rightSum + air + hotel,
- Count = result["公务舱JSES"]
- });
- allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
- }
- if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
- {
- var air = mainPrice.GWCCB * mainPrice.GWCXS;
- var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
- airHotelPriceList.Add(new
- AirHotelPrice
- {
- Name = "公务舱SUITE",
- Price = rightSum + air + hotel,
- Count = result["公务舱SUITE"]
- });
- allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
- }
- if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
- {
- var air = mainPrice.JJCCB * mainPrice.JJCXS;
- var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
- airHotelPriceList.Add(new
- AirHotelPrice
- {
- Name = "经济舱SUITE",
- Price = rightSum + air + hotel,
- Count = result["经济舱SUITE"]
- });
- allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
- }
- if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
- {
- var air = mainPrice.TDCCB * mainPrice.TDCXS;
- var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
- airHotelPriceList.Add(new
- AirHotelPrice
- {
- Name = "头等舱JSES",
- Price = rightSum + air + hotel,
- Count = result["头等舱JSES"]
- });
- allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
- }
- if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
- {
- var air = mainPrice.TDCCB * mainPrice.TDCXS;
- var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
- airHotelPriceList.Add(new
- AirHotelPrice
- {
- Name = "头等舱SUITE",
- Price = rightSum + air + hotel,
- Count = result["头等舱SUITE"]
- });
- allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
- }
- if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
- {
- var air = mainPrice.JJCCB * mainPrice.JJCXS;
- var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
- airHotelPriceList.Add(new
- AirHotelPrice
- {
- Name = "经济舱JSES",
- Price = rightSum + air + hotel,
- Count = result["经济舱JSES"]
- });
- allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
- }
- #endregion
- foreach (var item in airSouer.Keys)
- {
- var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
- if (find != null && find.Count > 0)
- {
- if (item.Contains("TBR"))
- {
- itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
- }
- else
- {
- itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
- }
- }
- }
- #region 替换Word模板书签内容
- Dictionary<string, string> marks = new Dictionary<string, string>();
- marks.Add("To", di.ClientUnit);//付款方
- marks.Add("ToTel", di.TellPhone);//付款方电话
- marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
- marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
- marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
- marks.Add("PayDay", (di.PayDay).ToString());//付款预期
- marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
- marks.Add("WeChat", di.WeChatNo ?? "");//微信号
- marks.Add("PayItemContent", itemStr);//详细信息
- marks.Add("Total", allPrice.ToString("F2"));//合计
- #endregion
- foreach (var item in marks.Keys)
- {
- if (doc.Range.Bookmarks[item] != null)
- {
- Bookmark mark = doc.Range.Bookmarks[item];
- mark.Text = marks[item];
- }
- }
- string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
- doc.Save(savePaht);
- var jw = new JsonView();
- jw.Msg = "生成成功!";
- jw.Code = 200;
- jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
- return Ok(jw);
- }
- /// <summary>
- /// 详细报价费用Excel下载
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
- {
- var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
- .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
- if (di == null)
- {
- return Ok(JsonView(false, "团组不存在!"));
- }
- var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
- if (mainPrice == null || mainPrice.IsShare == 0)
- {
- return Ok(JsonView(false, "团组成本不存在!"));
- }
- var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
- .FirstAsync(x=>x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
- if (costTypeHotelNumbers == null)
- {
- return Ok(JsonView(false, "团组成本不存在!"));
- }
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
- List<int> hideRowsList = new List<int>();
- int conterStartIndex = 3;
- int rowIndex = conterStartIndex;
- designer.SetDataSource("GroupName", di.TeamName);
- var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
- {
- ("VisaRS", "VisaCB", "VisaXS", "qz"),
- ("BXRS", "BXCB", "BXXS", "bx"),
- ("HCPRS", "HCPCB", "HCPXS", "hcp"),
- ("JJCRS", "JJCCB", "JJCXS", "jjc"),
- ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
- ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
- ("CPRS", "CPCB", "CPXS", "cp") ,
- ("HSRS", "HSCB", "HSXS", "hsjc") ,
- ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
- ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
- ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
- ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
- ("DJRS", "DJCB", "DJXS", "dj") ,
- ("GWRS", "GWCB", "GWXS", "gw") ,
- ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
- };
- var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
- var rightSum = 0.00M;
- foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
- {
- var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
- var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
- var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
- if (prefix == "tbr")
- {
- rsValue *= 2;
- cbValue /= 2;
- }
- if (OtherCostPropertyBJ.Contains(prefix))
- {
- rightSum += cbValue * xsValue;
- }
- if (rsValue == 0)
- {
- hideRowsList.Add(rowIndex);
- }
- else
- {
- designer.SetDataSource($"{prefix}rs", rsValue);
- designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
- designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
- }
- rowIndex += 2;
- }
- var hotelRooms = new Dictionary<string, int>
- {
- { "SGR", costTypeHotelNumbers.SGR },
- { "TBR", costTypeHotelNumbers.TBR },
- { "JSES", costTypeHotelNumbers.JSES },
- { "SUITE", costTypeHotelNumbers.SUITE }
- };
- var flights = new Dictionary<string, int>
- {
- { "经济舱", mainPrice.JJCRS },
- { "公务舱", mainPrice.GWCRS },
- { "头等舱", mainPrice.TDCRS }
- };
- var flightRoomMatchingRules = new Dictionary<string, string[]>
- {
- { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
- { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
- { "头等舱", new[] { "SUITE", "JSES" } }
- };
- var result = new Dictionary<string, int>();
- foreach (var flight in flights.Keys)
- {
- // 获取当前舱位的匹配规则
- if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
- {
- MatchRooms(ref hotelRooms,ref flights, roomTypes, flight,ref result);
- }
- }
- var allPrice = 0.00M;
- #region right计算
- int airRowIndex = 35;
- if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
- {
- var air = mainPrice.JJCCB * mainPrice.JJCXS;
- var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
- designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
- designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
- designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
- allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
- }
- else
- {
- hideRowsList.Add(airRowIndex);
- }
- airRowIndex += 2;
- if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
- {
- var air = mainPrice.JJCCB * mainPrice.JJCXS;
- var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
- designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
- designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
- designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
- allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
- }
- else
- {
- hideRowsList.Add(airRowIndex);
- }
- airRowIndex += 2;
- if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
- {
- var air = mainPrice.GWCCB * mainPrice.GWCXS;
- var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
- designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
- designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
- designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
- allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
- }
- else
- {
- hideRowsList.Add(airRowIndex);
- }
- airRowIndex += 2;
- if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
- {
- var air = mainPrice.GWCCB * mainPrice.GWCXS;
- var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
- designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
- designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
- designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
- allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
- }
- else
- {
- hideRowsList.Add(airRowIndex);
- }
- airRowIndex += 2;
- if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
- {
- var air = mainPrice.GWCCB * mainPrice.GWCXS;
- var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
- designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
- designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
- designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
- allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
- }
- else
- {
- hideRowsList.Add(airRowIndex);
- }
- airRowIndex += 2;
- if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
- {
- var air = mainPrice.JJCCB * mainPrice.JJCXS;
- var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
- designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
- designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
- designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
- allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
- }
- else
- {
- hideRowsList.Add(airRowIndex);
- }
- airRowIndex += 2;
- if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
- {
- var air = mainPrice.TDCCB * mainPrice.TDCXS;
- var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
- designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
- designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
- designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
- allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
- }
- else
- {
- hideRowsList.Add(airRowIndex);
- }
- airRowIndex += 2;
- if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
- {
- var air = mainPrice.TDCCB * mainPrice.TDCXS;
- var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
- designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
- designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
- designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
- allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
- }
- else
- {
- hideRowsList.Add(airRowIndex);
- }
- airRowIndex += 2;
- if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
- {
- var air = mainPrice.JJCCB * mainPrice.JJCXS;
- var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
- designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
- designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
- designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
- allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
- }
- else
- {
- hideRowsList.Add(airRowIndex);
- }
- #endregion
- designer.SetDataSource("AllPrice","总金额:" + allPrice.ToString("#0.00"));
- string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName +"_详细报批费用.xls";
- var ws = designer.Workbook.Worksheets[0];
- foreach (var Rowindex in hideRowsList)
- {
- ws.Cells.HideRows(Rowindex, 2);
- }
- designer.Process();
- designer.Workbook.Save(savePaht);
- return Ok(JsonView(true, "生成成功!", new
- {
- Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
- }));
- }
- private void MatchRooms(ref Dictionary<string, int> hotelRooms,ref Dictionary<string, int> flights, string[] roomTypes, string flightType,ref Dictionary<string, int> result)
- {
- foreach (var roomType in roomTypes)
- {
- while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
- {
- hotelRooms[roomType]--;
- flights[flightType]--;
- if (roomType == "TBR")
- {
- flights[flightType]--; // 双人间在减少1
- }
- string key = flightType + roomType;
- if (result.Keys.Contains(key))
- {
- result[key]++;
- }
- else
- {
- result.Add(key, 1);
- }
- }
- }
- }
- private class AirHotelPrice
- {
- public string Name { get; set; }
- public decimal Price { get; set; }
- public int Count { get; set; }
- }
- #endregion
- #region 酒店预订 新 雷怡 2023-12-28 17:45
- /// <summary>
- /// 酒店预订
- /// 酒店费用列表 根据团组Id查询
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
- }
- /// <summary>
- /// 酒店预订
- /// 基础数据
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- #endregion
- return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
- }
- /// <summary>
- /// 酒店预订
- /// 创建 入住卷号码
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- #endregion
- Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- /// <summary>
- /// 酒店预订
- /// 详情
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
- }
- /// <summary>
- /// 酒店预订
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (_dto.Id == 0) // Add
- {
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
- }
- else if (_dto.Id > 1) // Edit
- {
- if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
- }
- else return Ok(JsonView(false, "请输入正确的数据Id!"));
- #endregion
- #endregion
- JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
- if (_view.Code != 200)
- {
- return Ok(_view);
- }
- #region 成本无酒店价格数据进入超支
- _sqlSugar.BeginTran();
- var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
- var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
- var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
- for (int i = 0; i < groupCost.Count; i++)
- {
- if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
- {
- groupCost[i].Date = groupCost[i - 1].Date;
- }
- }
- var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
- List<Fin_GroupExtraCostDto_OP> extraCostList = new
- List<Fin_GroupExtraCostDto_OP>();
- if (start_Bool && end_Bool)
- {
- while (start_Time < end_Time)
- {
- foreach (var item in groupCost_Grp)
- {
- if (DateTime.TryParse(item.Key, out DateTime cost_Time))
- {
- if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
- {
- extraCostList.Add(new
- Fin_GroupExtraCostDto_OP
- {
- Area = _dto.AreaId,
- coefficient = 1.5M,
- createUser = _dto.UserId,
- currency = _dto.CardPriceCurrency,
- diId = _dto.DiId,
- ManagerConfirm = 0,
- SupervisorConfirm = 0,
- SYsupervisorConfirm = 0,
- editType = 1,
- PortType = 1,
- price = _dto.CardPrice,
- PriceCount = 1,
- priceType = 1027,
- priceDetailType = 1044,
- PriceDt = start_Time.ToString("yyyy-MM-dd"),
- priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
- });
- }
- }
- }
- start_Time = start_Time.AddDays(1);
- }
- }
- if (extraCostList.Any())
- {
- await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
- }
- _sqlSugar.CommitTran();
- #endregion
- #region 应用推送
- try
- {
- //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
- //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
- //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
- int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
- int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
- int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
- var diId = _dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- #region 操作记录
- var opInfo = new Crm_TableOperationRecord()
- {
- TableName = "Grp_HotelReservations",
- PortType = _dto.PortType,
- DataId = hotelId,
- CreateUserId = _dto.UserId
- };
- //var opStatus = OperationEnum.NoOperation;
- if (_dto.Id < 1) //添加操作
- {
- opInfo.OperationItem = OperationEnum.Add;
- }
- else if (_dto.Id > 0)
- {
- opInfo.OperationItem = OperationEnum.Edit;
- }
- string opRemark = string.Empty;
- if (ccpInfo != null)
- {
- // USD 1211.86、 CNY 8761.75、汇率:7.2300
- var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
- var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
- opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
- }
- opInfo.Remark = opRemark;
- await _tableorRep.AddAsync(opInfo);
- #endregion
- _logger.LogInformation($"【iOS推送通知Exception】Begin");
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"费用审核";
- string content = "";
- if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- try
- {
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
- await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
- //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
- //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
- //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
- }
- catch (Exception ex)
- {
- Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
- }
- }
- catch (Exception ex)
- {
- Logs($"【iOS推送通知Exception】【{ex.Message}】");
- }
- try
- {
- //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
- //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
- //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
- int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
- int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
- int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //自动审核
- var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
- //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
- _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- var diId = _dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- string content = "";
- if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(_view);
- }
- /// <summary>
- /// 酒店自动审核测试
- /// Add Or Edit
- /// </summary>
- /// <param name="diid"></param>
- /// <param name="dataId"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
- {
- #region 应用推送
- try
- {
- //自动审核
- await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "操作失败"));
- }
- #endregion
- return Ok(JsonView(false, "操作成功"));
- }
- /// <summary>
- /// 酒店预订
- /// Del
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
- #endregion
- #endregion
- var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
- #region 操作记录
- await _tableorRep.AddAsync(new Crm_TableOperationRecord()
- {
- TableName = "Grp_HotelReservations",
- PortType = _dto.PortType,
- OperationItem = OperationEnum.Del,
- DataId = _dto.Id,
- CreateUserId = _dto.UserId
- });
- #endregion
- return Ok(data);
- }
- /// <summary>
- /// 酒店预订
- /// 生成VOUCHER
- /// 2024.05.06 之前版本
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
- //判断数据是否完整
- if (hr != null)
- {
- if (!string.IsNullOrEmpty(hr.DetermineNo))
- {
- string strFileName = "HotelStatement/";
- Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
- if (dele != null)
- strFileName += dele.TourCode;
- //载入模板
- string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
- Document doc = new Document(sss);
- DocumentBuilder builder = new DocumentBuilder(doc);
- #region 替换Word模板书签内容
- //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
- //入住卷预定号码
- if (doc.Range.Bookmarks["VNO"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VNO"];
- mark.Text = hr.CheckNumber;
- }
- //酒店时间
- if (doc.Range.Bookmarks["Date"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Date"];
- mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
- }
- //团号
- if (doc.Range.Bookmarks["TNo"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["TNo"];
- mark.Text = dele.TourCode;
- }
- //预定号码
- if (doc.Range.Bookmarks["BookingId"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["BookingId"];
- mark.Text = hr.ReservationsNo;
- }
- if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
- mark.Text = hr.DetermineNo;
- }
- //酒店城市
- if (doc.Range.Bookmarks["City"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["City"];
- mark.Text = hr.City;
- }
- //酒店名称
- if (doc.Range.Bookmarks["HName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["HName"];
- mark.Text = hr.HotelName;
- }
- //酒店地址
- if (doc.Range.Bookmarks["Address"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Address"];
- mark.Text = hr.HotelAddress;
- }
- //酒店电话
- if (doc.Range.Bookmarks["Tel"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Tel"];
- mark.Text = hr.HotelTel;
- }
- //酒店传真
- if (doc.Range.Bookmarks["Fax"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Fax"];
- if (!string.IsNullOrWhiteSpace(hr.HotelFax))
- {
- mark.Text = hr.HotelFax;
- }
- }
- //入住时间
- if (doc.Range.Bookmarks["CIn"] != null)
- {
- DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
- Bookmark mark = doc.Range.Bookmarks["CIn"];
- mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
- }
- //退房时间
- if (doc.Range.Bookmarks["COut"] != null)
- {
- DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
- Bookmark mark = doc.Range.Bookmarks["COut"];
- mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
- }
- //客户名称
- if (doc.Range.Bookmarks["GName"] != null)
- {
- string guestName = "";
- string[] clients = new string[] { };
- if (hr.GuestName.Contains(","))
- {
- clients = hr.GuestName.Split(",");
- }
- else
- {
- clients = new string[] { hr.GuestName };
- }
- List<int> clientIds_int = new List<int>();
- if (clients.Length > 0)
- {
- foreach (var item in clients)
- {
- if (item.IsNumeric())
- {
- clientIds_int.Add(int.Parse(item));
- }
- }
- }
- if (clientIds_int.Count > 0)
- {
- var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
- foreach (var client in _clientDatas)
- {
- //男
- if (client.Sex == 0) guestName += $"Mr.";
- //女
- else if (client.Sex == 1) guestName += $"Ms.";
- if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
- {
- guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
- }
- //guestName += $"{client.Pinyin},";
- }
- if (guestName.Length > 0)
- {
- guestName = guestName.Substring(0, guestName.Length - 1);
- }
- }
- else
- {
- guestName = hr.GuestName;
- }
- Bookmark mark = doc.Range.Bookmarks["GName"];
- mark.Text = guestName;
- }
- //房间介绍
- if (doc.Range.Bookmarks["ROOM"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ROOM"];
- mark.Text = hr.RoomExplanation;
- }
- //报价描述
- if (doc.Range.Bookmarks["NOTE"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["NOTE"];
- Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
- if (ss != null)
- mark.Text = ss.Name;
- }
- //入住时间
- if (doc.Range.Bookmarks["CheckIn"] != null)
- {
- DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
- Bookmark mark = doc.Range.Bookmarks["CheckIn"];
- mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
- }
- //退房时间
- if (doc.Range.Bookmarks["CheckOut"] != null)
- {
- DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
- Bookmark mark = doc.Range.Bookmarks["CheckOut"];
- mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
- }
- //日期
- if (doc.Range.Bookmarks["DT"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["DT"];
- mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
- }
- //名称
- if (doc.Range.Bookmarks["VName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VName"];
- mark.Text = hr.HotelName;
- }
- //号码
- if (doc.Range.Bookmarks["VOUCHERNO"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
- mark.Text = hr.CheckNumber;
- }
- #endregion
- strFileName += "VOUCHER.doc";
- var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- else
- {
- return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
- }
- }
- else
- {
- return Ok(JsonView(false, "该条数据已删除或不存在!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 酒店预订
- /// 生成VOUCHER
- /// 2024.05.06 之后版本
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
- //判断数据是否完整
- if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
- hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
- string strFileName = "HotelStatement/";
- string guestNames = ""; //格式Mr.xxx Ms.xxx
- List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
- #region 数据处理
- List<int> guestIds = new List<int>();
- //int index = 0;
- foreach (var item in hrDtas)
- {
- if (item.GuestName.Contains(","))
- {
- string[] guestIdArr = item.GuestName.Split(',');
- foreach (var guestIdStr in guestIdArr)
- {
- bool guestBool = int.TryParse(guestIdStr, out int guestId);
- if (guestBool)
- {
- guestIds.Add(guestId);
- }
- }
- }
- else guestNames += item.GuestName;
- var voucherInfo = new HotelVoucherInfoView()
- {
- HotelName = item.HotelName,
- CheckInDate = item.CheckInDate,
- CheckOutDate = item.CheckOutDate,
- ConfirmationNumber = item.DetermineNo.Trim(),
- RoomType = item.RoomExplanation
- };
- vouchers.Add(voucherInfo);
- }
- if (guestIds.Count > 0)
- {
- guestIds = guestIds.Distinct().ToList();
- var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
- if (guestDatas.Count > 0)
- {
- guestNames = "";
- foreach (var guest in guestDatas)
- {
- string guestName = "";
- if (guest.Sex == 0) guestName += @"MR.";
- else if (guest.Sex == 1) guestName += @"MS.";
- if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
- else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
- guestNames += @$"{guestName.Trim()}、";
- }
- if (guestNames.Length > 0)
- {
- guestNames = guestNames.Substring(0, guestNames.Length - 1);
- }
- }
- }
- #endregion
- //载入模板
- string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
- Document doc = new Document(sss);
- DocumentBuilder builder = new DocumentBuilder(doc);
- if (doc.Range.Bookmarks["GuestName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["GuestName"];
- mark.Text = guestNames;
- }
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
- vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
- for (int i = 1; i <= vouchers.Count; i++)
- {
- HotelVoucherInfoView hviv = vouchers[i - 1];
- builder.MoveToCell(0, i, 0, 0);
- builder.Write(hviv.HotelName);
- builder.MoveToCell(0, i, 1, 0);
- builder.Write(hviv.CheckInDate);
- builder.MoveToCell(0, i, 2, 0);
- builder.Write(hviv.CheckOutDate);
- builder.MoveToCell(0, i, 3, 0);
- builder.Write(hviv.RoomType);
- builder.MoveToCell(0, i, 4, 0);
- builder.Write(hviv.ConfirmationNumber);
- }
- //删除多余行
- int currRowIndex = vouchers.Count + 1;
- int delRows = 21 - currRowIndex;
- if (delRows > 0)
- {
- for (int i = 0; i < delRows; i++)
- {
- table.Rows.RemoveAt(currRowIndex);
- //cultivateRowIndex++;
- }
- }
- strFileName += "VOUCHER.docx";
- var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- /// <summary>
- /// 酒店预订
- /// 生成VOUCHER 批量生成
- /// New
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
- if (_dto.PageId < 1) _dto.PageId = 28;
- if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
- .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
- .OrderBy(x => x.CheckInDate)
- .ToListAsync();
- //判断数据是否完整
- if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
- string strFileName = "HotelStatement/";
- var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
- if (dele != null)
- strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
- var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
- .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
- .Where(it => it.IsDel == 0)
- .ToListAsync();
- foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
- for (int i = 0; i < hrDtas.Count; i++)
- {
- string guestNames = string.Empty;
- List<int> guestIds = new List<int>();
- var item = hrDtas[i];
- //处理客户姓名
- if (item.GuestName.Contains(","))
- {
- string[] guestIdArr = item.GuestName.Split(',');
- foreach (var guestIdStr in guestIdArr)
- if (int.TryParse(guestIdStr, out int guestId))
- guestIds.Add(guestId);
- }
- else
- {
- bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
- if (guestIdBool)
- {
- guestIds.Add(guestId);
- }
- //NaN
- if (item.GuestName.Contains("NaN"))
- {
- guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
- }
- }
- if (guestIds.Count > 0)
- {
- guestIds = guestIds.Distinct().ToList();
- var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
- if (guestDatas1.Count > 0)
- {
- guestNames = "";
- foreach (var guest in guestDatas1)
- {
- string guestName = "";
- if (guest.Sex == 0) guestName += @"MR.";
- else if (guest.Sex == 1) guestName += @"MS.";
- if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
- else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
- guestNames += @$"{guestName.Trim()}、";
- }
- if (guestNames.Length > 0)
- {
- guestNames = guestNames.Substring(0, guestNames.Length - 1);
- }
- }
- }
- //if (!string.IsNullOrEmpty(guestNames))
- //{
- hrDtas[i].GuestName = guestNames;
- //}
- }
- strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
- Document doc = new Document();
- DocumentBuilder builder = new DocumentBuilder(doc);
- try
- {
- builder.MoveToDocumentStart();
- foreach (var item in hrDtas)
- {
- //标题
- builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
- builder.ParagraphFormat.LineSpacing = 1;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 9;
- builder.ParagraphFormat.Style.Font.Bold = true;
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
- builder.Writeln(@$"ACCOMMODATION VOUCHER");
- builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
- builder.ParagraphFormat.LineSpacing = 1;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 9;
- builder.ParagraphFormat.Style.Font.Bold = true;
- builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
- builder.StartTable();
- // 设置边框颜色
- builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
- //设置边框样式
- builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
- //表格
- #region 第一行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- //builder.CellFormat.AllowAutoFit = false;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.CellFormat.WrapText = true; //自动换行
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write("TOUR NO:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"{dele?.TourCode ?? "-"}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"CITY:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"{item.City}");
- builder.EndRow();
- #endregion
- #region 第二行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write("CONFIRMATION NO:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.CellFormat.VerticalMerge = CellMerge.None;
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"{item.DetermineNo}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- #region 第三行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"HOTEL NAME:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"{item.HotelName}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- #region 第四行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"HOTEL ADDRESS:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 8;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"{item.HotelAddress}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- #region 第五行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write("TEL:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"{item.HotelTel}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"FAX:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"{item.HotelFax}");
- builder.EndRow();
- #endregion
- #region 第六行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write("CHECK IN:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
- string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
- builder.Write($"{checkInStr}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"CHECK OUT:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
- string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
- builder.Write($"{checkOutStr}");
- builder.EndRow();
- #endregion
- #region 第七行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"GUEST NAME:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 8;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"{item.GuestName}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- #region 第八行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"ROOM TYPE:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- builder.Write($"{item.RoomExplanation}");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- #region 第九行
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
- builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
- builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
- builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
- builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
- builder.Write($"NOTE:");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
- builder.ParagraphFormat.Style.Font.Size = 7.5;
- builder.ParagraphFormat.Style.Font.Bold = false;
- builder.CellFormat.HorizontalMerge = CellMerge.None;
- builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
- builder.CellFormat.HorizontalMerge = CellMerge.First;
- 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.");
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.InsertCell();
- builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
- builder.CellFormat.HorizontalMerge = CellMerge.Previous;
- builder.EndRow();
- #endregion
- builder.EndTable();
- //换行
- builder.Writeln("");
- builder.Writeln("");
- }
- #region 获取文档中的所有表格 设置文字自适应
- // 获取文档中的所有表格。
- foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
- {
- // 遍历表格中的所有行。
- foreach (Aspose.Words.Tables.Row row in table.Rows)
- {
- foreach (Cell cell in row.Cells)
- {
- Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
- cellFormat.Width = 0;
- }
- }
- }
- #endregion
- #region 设置页眉
- builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
- string voucherHeaderPath = $"./Images/VoucherHeader.png";
- if (System.IO.File.Exists(voucherHeaderPath))
- {
- byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
- //Image image = Image.FromStream(imageBytes, ImageType.Png);
- //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
- Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
- // 调整图片位置
- shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
- shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
- shape.Top = 50; // 将图片距离页眉上边缘的距离
- shape.Left = 0; // 将图片距离页面左边缘的距离
- shape.Width = 81; // 设置图片宽度
- shape.Height = 36; // 设置图片高度
- }
- //靠右
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
- //// 设置页脚上下边距
- //builder.PageSetup.HeaderDistance = 42;
- // 添加页眉线
- Aspose.Words.Border borderHeader = null;
- try
- {
- borderHeader = builder.ParagraphFormat.Borders.Bottom;
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- //e.printStackTrace();
- }
- borderHeader.Shadow = true;
- borderHeader.DistanceFromText = 2;
- borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
- #endregion
- }
- catch (Exception ex)
- {
- }
- var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- /// <summary>
- /// 酒店预订
- /// 生成 预定成本 Excel
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
- {
- #region 参数验证
- var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
- var vadalitorRes = await vadalitor.ValidateAsync(_dto);
- if (!vadalitorRes.IsValid)
- {
- var errors = new StringBuilder();
- foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
- return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
- }
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- decimal _rate = 1.00M;
- string _currency = string.Empty;
- var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
- var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
- if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
- var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
- var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
- var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
- //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
- if (_GroupCostParameter == null)
- {
- //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
- bool isIntType = int.TryParse(_currency, out int currId);
- if (isIntType)
- {
- _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
- }
- var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
- var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
- if (currInfo == null)
- {
- //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
- }
- else _rate = currInfo.Rate;
- if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
- {
- _rate = _GroupCostParameter.Rate;
- }
- hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
- //string strFileName = "HotelStatement/";
- //string guestNames = ""; //格式Mr.xxx Ms.xxx
- List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
- var rateDatas = new List<dynamic>();
- #region 数据处理
- foreach (var item in hrDtas)
- {
- var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
- var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
- var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
- var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
- var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
- if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
- {
- continue;
- }
- string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
- if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
- string singleRoomFeeStr = string.Empty,
- doubleRoomFeeStr = string.Empty,
- suiteRoomFeeStr = string.Empty,
- otherRoomFeeStr = string.Empty,
- payMoneyStr = string.Empty,
- cardPriceStr = string.Empty;
- if (roomCurr.Equals("CNY"))
- {
- rateDatas.Add(new { code = "CNY", rate = 1.0000 });
- singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
- doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
- suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
- otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
- payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
- cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
- }
- else
- {
- //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
- //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
- //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
- //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
- //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
- //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
- singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
- doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
- suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
- otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
- rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
- var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
- if (ccpPaymentCurrency.Equals("CNY"))
- {
- payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
- cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
- }
- else
- {
- rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
- payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
- }
- var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
- if (hotelcardPriceCurrency.Equals("CNY"))
- {
- cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
- }
- else
- {
- cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
- }
- }
- string breakfastPriceStr = string.Empty,
- breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
- governmentRentStr = string.Empty,
- governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
- cityTaxStr = string.Empty,
- cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
- var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
- if (!string.IsNullOrEmpty(breakfastCurrency1))
- {
- if (breakfastCurrency1.Equals("CNY"))
- {
- breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
- }
- else
- {
- rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
- var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
- breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
- }
- }
- else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
- var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
- if (!string.IsNullOrEmpty(governmentRentCurrency1))
- {
- if (governmentRentCurrency.Equals("CNY"))
- {
- governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
- }
- else
- {
- rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
- var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
- governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
- }
- }
- else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
- var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
- if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
- {
- if (cityTaxStrCurrency1.Equals("CNY"))
- {
- cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
- }
- else
- {
- rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
- var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
- cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
- }
- }
- else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
- int payDId = roomInfo?.PayDId ?? 0;
- pcfds.Add(new HotelReservations_PCFD_View()
- {
- City = item.City,
- HotelName = item.HotelName,
- Date = $"{item.CheckInDate} - {item.CheckOutDate}",
- // SingleRoomCount = item.SingleRoomCount,
- SingleRoomPrice = singleRoomFeeStr,
- // DoubleRoomCount = item.DoubleRoomCount,
- DoubleRoomPrice = doubleRoomFeeStr,
- //SuiteRoomCount = item.SuiteRoomCount,
- SuiteRoomPrice = suiteRoomFeeStr,
- OtherRoomPrice = otherRoomFeeStr,
- //OtherRoomCount = item.OtherRoomCount,
- BreakfastPrice = breakfastPriceStr,
- GovernmentRent = governmentRentStr,
- CityTax = cityTaxStr,
- RoomExplanation = item.RoomExplanation,
- PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
- PayTime = roomInfo?.ConsumptionDate,
- BankNo = roomInfo?.BankNo,
- PayMoney = payMoneyStr,
- //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
- ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
- CardPrice = cardPriceStr,
- Remark = ccpInfo.Remark
- });
- }
- #endregion
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
- var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
- designer.SetDataSource("TourNo", groupInfo.TourCode);
- var rateDatas1 = rateDatas.Distinct();
- var rateStr = string.Empty;
- foreach (var item in rateDatas1)
- {
- rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
- }
- designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
- designer.SetDataSource("Opertor", userInfo.CnName);
- DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
- dt.TableName = "ViewMyHotelReservations";
- designer.SetDataSource(dt);
- designer.Process();
- string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
- designer.Workbook.Save(serverPath);
- string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
- #region 删除指定行
- bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
- int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
- doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
- suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
- otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
- zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
- dsIndex = dt.Columns["GovernmentRent"].Ordinal,
- cssIndex = dt.Columns["CityTax"].Ordinal,
- cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
- remarkIndex = dt.Columns["Remark"].Ordinal;
- //删除指定列
- foreach (DataRow item in dt.Rows)
- {
- string singleStr = item["SingleRoomPrice"].ToString();
- bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
- if (containsDigitButNotZero1) singleDel = false;
- singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
- string doubleStr = item["DoubleRoomPrice"].ToString();
- bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
- if (containsDigitButNotZero2) doubleDel = false;
- string suiteStr = item["SuiteRoomPrice"].ToString();
- bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
- if (containsDigitButNotZero3) suiteDel = false;
- string otherStr = item["OtherRoomPrice"].ToString();
- bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
- if (containsDigitButNotZero4) otherDel = false;
- string zcStr = item["BreakfastPrice"].ToString();
- bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
- if (containsDigitButNotZero5) zcDel = false;
- string dsStr = item["GovernmentRent"].ToString();
- bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
- if (containsDigitButNotZero6) dsDel = false;
- string cssStr = item["CityTax"].ToString();
- bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
- if (containsDigitButNotZero7) cssDel = false;
- string cpStr = item["ConsumptionPatterns"].ToString();
- if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
- string remarkStr = item["Remark"].ToString();
- if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
- }
- DeleteColumn(serverPath, remarkIndex, remarkDel);
- DeleteColumn(serverPath, cpIndex, cpDel);
- DeleteColumn(serverPath, dsIndex, dsDel);
- DeleteColumn(serverPath, cssIndex, cssDel);
- DeleteColumn(serverPath, zcIndex, zcDel);
- DeleteColumn(serverPath, otherIndex, otherDel);
- DeleteColumn(serverPath, suiteIndex, suiteDel);
- DeleteColumn(serverPath, doubleIndex, doubleDel);
- DeleteColumn(serverPath, singleIndex, singleDel);
- #endregion
- //只保留第一个表格
- DeleteSheet(serverPath);
- return Ok(JsonView(true, "操作成功", url = rst));
- }
- else
- {
- _currency = _GroupCostParameter.Currency;
- bool isIntType = int.TryParse(_currency, out int currId);
- if (isIntType)
- {
- _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
- }
- var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
- var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
- if (currInfo == null)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
- }
- if (!_currency.ToUpper().Equals("CNY"))
- {
- _rate = _GroupCostParameter.Rate;
- }
- _rate = currInfo.Rate;
- hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
- //string strFileName = "HotelStatement/";
- //string guestNames = ""; //格式Mr.xxx Ms.xxx
- List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
- #region 数据处理
- foreach (var item in hrDtas)
- {
- var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
- var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
- var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
- var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
- var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
- string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
- string singleRoomFeeStr = string.Empty,
- doubleRoomFeeStr = string.Empty,
- suiteRoomFeeStr = string.Empty,
- otherRoomFeeStr = string.Empty,
- payMoneyStr = string.Empty,
- cardPriceStr = string.Empty;
- if (roomCurr.Equals(_currency))
- {
- singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
- doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
- suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
- otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
- payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
- cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
- }
- else
- {
- singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
- doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
- suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
- otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
- payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
- cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
- }
- string breakfastPriceStr = string.Empty,
- breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
- governmentRentStr = string.Empty,
- governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
- cityTaxStrStr = string.Empty,
- cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
- breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
- governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
- cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
- int payDId = roomInfo?.PayDId ?? 0;
- pcfds.Add(new HotelReservations_PCFD_View()
- {
- City = item.City,
- HotelName = item.HotelName,
- Date = $"{item.CheckInDate} - {item.CheckOutDate}",
- // SingleRoomCount = item.SingleRoomCount,
- SingleRoomPrice = singleRoomFeeStr,
- // DoubleRoomCount = item.DoubleRoomCount,
- DoubleRoomPrice = doubleRoomFeeStr,
- //SuiteRoomCount = item.SuiteRoomCount,
- SuiteRoomPrice = suiteRoomFeeStr,
- OtherRoomPrice = otherRoomFeeStr,
- //OtherRoomCount = item.OtherRoomCount,
- BreakfastPrice = breakfastPriceStr,
- GovernmentRent = governmentRentStr,
- CityTax = cityTaxStrStr,
- RoomExplanation = item.RoomExplanation,
- PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
- PayTime = roomInfo?.ConsumptionDate,
- BankNo = roomInfo?.BankNo,
- PayMoney = payMoneyStr,
- //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
- ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
- CardPrice = cardPriceStr,
- Remark = ccpInfo.Remark
- });
- }
- #endregion
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
- var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
- var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
- designer.SetDataSource("TourNo", groupInfo.TourCode);
- designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
- designer.SetDataSource("Opertor", userInfo.CnName);
- DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
- dt.TableName = "ViewMyHotelReservations";
- designer.SetDataSource(dt);
- designer.Process();
- string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
- string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
- designer.Workbook.Save(serverPath);
- string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
- #region 删除指定行
- bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
- int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
- doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
- suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
- otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
- zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
- dsIndex = dt.Columns["GovernmentRent"].Ordinal,
- cssIndex = dt.Columns["CityTax"].Ordinal,
- cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
- remarkIndex = dt.Columns["Remark"].Ordinal;
- //删除指定列
- foreach (DataRow item in dt.Rows)
- {
- string singleStr = item["SingleRoomPrice"].ToString();
- bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
- if (containsDigitButNotZero1) singleDel = false;
- singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
- string doubleStr = item["DoubleRoomPrice"].ToString();
- bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
- if (containsDigitButNotZero2) doubleDel = false;
- string suiteStr = item["SuiteRoomPrice"].ToString();
- bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
- if (containsDigitButNotZero3) suiteDel = false;
- string otherStr = item["OtherRoomPrice"].ToString();
- bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
- if (containsDigitButNotZero4) otherDel = false;
- string zcStr = item["BreakfastPrice"].ToString();
- bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
- if (containsDigitButNotZero5) zcDel = false;
- string dsStr = item["GovernmentRent"].ToString();
- bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
- if (containsDigitButNotZero6) dsDel = false;
- string cssStr = item["CityTax"].ToString();
- bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
- if (containsDigitButNotZero7) cssDel = false;
- string cpStr = item["ConsumptionPatterns"].ToString();
- if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
- string remarkStr = item["Remark"].ToString();
- if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
- }
- DeleteColumn(serverPath, remarkIndex, remarkDel);
- DeleteColumn(serverPath, cpIndex, cpDel);
- DeleteColumn(serverPath, dsIndex, dsDel);
- DeleteColumn(serverPath, cssIndex, cssDel);
- DeleteColumn(serverPath, zcIndex, zcDel);
- DeleteColumn(serverPath, otherIndex, otherDel);
- DeleteColumn(serverPath, suiteIndex, suiteDel);
- DeleteColumn(serverPath, doubleIndex, doubleDel);
- DeleteColumn(serverPath, singleIndex, singleDel);
- #endregion
- //只保留第一个表格
- DeleteSheet(serverPath);
- return Ok(JsonView(true, "操作成功", url = rst));
- }
- //return Ok(JsonView(false));
- }
- /// <summary>
- /// 删除指定列
- /// </summary>
- /// <param name="file"></param>
- /// <param name="columnIndex"></param>
- /// <param name="isDel"></param>
- private void DeleteColumn(string file, int columnIndex, bool isDel)
- {
- Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
- //wb.Save(file);
- Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
- if (sheet1 != null)
- {
- if (isDel)
- {
- Cells cells = sheet1.Cells;
- cells.DeleteColumn(columnIndex);
- }
- }
- wb.Save(file);
- }
- /// <summary>
- /// 删除sheet
- /// </summary>
- /// <param name="file"></param>
- /// <param name="sheetName"></param>
- private void DeleteSheet(string file, string sheetName = "")
- {
- Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
- //wb.Save(file);
- List<string> sheets = new List<string>();
- foreach (var item in wb.Worksheets)
- {
- sheets.Add(item.Name);
- }
- if (sheets.Count > 0)
- {
- sheets.RemoveAt(0);//不删除第一个sheet
- foreach (var item in sheets)
- {
- wb.Worksheets.RemoveAt(item);
- }
- }
- wb.Save(file);
- }
- /// <summary>
- /// 酒店预订
- /// 确认单
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- //团组信息
- Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
- //酒店数据
- List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
- if (listhoteldata.Count < 0)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
- }
- //利datatable存储
- DataTable dt = new DataTable();
- dt.Columns.Add("CheckInDate", typeof(string));
- dt.Columns.Add("City", typeof(string));
- dt.Columns.Add("Hotel", typeof(string));
- dt.Columns.Add("Room", typeof(string));
- for (int i = 0; i < listhoteldata.Count; i++)
- {
- DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
- DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
- while (dayStart < dayEnd)
- {
- string temp = "";
- DataRow row = dt.NewRow();
- row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
- row["City"] = listhoteldata[i].City;
- row["Hotel"] = listhoteldata[i].HotelName;
- if (listhoteldata[i].SingleRoomCount > 0)
- {
- temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
- }
- if (listhoteldata[i].DoubleRoomCount > 0)
- {
- temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
- }
- if (listhoteldata[i].SuiteRoomCount > 0)
- {
- temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
- }
- if (listhoteldata[i].OtherRoomCount > 0)
- {
- temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
- }
- row["Room"] = temp;
- dt.Rows.Add(row);
- dayStart = dayStart.AddDays(1);
- }
- }
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("Dele", di.TeamName);
- dic.Add("City", di.VisitCountry);
- //模板路径
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
- //载入模板
- Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(dt.Rows[i]["CheckInDate"].ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(dt.Rows[i]["City"].ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(dt.Rows[i]["Hotel"].ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(dt.Rows[i]["Room"].ToString());
- }
- //删除多余行
- while (tableOne.Rows.Count > dt.Rows.Count + 1)
- {
- tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
- }
- string strFileName = di.TeamName + "酒店确认单.doc";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
- return Ok(JsonView(true, "成功", url));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
- }
- }
- #endregion
- #region 团组状态
- /// <summary>
- /// 团组状态列表 Page
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
- {
- if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
- if (dto.PortType == 1 || dto.PortType == 2) // web/Android
- {
- string sqlWhere = string.Empty;
- if (dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- if (!string.IsNullOrEmpty(dto.SearchCriteria))
- {
- string tj = dto.SearchCriteria;
- 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}%')",
- tj, tj, tj, tj, tj);
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
- From (
- Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
- ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
- From Grp_DelegationInfo gdi
- Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {0}
- ) temp ", sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
- return Ok(JsonView(true, "查询成功!", _DelegationList, total));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 团组状态
- /// 设置操作完成
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
- {
- if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
- Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
- {
- Id = dto.Id,
- IsSure = 1
- };
- var result = await _sqlSugar.Updateable(_DelegationInfo)
- .UpdateColumns(it => new { it.IsSure })
- .WhereColumns(it => new { it.Id })
- .ExecuteCommandAsync();
- if (result > 0)
- {
- return Ok(JsonView(true, "操作完成!"));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- #endregion
- #region 保险费用录入
- /// <summary>
- /// 根据团组Id查询保险费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
- {
- Result groupData = await _customersRep.CustomersByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 根据保险费用Id查询保险费用详细
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
- {
- try
- {
- Result groupData = await _customersRep.CustomersById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 保险费用录入页面初始化绑定
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
- {
- try
- {
- Result groupData = await _customersRep.CustomersInitialize(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 保险费用操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
- {
- Result groupData = await _customersRep.OpCustomers(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- #region 应用推送
- try
- {
- int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
- int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
- await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
- //自动审核
- await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
- //2024-10-21 新增LZ UID
- var userIds = new List<int>() { 21 };
- string title = $"系统通知";
- var diId = dto.DiId;
- var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
- var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
- string content = "";
- if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
- await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 保险文件上传
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UploadCus(IFormFile file)
- {
- try
- {
- if (file != null)
- {
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- //文件名称
- string projectFileName = file.FileName;
- //上传的文件的路径
- string filePath = "";
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- return Ok(JsonView(true, "上传成功!", projectFileName));
- }
- else
- {
- return Ok(JsonView(false, "上传失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 保险删除指定文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelFileCus(DelFileDto dto)
- {
- try
- {
- string filePath = "";
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- // 返回与指定虚拟路径相对应的物理路径即绝对路径
- //int id = 0;
- filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
- // 删除该文件
- try
- {
- System.IO.File.Delete(filePath);
- 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()
- {
- Attachment = "",
- }).ExecuteCommandAsync();
- if (result != 0)
- {
- return Ok(JsonView(true, "成功!"));
- }
- else
- {
- return Ok(JsonView(false, "失败!"));
- }
- }
- catch (Exception)
- {
- 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()
- {
- Attachment = "",
- }).ExecuteCommandAsync();
- if (result != 0)
- {
- return Ok(JsonView(true, "成功!"));
- }
- else
- {
- return Ok(JsonView(false, "失败!"));
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 保险费用操作(删除)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCustomers(DelBaseDto dto)
- {
- try
- {
- var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 接团客户名单 PageId 104
- /// <summary>
- /// 接团客户名单
- /// 迁移数据(慎用!)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListChange()
- {
- try
- {
- _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
- //var groupClinetData1
- string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
- var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
- int updateCount = 0;
- if (oldOAClientList.Count > 0)
- {
- _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
- _sqlSugar.BeginTran();
- var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
- var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
- foreach (var item in oldOAClientList)
- {
- int comId = 0;
- string format = "yyyy-MM-dd HH:mm:ss";
- string data11 = "1990-01-01 00:00";
- var data1 = IsValidDate(item.OPdate, format);
- if (data1) data11 = item.OPdate;
- //客户公司验证
- if (!string.IsNullOrEmpty(item.Company))
- {
- var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
- if (clientComInfo == null) // add
- {
- var addInfo = new Crm_CustomerCompany()
- {
- CompanyAbbreviation = "",
- CompanyFullName = item.Company,
- Address = "",
- PostCodes = "",
- LastedOpUserId = item.OPer,
- LastedOpDt = Convert.ToDateTime(data11),
- CreateUserId = item.OPer,
- CreateTime = Convert.ToDateTime(data11),
- IsDel = 0
- };
- var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
- if (comId1 > 0) comId = comId1;
- }
- else comId = clientComInfo.Id;
- }
- //客户人员验证
- int clientId = 0;
- string name = item.LastName + item.Name;
- if (!string.IsNullOrEmpty(name))
- {
- var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
- if (clientInfo == null)
- {
- DateTime? dateTime = null;
- var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
- if (isDt) dateTime = birthDayDt;
- var addInfo1 = new Crm_DeleClient()
- {
- CrmCompanyId = comId,
- DiId = -1,
- LastName = item.LastName,
- FirstName = item.Name,
- OldName = "",
- Pinyin = item.Pinyin,
- Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
- Marriage = 0,
- Phone = item.Phone,
- Job = item.Job,
- BirthDay = dateTime
- };
- var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
- if (clientId1 > 0) clientId = clientId1;
- }
- else clientId = clientInfo.Id;
- }
- if (clientId < 1)
- {
- continue;
- }
- int airType = 0;
- if (item.AirType == "超经舱") airType = 459;
- else if (item.AirType == "公务舱") airType = 458;
- else if (item.AirType == "经济舱") airType = 460;
- else if (item.AirType == "其他") airType = 565;
- else if (item.AirType == "头等舱") airType = 457;
- var _TourClientListEntity = new Grp_TourClientList()
- {
- DiId = item.Diid,
- ClientId = clientId,
- CreateUserId = item.OPer,
- CreateTime = Convert.ToDateTime(data11),
- Remark = item.Remark,
- IsDel = item.Isdel,
- ShippingSpaceTypeId = airType,
- ShippingSpaceSpecialNeeds = item.AirRemark,
- HotelSpecialNeeds = item.RoomType
- };
- var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
- if (_TourClientList > 0)
- {
- updateCount++;
- }
- }
- _sqlSugar.CommitTran();
- }
- return Ok(JsonView(true, $"更新条数:{updateCount}条"));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- //return Ok(JsonView(true));
- }
- private bool IsValidDate(string dateString, string format)
- {
- DateTime dateValue;
- bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
- return valid;
- }
- /// <summary>
- /// 接团客户名单
- /// 根据团组Id查询List
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
- if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 接团客户名单
- /// 基础数据 Init
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
- }
- /// <summary>
- /// 接团客户名单
- /// 根据 Id查询 Details
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 接团客户名单
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (_dto.Id == 0) //添加
- {
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
- }
- else if (_dto.Id >= 0) //修改
- {
- if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
- }
- #endregion
- #endregion
- var viewData = await _tourClientListRep._AddOrEdit(_dto);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 接团客户名单
- /// json字符串 AddMultiple(添加多个)
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
- {
- #region 参数验证
- string jsonLabel = _dto.JsonLabel;
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
- #endregion
- #endregion
- var request = new TourClientListAddMultipleDto();
- request.DiId = _dto.DiId;
- request.UserId = _dto.UserId;
- if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
- if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
- List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
- if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
- var infos = new List<TourClientListInfo>();
- foreach (var data in datas)
- {
- (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
- string lastNameEn = CommonFun.ConvertToPinyin(lastName),
- firstNameEn = CommonFun.ConvertToPinyin(lastName);
- if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
- {
- continue;
- }
- infos.Add(new TourClientListInfo()
- {
- IsAccompany = 1,
- LastName = lastName,
- FirstName = firstName,
- Pinyin = lastNameEn + @"/" + firstNameEn,
- Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
- CompanyFullName = data.CompanyFullName,
- Job = data.Job
- });
- }
- if (infos.Any())
- {
- var viewData = await _tourClientListRep._AddMultiple(request);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- return Ok(JsonView(false));
- }
- /// <summary>
- /// 接团客户名单
- /// AddMultiple(添加多个)
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._AddMultiple(_dto);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 接团客户名单
- /// Del
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 接团客户名单
- /// 文件下载 客户名单
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
- tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
- From Grp_TourClientList tcl
- Left Join
- (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
- cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
- cc2.Area,cc2.IssueDt,cc2.ExpiryDt
- From Crm_DeleClient dc
- Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
- Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
- Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
- Where dc.IsDel = 0) temp
- On temp.DcId =tcl.ClientId
- Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
- List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
- if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
- //载入模板
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
- if (_dto.Language == 1)
- {
- tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
- }
- //载入模板
- var doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- if (_dto.Language == 0)
- {
- //循环赋值
- for (int i = 0; i < DcList.Count; i++)
- {
- EncryptionProcessor.DecryptProperties(DcList[i]);
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(DcList[i].LastName + DcList[i].FirstName);
- builder.MoveToCell(0, i + 1, 1, 0);
- int sex = DcList[i].Sex;
- string sexStr = string.Empty;
- if (sex == 0) sexStr = "男";
- else if (sex == 1) sexStr = "女";
- else sexStr = "未设置";
- builder.Write(sexStr);
- builder.MoveToCell(0, i + 1, 2, 0);
- string birthDay = DcList[i].BirthDay;
- string birthDayStr = string.Empty;
- if (!string.IsNullOrEmpty(birthDay))
- {
- birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
- }
- builder.Write(birthDayStr);
- builder.MoveToCell(0, i + 1, 3, 0);
- string company = "";
- if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
- {
- company = DcList[i].CompanyFullName.ToString();
- }
- builder.Write(company);
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(DcList[i].Job);
- }
- }
- else if (_dto.Language == 1)
- {
- List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
- List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
- List<string> transArrayStr = new List<string>();
- string transStrRes1 = "";
- for (int i = 0; i < DcList.Count; i++)
- {
- var dc = DcList[i];
- EncryptionProcessor.DecryptProperties(dc);
- if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
- if (dc.Job.Equals("暂无")) dc.Job = "-";
- string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
- if (DcList.Count - 1 == i) transStrRes1 += str1;
- else transStrRes1 += $"{str1}|";
- }
- #region AI转英文
- string jsonValue = JsonConvert.SerializeObject(DcList);
- string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
- List<SeedMessages> messages = new List<SeedMessages>()
- {
- new SeedMessages
- {
- Role = KimiRole.user,
- Content = jsonValue + text
- }
- };
- KiMiApiClient client = new KiMiApiClient();
- var kimiApiResult = await client.SeedMessage(messages);
- var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
- string clients = kimiApiResult_JObject["content"].ToString();
- string startStr = "```json", endStr = "```";
-
- // 判断并清除开头部分
- if (clients.StartsWith(startStr))
- {
- clients = clients.Remove(0, startStr.Length);
- }
- // 判断并清除结尾部分
- if (clients.EndsWith(endStr))
- {
- clients = clients.Remove(clients.Length - endStr.Length);
- }
- var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
- //循环赋值
- for (int i = 0; i < en_Json.Count; i++)
- {
- var dc = en_Json[i];
- var dc1 = DcList.Find(x => x.Id == dc.Id);
- string PYName = dc.FirstName + " " + dc.LastName;
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(PYName);
- string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(sex);
- DateTime birthDt;
- bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
- string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(birthday);
- string company = string.Empty, job = string.Empty;
- company = dc.CompanyFullName;
- job = dc.Job;
- if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName) )
- {
- //查询对照表
- Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
- if (tempCec != null)
- {
- company = tempCec.enName;
- }
- }
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(company);
- if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
- {
- //查询对照表
- Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
- if (tempPec != null)
- {
- job = tempPec.enName;
- }
- }
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(job);
- }
- #endregion
- #region 旧翻译英文处理
- ////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";
- //string transStrRes = "";
- //if (transStrRes1.Length > 0)
- //{
- // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
- //}
- ////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
- ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
- ////List<string> transArray = new List<string> { };
- //List<TranslateInfo> transArray = new List<TranslateInfo>();
- //if (transStrRes.Contains("|"))
- //{
- // string[] transArray1 = transStrRes.Split('|');
- // if (transArray1.Length > 0)
- // {
- // foreach (var item in transArray1)
- // {
- // if (item.Contains("&"))
- // {
- // string[] transArray2 = item.Split('&');
- // int index = 0;
- // string companyName = "", job = "";
- // if (transArray2.Length > 0)
- // {
- // bool success = int.TryParse(transArray2[0].Trim(), out index);
- // if (1 < transArray2.Length) companyName = transArray2[1];
- // if (2 < transArray2.Length) job = transArray2[2];
- // }
- // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
- // }
- // }
- // }
- //}
- ////循环赋值
- //for (int i = 0; i < DcList.Count; i++)
- //{
- // string PYName = "";
- // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
- // {
- // string PY_Last = DcList[i].Pinyin.Split('/')[0];
- // string PY_First = DcList[i].Pinyin.Split('/')[1];
- // PYName = PY_First + " " + PY_Last;
- // }
- // else
- // {
- // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
- // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
- // PYName = PY_First + " " + PY_Last;
- // }
- // builder.MoveToCell(0, i + 1, 0, 0);
- // builder.Write(PYName);
- // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
- // builder.MoveToCell(0, i + 1, 1, 0);
- // builder.Write(sex);
- // DateTime birthDt;
- // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
- // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
- // builder.MoveToCell(0, i + 1, 2, 0);
- // builder.Write(birthday);
- // string company = string.Empty, job = string.Empty;
- // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
- // if (dcTransInfo != null)
- // {
- // company = dcTransInfo.CompanyName;
- // job = dcTransInfo.Job;
- // }
- // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
- // {
- // //查询对照表
- // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
- // if (tempCec != null)
- // {
- // company = tempCec.enName;
- // }
- // //翻译
- // else
- // {
- // }
- // }
- // builder.MoveToCell(0, i + 1, 3, 0);
- // builder.Write(company);
- // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
- // {
- // //查询对照表
- // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
- // if (tempPec != null)
- // {
- // job = tempPec.enName;
- // }
- // //翻译
- // else
- // {
- // }
- // }
- // builder.MoveToCell(0, i + 1, 4, 0);
- // builder.Write(job);
- //}
- #endregion
- }
- //删除多余行
- while (tableOne.Rows.Count > DcList.Count + 1)
- {
- tableOne.Rows.RemoveAt(DcList.Count + 1);
- }
- string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
- var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- private class TranslateInfo
- {
- public int Index { get; set; }
- public string CompanyName { get; set; }
- public string Job { get; set; }
- }
- [HttpPost]
- public async Task<IActionResult> FileReadClient(List<IFormFile> files)
- {
- if (files.Count == 0)
- {
- return Ok(JsonView(false, "文件为空"));
- }
- KiMiApiClient KiMiApi = new KiMiApiClient();
- var seedConter = await KiMiApi.UploadFilesAsync(files);
- if (seedConter.Count == 0)
- {
- return Ok(JsonView(false, "上传结果为空!"));
- }
- var messages = new List<SeedMessages>
- {
- new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
- new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
- };
- messages.InsertRange(1, seedConter);
- var kimiApiResult = await KiMiApi.SeedMessage(messages);
- var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
- string clients = kimiApiResult_JObject["content"].ToString();
- string startStr = "```json", endStr = "```";
- // 判断并清除开头部分
- if (clients.StartsWith(startStr))
- {
- clients = clients.Remove(0, startStr.Length);
- }
- // 判断并清除结尾部分
- if (clients.EndsWith(endStr))
- {
- clients = clients.Remove(clients.Length - endStr.Length);
- }
- var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
- Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
- {
- {"姓", "LastName" },
- {"名", "FirstName" },
- {"姓名拼音", "Pinyin" },
- {"性别", "Sex" },
- {"单位", "CompanyFullName" },
- {"职务", "Job" },
- {"出生日期", "Birthday" },
- };
- List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
- foreach (var item in clients_JObject)
- {
- BaiduClientOCRView cdc = new BaiduClientOCRView();
- foreach (var field in clientFieldMap.Keys)
- {
- if (item.TryGetValue(field, out JToken value))
- {
- var getValue = value.ToString();
- System.Type type = cdc.GetType();
- PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
- var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
- propertyInfo.SetValue(cdc, propertyValue);
- }
- }
- crmClients.Add(cdc);
- }
- return Ok(JsonView(new
- {
- fileCount = files.Count,
- UploadCount = seedConter.Count,
- ApiResult = clients,
- CrmClients = crmClients
- }));
- }
- #endregion
- #region 团组倒推表
- /// <summary>
- /// 倒推表基础数据
- /// Init
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListInit()
- {
- var viewData = await _invertedListRep._Init();
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// Info
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
- {
- var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// Create
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
- {
- var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// Update
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
- {
- var viewData = await _invertedListRep._Update(dto);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// File Download
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
- {
- var info2 = await _invertedListRep._Info(1, dto.DiId);
- if (info2.Code != 0)
- {
- return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
- }
- var info1 = info2.Data as InvertedListInfoView;
- var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
- string teamName = "";
- if (info != null) teamName = info.TeamName;
- var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
- var doc = new Document();
- var builder = new DocumentBuilder(doc);
- #region old insert
- ////载入模板
- //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
- //Document doc = new Document(tempPath);
- //DocumentBuilder builder = new DocumentBuilder(doc);
- //利用键值对存放数据
- //Dictionary<string, string> dic = new Dictionary<string, string>();
- //dic.Add("TeamName", teamName);
- //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
- //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
- //dic.Add("BPRemark", info1.ApprovalDataRemark);
- //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
- //dic.Add("SQRemark", info1.ApprovalRemark);
- //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
- //dic.Add("CPJRemark", info1.IssueApprovalRemark);
- ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
- ////dic.Add("HZRemark", info1.ApplyPassportRemark);
- //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
- //dic.Add("QZRemark", info1.VisaInformationRemark);
- //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
- //dic.Add("SQQZRemark", info1.SendVisaRemark);
- //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
- //dic.Add("CQRemark", info1.IssueVisaRemark);
- //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
- //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
- //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
- //dic.Add("SJRemark", info1.AirportdDropOffRemark);
- //#region 填充word模板书签内容
- //foreach (var key in dic.Keys)
- //{
- // builder.MoveToBookmark(key);
- // builder.Write(dic[key]);
- //}
- //#endregion
- #endregion
- #region New Insert
- string titleFont = $"仿宋",
- contentFont = $"仿宋";
- var fontColor = Color.FromArgb(64, 64, 64);
- //设置标题 团组名称
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
- builder.Font.Name = titleFont;
- builder.Font.Color = fontColor;
- builder.Font.Size = 12;
- builder.Font.Bold = true;
- builder.Writeln(teamName);
- //设置副标题 团组出访时间
- builder.Font.Size = 12;
- builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
- builder.Writeln();
- var backgroundColor = Color.FromArgb(199, 199, 199);
- var table = builder.StartTable();
- builder.InsertCell();
- builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
- builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
- builder.CellFormat.Borders.LineWidth = 1;
- builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
- table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
- builder.RowFormat.Height = 40;
- builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
- builder.Font.Name = contentFont;
- builder.Font.Size = 12;
- builder.Font.Bold = true;
- builder.Font.Color = fontColor;
- builder.Write("时间");
- builder.InsertCell();
- table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
- builder.Write("流程");
- builder.InsertCell();
- table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
- builder.Write("说明");
- builder.EndRow();
- //报批资料准备
- if (info1.IsSelectedAirportd)
- {
- InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
- }
- //报批/提供送签资料
- if (info1.IsSelectedApprovalData)
- {
- InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
- }
- //出批件护照办理
- if (info1.IsSelectedIssueApproval)
- {
- InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
- }
- //签证资料准备
- if (info1.IsSelectedVisaInfo)
- {
- InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
- }
- //送签
- if (info1.IsSelectedSendVisa)
- {
- InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
- }
- //出签
- if (info1.IsSelectedIssueVisa)
- {
- InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
- }
- //机票
- if (info1.IsSelectedAirTicket)
- {
- if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
- InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
- }
- //酒店
- if (info1.IsSelectedHotel)
- {
- if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
- InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
- }
- //开行前会
- if (info1.IsSelectedPreTripMeeting)
- {
- InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
- }
- //送机
- if (info1.IsSelectedAirportdDropOff)
- {
- InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
- }
- builder.EndTable();
- //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
- //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
- for (int i = 0; i < table.Rows.Count; i++)
- {
- var row = table.Rows[i];
- //设置宽度
- row.Cells[0].CellFormat.Width = 20.00;
- row.Cells[1].CellFormat.Width = 30.00;
- row.Cells[2].CellFormat.Width = 50.00;
- if (i != 0)
- {
- //边框设置
- InvertedListFileDownloadSetBorders(row.Cells, 0);
- InvertedListFileDownloadSetBorders(row.Cells, 1);
- InvertedListFileDownloadSetBorders(row.Cells, 2);
- }
- }
- #region 页脚插入图片
- // 创建页脚
- Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
- doc.FirstSection.HeadersFooters.Add(footer);
- Paragraph para = new Paragraph(doc);
- para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
- footer.AppendChild(para);
- builder.MoveTo(para);
- string imagePath = "./Images/FMGJ_Log.png";
- builder.InsertImage(imagePath);
- #endregion
- #endregion
- var fileDir = AppSettingsHelper.Get("WordBasePath");
- string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
- string filePath = fileDir + $@"InvertedList/{fileName}";
- doc.Save(filePath);
- string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
- return Ok(JsonView(true, "操作成功!", Url));
- }
- private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
- {
- var fontColor = Color.FromArgb(64, 64, 64);
- builder.InsertCell();
- builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
- builder.RowFormat.Height = 40;
- builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
- builder.Font.Name = fontName;
- builder.Font.Size = 8;
- builder.Font.Bold = true;
- builder.Font.Color = fontColor;
- builder.Write(dateTime);
- builder.InsertCell();
- builder.Font.Size = 9;
- builder.Font.Bold = true;
- builder.Font.Color = fontColor;
- builder.Write(content);
- builder.InsertCell();
- builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
- builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
- builder.Font.Size = 9;
- builder.Font.Bold = false;
- builder.Font.Color = fontColor;
- builder.Write(reamrk);
- builder.EndRow();
- }
- private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
- {
- cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
- cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
- cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
- cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
- //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
- //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
- }
- #endregion
- #region 会务倒推表
- /// <summary>
- /// 会务倒推表
- /// Init
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InforRetrogressTableInit()
- {
- var groupData = await _groupRepository.PostShareGroupInfos(1);
- if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
- return Ok(JsonView(false, groupData.Msg));
- }
- /// <summary>
- /// 会务倒推表
- /// ExcelDownload
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ApiLog("InforRetrogressTable", OperationEnum.Download)]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
- {
- var validator = new InforRetrogressTableFileDownloadDtoValidator();
- var validatorRes = await validator.ValidateAsync(dto);
- if (!validatorRes.IsValid)
- {
- StringBuilder sb = new StringBuilder();
- foreach (var item in validatorRes.Errors)
- {
- sb.AppendLine(item.ErrorMessage);
- }
- return Ok(JsonView(false, sb.ToString()));
- }
- var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
- if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
- //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
- var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
- #region Excel
- var tempPath = AppSettingsHelper.Get("ExcelTempPath");
- var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
- var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
- var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
- var fileNamePrefix = string.Empty;
- if (days >= 30)
- {
- tempPath += $"会务工作倒推进度表(30天).xlsx";
- fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
- }
- else if (days < 30 && days > 7)
- {
- tempPath += $"会务工作倒推进度表(15天).xlsx";
- fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
- }
- else if (days <= 7)
- {
- tempPath += $"会务工作倒推进度表(7天).xlsx";
- fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
- }
- var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
- fileName = CommonFun.ValidFileName(fileName);
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(tempPath);
- designer.Process();
- if (!Directory.Exists(savePath))
- {
- Directory.CreateDirectory(savePath);
- }
- string serverPath = $"{savePath}{fileName}";
- designer.Workbook.Save(serverPath);
- string rst = $"{servicePath}{ftpPath}{fileName}";
- #endregion
- return Ok(JsonView(new { url = rst }));
- }
- #endregion
- #region 三公签证费用(签证费、代办费)
- /// <summary>
- /// 三公签证费用(签证费、代办费)
- /// List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
- {
- var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
- if (_view.Code != 0)
- {
- return Ok(JsonView(false, _view.Msg));
- }
- return Ok(JsonView(true, "操作成功!", _view.Data));
- }
- /// <summary>
- /// 三公签证费用(签证费、代办费)
- /// Add Or Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
- {
- var _view = await _visaFeeInfoRep._Update(_dto);
- if (_view.Code != 0)
- {
- return Ok(JsonView(false, _view.Msg));
- }
- return Ok(JsonView(true, _view.Msg));
- }
- #endregion
- #region 酒店询价
- /// <summary>
- /// 酒店询价
- /// Init
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelInquiryInit()
- {
- var res = await _hotelInquiryRep._Init();
- if (res.Code != 0) return Ok(JsonView(false, res.Msg));
- return Ok(JsonView(true, res.Msg, res.Data));
- }
- /// <summary>
- /// 酒店询价
- /// page Item
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
- {
- var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
- if (res.Code != 0) return Ok(JsonView(false, res.Msg));
- var view = res.Data as PageDataViewBase;
- return Ok(JsonView(true, res.Msg, view.Data, view.Total));
- }
- /// <summary>
- /// 酒店询价
- /// info
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
- {
- var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
- if (res.Code != 0) return Ok(JsonView(false, res.Msg));
- return Ok(JsonView(true, res.Msg, res.Data));
- }
- /// <summary>
- /// 酒店询价
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
- {
- var res = await _hotelInquiryRep._AddOrEdit(_dto);
- if (res.Code != 0) return Ok(JsonView(false, res.Msg));
- return Ok(JsonView(true, res.Msg, res.Data));
- }
- /// <summary>
- /// 酒店询价
- /// Del
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
- {
- var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
- if (res.Code != 0) return Ok(JsonView(false, res.Msg));
- return Ok(JsonView(true, res.Msg, res.Data));
- }
- #endregion
- #region 下载匹配op行程单
- /// <summary>
- /// 匹配op行程单
- /// Init
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
- {
- Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
- List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
- groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
- .Where(it => it.IsDel == 0)
- .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
- .OrderByDescending(it => it.VisitStartDate)
- .ToList();
- if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
- var country = groupInfos.Select(it => it.VisitCountry).ToList();
- var diids = groupInfos.Select(it => it.Id).ToList();
- List<string> countrys = new List<string>();
- foreach (var item in country)
- {
- var data = _groupRepository.FormartTeamName(item);
- var dataArray = _groupRepository.GroupSplitCountry(data);
- if (dataArray.Count > 0) countrys.AddRange(dataArray);
- }
- countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
- List<string> areaArray = new List<string>(); //GetGroupCityLine
- var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
- foreach (var item in areaItem)
- {
- string areaStr = item.Value;
- if (!string.IsNullOrEmpty(areaStr))
- {
- string[] str1 = areaStr.Split("-");
- if (str1.Length > 0)
- {
- areaArray.AddRange(str1);
- }
- }
- }
- if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
- var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
- .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
- .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
- .ToList();
- List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
- var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
- .Where(it => countriesIds.Contains(it.Id))
- .Select(it => new { it.Id, Name = it.Name_CN })
- .ToList();
- var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
- .Select(it => it.TeamName).ToList();
- stopwatch.Stop();
- return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
- }
- ///// <summary>
- ///// 匹配op行程单
- ///// Init 查询区域数据
- ///// </summary>
- ///// <param name="dto">团组列表请求dto</param>
- ///// <returns></returns>
- //[HttpPost]
- //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
- //{
- // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
- // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
- // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
- // if (string.IsNullOrEmpty(countriesDataStr))
- // {
- // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
- // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
- // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
- // }
- // else
- // {
- // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
- // }
- // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
- // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
- // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
- // List<dynamic> childList = new List<dynamic>();
- // int parentId = dto.CountriesId;
- // if (provinceData.Count > 1)
- // {
- // foreach (var item1 in provinceData)
- // {
- // List<dynamic> childList1 = new List<dynamic>();
- // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
- // foreach (var item2 in citiesData1)
- // {
- // List<dynamic> childList2 = new List<dynamic>();
- // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
- // foreach (var item3 in countiesData1)
- // {
- // childList2.Add(new
- // {
- // id = item3.Id,
- // parentId = item2.Id,
- // level = "district",
- // name = item3.Name_CN,
- // });
- // }
- // childList1.Add(new
- // {
- // id = item2.Id,
- // parentId = item1.Id,
- // level = "city",
- // name = item2.Name_CN,
- // childList = childList2
- // });
- // }
- // childList.Add(new
- // {
- // id = item1.Id,
- // parentId = parentId,
- // level = "province",
- // name = item1.Name_CN,
- // childList = childList1
- // });
- // }
- // //城市
- // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
- // foreach (var item2 in citiesData2)
- // {
- // List<dynamic> childList22 = new List<dynamic>();
- // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
- // foreach (var item3 in countiesData1)
- // {
- // childList22.Add(new
- // {
- // id = item3.Id,
- // parentId = item2.Id,
- // level = "district",
- // name = item3.Name_CN,
- // });
- // }
- // childList.Add(new
- // {
- // id = item2.Id,
- // parentId = parentId,
- // level = "city",
- // name = item2.Name_CN,
- // childList = childList22
- // });
- // }
- // }
- // else
- // {
- // foreach (var item2 in citiesData)
- // {
- // string cname = item2.Name_CN;
- // List<dynamic> childList1 = new List<dynamic>();
- // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
- // foreach (var item3 in countiesData1)
- // {
- // childList1.Add(new
- // {
- // Id = item3.Id,
- // parentId = item2.Id,
- // level = "district",
- // name = item3.Name_CN
- // });
- // }
- // childList.Add(new
- // {
- // id = item2.Id,
- // parentId = parentId,
- // level = "city",
- // name = item2.Name_CN,
- // childList = childList1
- // });
- // }
- // }
- // stopwatch.Stop();
- // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
- //}
- /// <summary>
- /// 匹配op行程单
- /// 接团信息列表 Page
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
- {
- var swatch = new Stopwatch();
- swatch.Start();
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
- {
- var _view = await GeneralMethod.MateOpGroupPageListRedis();
- //string sqlWhere = "";
- if (!string.IsNullOrEmpty(dto.Country))
- {
- _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
- }
- if (!string.IsNullOrEmpty(dto.Area))
- {
- _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
- }
- if (!string.IsNullOrEmpty(dto.TeamName))
- {
- _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
- }
- int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
- int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
- var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
- swatch.Stop();
- return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 匹配op行程单
- /// 行程单下载
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
- #endregion
- #endregion
- if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
- {
- var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
- return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
- }
- else
- {
- return Ok(JsonView(false, "下载失败!"));
- }
- }
- #endregion
- #region 国家信息 数据 注释
- //[HttpPost]
- //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
- //{
- // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
- // foreach (var item in dto)
- // {
- // infos.Add(new Grp_GroupsTaskAssignment()
- // {
- // DIId = item,
- // CTId = 82,
- // UId = 248,
- // IsEnable = 1,
- // CreateUserId = 233,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // });
- // infos.Add(new Grp_GroupsTaskAssignment()
- // {
- // DIId = item,
- // CTId = 82,
- // UId = 286,
- // IsEnable = 1,
- // CreateUserId = 233,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // });
- // }
- // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
- // return Ok("操作成功");
- //}
- //public class paramJsonDto
- //{
- // public List<CountriesInfo> str { get; set; }
- //}
- //[HttpPost]
- //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
- //{
- // //List<CountriesInfo> infos = new List<CountriesInfo>();
- // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
- // List<Sys_Cities> cities = new List<Sys_Cities>();
- // List<Sys_Cities> districts = new List<Sys_Cities>();
- // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
- // _sqlSugar.BeginTran();
- // int countitiesIndex = 0;
- // foreach (var item in dto.str)
- // {
- // dynamic data = item.c;
- // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
- // if (data != null)
- // {
- // countitiesIndex++;
- // foreach (var item1 in data)
- // {
- // string cnname = item1.cn;
- // string enname = item1.en;
- // Sys_Cities provinceInfo = new Sys_Cities()
- // {
- // CountriesId = countriesId,
- // Name_CN = cnname,
- // Name_EN = enname,
- // ParentId = 0,
- // IsCapital = 1,
- // CreateUserId = 208,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // };
- // if (item1.lv == "province") //省份
- // {
- // provinceInfo.Level = 1;
- // int provinceId = 0;
- // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
- // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
- // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
- // var data1 = item1.c;
- // foreach (var item2 in data1)
- // {
- // if (item2.lv == "city")
- // {
- // string citycnname = item2.cn;
- // string cityenname = item2.en;
- // Sys_Cities cityInfo = new Sys_Cities()
- // {
- // CountriesId = countriesId,
- // ParentId = provinceId,
- // Level = 2,
- // Name_CN = citycnname,
- // Name_EN = cityenname,
- // IsCapital = 1,
- // CreateUserId = 208,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // };
- // if (item2.c != null)
- // {
- // int cityId = 0;
- // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
- // if (citiesInfo != null) cityId = citiesInfo.Id;
- // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
- // foreach (var item3 in item2.c)
- // {
- // if (item3.lv == "district")
- // {
- // var districtInfo = new Sys_Cities()
- // {
- // CountriesId = countriesId,
- // Name_CN = item3.cn,
- // Name_EN = item3.en,
- // Level = 3,
- // ParentId = cityId,
- // IsCapital = 1,
- // CreateUserId = 208,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // };
- // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
- // //{
- // districts.Add(districtInfo);
- // //}
- // }
- // }
- // }
- // else
- // {
- // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
- // //{
- // cities.Add(cityInfo);
- // //}
- // }
- // }
- // }
- // }
- // else if (item1.lv == "city")//城市
- // {
- // provinceInfo.Level = 2;
- // if (item1.c != null)
- // {
- // int cityId = 0;
- // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
- // if (citiesInfo != null) cityId = citiesInfo.Id;
- // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
- // foreach (var item3 in item1.c)
- // {
- // if (item3.lv == "district")
- // {
- // var districtInfo = new Sys_Cities()
- // {
- // CountriesId = countriesId,
- // Name_CN = item3.cn,
- // Name_EN = item3.en,
- // Level = 3,
- // ParentId = cityId,
- // IsCapital = 1,
- // CreateUserId = 208,
- // CreateTime = DateTime.Now,
- // IsDel = 0
- // };
- // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
- // //{
- // districts.Add(districtInfo);
- // //}
- // }
- // }
- // }
- // else
- // {
- // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
- // //{
- // cities.Add(provinceInfo);
- // //}
- // }
- // }
- // }
- // }
- // }
- // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
- // cities = cities.Distinct().ToList();
- // districts = districts.Distinct().ToList();
- // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
- // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
- // cities.AddRange(districts);
- // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
- // //_sqlSugar.RollbackTran();
- // _sqlSugar.CommitTran();
- // return Ok(JsonView(false, "操作成功!"));
- //}
- //[HttpPost]
- //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
- //{
- // List<CountitiesInfo> infos = dto.MyProperty;
- // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
- // _sqlSugar.BeginTran();
- // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
- // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
- // foreach (var item in infos)
- // {
- // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
- // if (countryInfo != null)
- // {
- // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
- // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
- // if (cityInfo1 != null)
- // {
- // cityInfo1.IsCapital = 0;
- // cityInfos.Add(cityInfo1);
- // }
- // }
- // }
- // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
- // .UpdateColumns(it => it.IsCapital)
- // .WhereColumns(it => it.Id)
- // .ExecuteCommand();
- // //_sqlSugar.RollbackTran();
- // _sqlSugar.CommitTran();
- // return Ok(JsonView(false, "操作成功!"));
- //}
- //public class CounrtiesDto
- //{
- // public List<CountitiesInfo> MyProperty { get; set; }
- //}
- //public class CountitiesInfo
- //{
- // /// <summary>
- // /// 圣约翰
- // /// </summary>
- // public string capital_name_chinese { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string capital_name { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_type { get; set; }
- // /// <summary>
- // /// 安提瓜和巴布达
- // /// </summary>
- // public string country_name_chinese { get; set; }
- // /// <summary>
- // /// 安提瓜和巴布达
- // /// </summary>
- // public string country_name_chinese_short { get; set; }
- // /// <summary>
- // /// 安提瓜和巴布达
- // /// </summary>
- // public string country_name_chinese_UN { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_name_english_abbreviation { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_name_english_formal { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_name_english_UN { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string continent_name { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string subregion_name { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_code2 { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string country_code3 { get; set; }
- // /// <summary>
- // ///
- // /// </summary>
- // public string phone_code { get; set; }
- //}
- //public class CountriesInfo : BasicInfo
- //{
- // public List<CitiesInfo> c { get; set; }
- //}
- //public class CitiesInfo : BasicInfo
- //{
- // public List<AreaInfo> c { get; set; }
- //}
- //public class AreaInfo : BasicInfo
- //{
- // public List<AreaInfo> c { get; set; }
- //}
- //public class BasicInfo
- //{
- // public string code { get; set; }
- // public string cn { get; set; }
- // public string lv { get; set; }
- // public string en { get; set; }
- //}
- #endregion
- #region 查看邀请方
- /// <summary>
- /// 查看邀请方
- /// 邀请方信息 Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
- {
- string sqlWhere = string.Empty;
- if (!string.IsNullOrEmpty(dto.Search))
- {
- sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
- }
- string sql = string.Format($@"Select
- ROW_NUMBER() Over(Order By Id desc) As Row_Number,
- Id,
- UnitName
- From Res_InvitationOfficialActivityData
- Where IsDel = 0
- And (UnitName != '' Or UnitName != null) {sqlWhere}");
- RefAsync<int> total = 0;
- var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, MsgTips.Succeed, _views, total));
- }
- /// <summary>
- /// 查看邀请方
- /// 国家信息 Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
- {
- var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
- var country = groupInfos.Select(it => it.VisitCountry).ToList();
- var diids = groupInfos.Select(it => it.Id).ToList();
- List<string> countrys = new List<string>();
- foreach (var item in country)
- {
- var data = _groupRepository.FormartTeamName(item);
- var dataArray = _groupRepository.GroupSplitCountry(data);
- if (dataArray.Count > 0) countrys.AddRange(dataArray);
- }
- countrys = countrys.Distinct().ToList();
- for (int i = 0; i < countrys.Count; i++)
- {
- string item = countrys[i];
- if (string.IsNullOrEmpty(item) || item.Contains("-"))
- {
- countrys.Remove(item);
- i--;
- }
- }
- RefAsync<int> total = 0;
- var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
- .Where(it => countrys.Contains(it.Name_CN))
- .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
- .Select(it => new { id = it.Id, name = it.Name_CN })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
- }
- /// <summary>
- /// 查看邀请方
- /// 城市信息 Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
- {
- if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
- RefAsync<int> total = 0;
- var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
- .Where(it => it.CountriesId == dto.CountiesId)
- .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
- .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
- .Select(it => new { id = it.Id, name = it.Name_CN })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
- }
- /// <summary>
- /// 查看邀请方
- /// 团组名称 Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
- {
- var watch = new Stopwatch();
- watch.Start();
- RefAsync<int> total = 0;
- var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
- .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
- .Where((oa, di) => oa.IsDel == 0)
- .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
- .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
- .Select((oa, di) => new { id = di.Id, name = di.TeamName })
- .Distinct()
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- watch.Stop();
- return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
- }
- /// <summary>
- /// 查看邀请方
- /// 团组 & 邀请方信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
- {
- var watch = new Stopwatch();
- watch.Start();
- RefAsync<int> total = 0;
- var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
- .AS("Grp_DelegationInfo")
- .Includes(x => x.InvitingInfos)
- .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
- .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
- .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
- .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
- .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
- .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
- var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
- infos.ForEach(x =>
- {
- x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
- x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
- x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
- x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
- });
- watch.Stop();
- return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
- }
- #endregion
- #region 报批行程
- /// <summary>
- /// 报批行程初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
- {
- const int chiNumber = 5;
- var jw = JsonView(false);
- var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
- var group = groupList.First();
- var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
- group = groupList.First(x => x.Id == diid);
- var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
- .Where(x => x.DiId == diid && x.IsDel == 0)
- .ToArray();
- var count = 1;
- foreach (var item in blackCodeList)
- {
- if (string.IsNullOrWhiteSpace(item.Title))
- {
- item.Title = "未设置名称数据" + count;
- }
- count++;
- };
- if (group == null)
- {
- jw.Msg = "暂无团组!";
- return Ok(jw);
- }
- var data = new
- {
- groupList = groupList.Select(x => new
- {
- x.TeamName,
- x.Id
- }),
- content = new ArrayList(),
- groupInfo = new
- {
- group.VisitDays,
- group.TourCode,
- group.VisitPNumber,
- group.TeamName,
- group.Id,
- visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
- visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
- },
- blackCodeList = blackCodeList.Select(x => new
- {
- x.Title,
- x.Id
- }),
- FileTempList = new ArrayList()
- {
- new { Index = 1,FileName = "旧模板" },
- new { Index = 2,FileName = "省外办" },
- new { Index = 3,FileName = "市外办" },
- }
- };
- var resultArr = new ArrayList();
- var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
- #region 默认不生成行程
- //if (content.Count == 0)
- //{
- // var stay = "-";
- // var cityPath = "-";
- // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
- // .Where(x => x.DiId == diid && x.IsDel == 0)
- // .ToList();
- // //添加城市路径以及住宿地
- // //黑屏代码数据
- // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
- // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
- // {
- // jw = JsonView(true, "黑屏代码有误!", data);
- // return Ok(jw);
- // }
- // data = data with
- // {
- // blackCodeList = new ArrayList(blackCodeList.Select(x => new
- // {
- // x.Title,
- // x.Id,
- // }).ToArray())
- // };
- // foreach (DataRow row in dtBlack.Rows)
- // {
- // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
- // {
- // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
- // return Ok(jw);
- // }
- // }
- // //黑屏代码获取时间区间
- // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
- // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
- // _sqlSugar.BeginTran();
- // for (int i = 0; i < timeArr.Count; i++)
- // {
- // stay = "-";
- // cityPath = "-";
- // DateTime NewData = DateTime.Parse(timeArr[i]);
- // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
- // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
- // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
- // if (tbSelect.Length > 0)
- // {
- // List<string> threeCodeStr = new List<string>();
- // foreach (var item in tbSelect)
- // {
- // var threeCode = item["Three"].ToString() ?? "";
- // if (threeCode.Length == 6)
- // {
- // var start = threeCode.Substring(0, 3);
- // var end = threeCode.Substring(3, 3);
- // if (threeCodeStr.Count == 0)
- // {
- // threeCodeStr.Add(start);
- // threeCodeStr.Add(end);
- // }
- // else
- // {
- // if (threeCodeStr[threeCodeStr.Count - 1] == start)
- // {
- // threeCodeStr.Add(end);
- // }
- // else
- // {
- // threeCodeStr.Add(start);
- // threeCodeStr.Add(end);
- // }
- // }
- // }
- // }
- // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
- // var last = threeCodeStr.Last();
- // foreach (var item in threeCodeStr)
- // {
- // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
- // if (item.Equals(last))
- // {
- // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
- // }
- // }
- // cityPath = cityPath.Trim('-');
- // }
- // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
- // appro.Diid = diid ?? -1;
- // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
- // appro.Id = thisId;
- // appro.CreateUserId = dto.UserId;
- // appro.CreateTime = DateTime.Now;
- // content.Add(appro);
- // }
- // _sqlSugar.CommitTran();
- //}
- #endregion
- foreach (var x in content)
- {
- var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
- if (chiList.Count < chiNumber)
- {
- for (int i = chiList.Count; i < chiNumber; i++)
- {
- chiList.Add(new Grp_ApprovalTravelDetails());
- }
- }
- resultArr.Add(new
- {
- x.Id,
- x.Date,
- x.Diid,
- chiList = chiList.Select(x1 => new
- {
- timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
- x1.Details,
- x1.ParentId,
- x1.Id
- })
- });
- }
- data = data with
- {
- content = resultArr,
- };
- jw = JsonView(true, "获取成功!", data);
- return Ok(jw);
- }
- /// <summary>
- /// 报批行程删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
- {
- var jw = JsonView(false);
- var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (group == null)
- {
- jw.Msg = "团组参数有误!";
- return Ok(jw);
- }
- try
- {
- _sqlSugar.BeginTran();
- var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
- _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
- {
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- DeleteUserId = dto.uesrId,
- IsDel = 1
- }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
- _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
- {
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- DeleteUserId = dto.uesrId,
- IsDel = 1
- }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
- _sqlSugar.CommitTran();
- jw = JsonView(true, "删除成功");
- }
- catch (Exception ex)
- {
- jw = JsonView(false, ex.Message);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 报批行程保存
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
- {
- var jw = JsonView(false);
- var Find = dto.Arr.Find(x => x.id == 0);
- if (Find != null)
- {
- jw.Msg = "生成的ID为0!";
- return Ok(jw);
- }
- foreach (var item in dto.Arr)
- {
- foreach (var chi in item.chiList)
- {
- if (chi.parentId == 0)
- {
- chi.parentId = item.id;
- }
- }
- }
- var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
- _sqlSugar.BeginTran();
- if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
- {
- var parentIds = dto.Arr.Select(x => x.id).ToList();
- _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
- {
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- DeleteUserId = dto.UserId,
- IsDel = 1
- }).ExecuteCommand();
- }
- try
- {
- _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
- {
- CreateTime = DateTime.Now,
- CreateUserId = dto.UserId,
- Details = x.details,
- ParentId = x.parentId,
- Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
- Remark = "",
- IsDel = 0
- }).ToList()).ExecuteCommand();
- _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
- {
- Id = x.id,
- Details = x.details,
- ParentId = x.parentId,
- Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
- }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
- {
- Details = x.Details,
- ParentId = x.ParentId,
- Time = x.Time
- }).ExecuteCommand();
- _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
- {
- Id = x.id,
- Date = x.date,
- }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
- {
- Date = x.Date
- }).ExecuteCommand();
- _sqlSugar.CommitTran();
- jw = JsonView(true, "保存成功!");
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- jw = JsonView(false, "保存失败!" + ex.Message);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 报批行程生成
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
- {
- var jw = JsonView(false);
- var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (group == null)
- {
- jw.Msg = "暂无该团组!";
- return Ok(jw);
- }
- var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
- //黑屏代码数据
- DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
- if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
- {
- jw.Msg = "黑屏代码有误!";
- return Ok(jw);
- }
- foreach (DataRow row in dtBlack.Rows)
- {
- if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
- {
- jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
- return Ok(jw);
- }
- }
- //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
- var resultArr = new ArrayList();
- //if (officialActivitiesArr.Count == 0)
- //{
- // jw.Msg = "暂无公务出访信息!";
- // return Ok(jw);
- //}
- try
- {
- _sqlSugar.BeginTran();
- DeleteApprovalJourney(new
- Domain.Dtos.Groups.DeleteApprovalJourney
- {
- Diid = dto.Diid,
- uesrId = dto.Userid
- });
- var stay = "-";
- var cityPath = "-";
- var arriveCountry = string.Empty;
- //添加城市路径以及住宿地
- //黑屏代码获取时间区间
- var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
- var empty = "【未收入该三字码!请机票同事录入】";
- string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
- #region 配置公务活动时间
- List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
- Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
- Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
- Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
- Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
- List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
- {
- 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" }),
- 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"}),
- new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
- new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
- };
- List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
- {
- 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" }),
- 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"}),
- new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
- new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
- };
- List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
- {
- 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" }),
- 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"}),
- new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
- new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
- };
- #endregion
- var nextDayNum = 0;
- for (int i = 0; i < timeArr.Count; i++)
- {
- stay = "-";
- cityPath = "-";
- var chiarr = new List<Grp_ApprovalTravelDetails>();
- DateTime NewData = DateTime.Parse(timeArr[i]);
- //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();
- var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
- if (nextDayNum > 0)
- {
- nextDayNum--;
- }
- if (tbSelect.Length > 0)
- {
- List<string> threeCodeStr = new List<string>();
- bool isTrade = false;
- string trip = string.Empty;
- foreach (var item in tbSelect)
- {
- if (nextDayNum == 0)
- {
- nextDayNum = Convert.ToInt32(item["Sign"]);
- }
- var airStartTime = item["StartTime"].ToString() ?? "0000";
- var airEndTime = item["EndTime"].ToString() ?? "0000";
- var takeOffTime = DateTime.Parse(timeArr[i]);
- var fallToTime = DateTime.Parse(timeArr[i]);
- takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
- takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
- fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
- fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
- if (nextDayNum > 0)
- {
- fallToTime = fallToTime.AddDays(nextDayNum);
- }
- trip = string.Empty;
- var start = string.Empty;
- var end = string.Empty;
- var threeCode = item["Three"].ToString() ?? "";
- if (threeCode.Length == 6)
- {
- start = threeCode.Substring(0, 3);
- end = threeCode.Substring(3, 3);
- if (threeCodeStr.Count == 0)
- {
- threeCodeStr.Add(start);
- threeCodeStr.Add(end);
- }
- else
- {
- if (threeCodeStr[threeCodeStr.Count - 1] == start)
- {
- threeCodeStr.Add(end);
- }
- else
- {
- threeCodeStr.Add(start);
- threeCodeStr.Add(end);
- }
- }
- }
- //处理机票信息
- var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
- var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
- if (start_Object == null)
- {
- start_Object = new Res_ThreeCode()
- {
- AirPort = empty,
- AirPort_En = empty,
- City = empty,
- Country = empty,
- Four = empty,
- Three = empty,
- };
- }
- if (end_Object == null)
- {
- end_Object = new Res_ThreeCode()
- {
- AirPort = empty,
- AirPort_En = empty,
- City = empty,
- Country = empty,
- Four = empty,
- Three = empty,
- };
- }
- //机型判断
- string airModel = item["AirModel"].ToString();
- airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
- string flightTime = item["FlightTime"].ToString();
- flightTime = ParseBlackTime(flightTime);
- //航班号
- string flightcode = item["Fliagtcode"].ToString();
- var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
- var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
- if (aircompany == null)
- {
- aircompany = new Res_AirCompany
- {
- CnName = hsEmpty,
- EnName = hsEmpty,
- ShortCode = hsEmpty,
- };
- }
- //航班前公务安排
- if (tbSelect.First().Equals(item) && i != 0)
- {
- foreach (var takeoff in takeoffTimes)
- {
- var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
- if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
- {
- foreach (var addTime in takeoff.Item2)
- {
- chiarr.Add(new Grp_ApprovalTravelDetails
- {
- Time = addTime,
- CreateTime = DateTime.Now,
- CreateUserId = dto.Userid,
- ParentId = 0,
- Details = "公务活动"
- });
- }
- break;
- }
- }
- }
- //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
- //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
- //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
- trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
- isTrade = Convert.ToBoolean(item["isTransitShipment"]);
- if (isTrade)
- {
- //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
- trip += "(转机不出机场)。";
- }
- //else
- //{
- // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
- //}
- chiarr.Add(new Grp_ApprovalTravelDetails
- {
- Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
- CreateTime = DateTime.Now,
- CreateUserId = dto.Userid,
- ParentId = 0,
- Details = trip
- });
- //最后一条到达的时间安排公务
- if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
- {
- bool isCheckCountry = false;
- if (end_Object.Country != arriveCountry)
- {
- arriveCountry = end_Object.Country;
- isCheckCountry = true;
- }
- if (nextDayNum == 0)
- {
- //需要入境的情况
- if (isCheckCountry)
- {
- foreach (var fallTime in fallTimesCheckCountry)
- {
- var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
- if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
- {
- foreach (var addTime in fallTime.Item2)
- {
- chiarr.Add(new Grp_ApprovalTravelDetails
- {
- Time = addTime,
- CreateTime = DateTime.Now,
- CreateUserId = dto.Userid,
- ParentId = 0,
- Details = "公务活动"
- });
- }
- break;
- }
- }
- }
- else
- {
- foreach (var fallTime in fallTimesNotCheckCountry)
- {
- var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
- if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
- {
- foreach (var addTime in fallTime.Item2)
- {
- chiarr.Add(new Grp_ApprovalTravelDetails
- {
- Time = addTime,
- CreateTime = DateTime.Now,
- CreateUserId = dto.Userid,
- ParentId = 0,
- Details = "公务活动"
- });
- }
- break;
- }
- }
- }
- }
- }
- }
- //添加乘车语句
- //chiarr.Add(new Grp_ApprovalTravelDetails
- //{
- // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
- // CreateTime = DateTime.Now,
- // CreateUserId = dto.Userid,
- // ParentId = 0,
- // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
- //});
- //if (i != timeArr.Count - 1)
- //{
- // fallToTime = fallToTime.AddHours(2.5);
- // foreach (var item in Times)
- // {
- // //排列公务时间
- // if (fallToTime.Hour < item.Item1)
- // {
- // chiarr.Add(new Grp_ApprovalTravelDetails
- // {
- // Time = $"{item.Item2} - {item.Item3}",
- // CreateTime = DateTime.Now,
- // CreateUserId = dto.Userid,
- // ParentId = 0,
- // Details = "公务活动"
- // });
- // }
- // }
- //}
- var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
- var last = threeCodeStr.Last();
- foreach (var item in threeCodeStr)
- {
- cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
- if (item.Equals(last))
- {
- stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
- }
- }
- cityPath = cityPath.Trim('-');
- }
- else
- {
- foreach (var item in Times)
- {
- chiarr.Add(new Grp_ApprovalTravelDetails
- {
- Time = $"{item.Item2} - {item.Item3}",
- CreateTime = DateTime.Now,
- CreateUserId = dto.Userid,
- ParentId = 0,
- Details = "公务活动"
- });
- }
- }
- string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
- Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
- appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
- appro.Diid = dto.Diid;
- appro.CreateUserId = dto.Userid;
- appro.CreateTime = DateTime.Now;
- var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
- appro.Id = thisId;
- //foreach (var item in gwinfo)
- //{
- // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
- // chi.Details = "拜访" + item.Client;
- // if (!string.IsNullOrWhiteSpace(item.ReqSample))
- // {
- // chi.Details += "," + item.ReqSample;
- // }
- // chi.ParentId = thisId;
- // chi.Time = item.Time;
- // chiarr.Add(chi);
- //}
- if (chiarr.Count < 6)
- {
- for (int j = chiarr.Count; j < 6; j++)
- {
- chiarr.Add(new
- Grp_ApprovalTravelDetails());
- }
- }
- resultArr.Add(new
- {
- appro.Id,
- appro.Date,
- appro.Diid,
- chiList = chiarr.Select(x1 => new
- {
- timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
- x1.Details,
- x1.ParentId,
- x1.Id
- })
- });
- }
- _sqlSugar.CommitTran();
- jw = JsonView(true, "生成成功!", resultArr);
- }
- catch (Exception ex)
- {
- jw.Code = 400;
- jw.Msg = "生成失败!" + ex.Message;
- }
- return Ok(jw);
- }
- /// <summary>
- /// 报批行程word导出
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
- {
- var jw = JsonView(false);
- var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
- if (group == null)
- {
- jw.Msg = "暂无该团组!";
- return Ok(jw);
- }
- //模板路径
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
- var fileName = string.Empty;
- string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
- bool bold = false;
- if (dto.FileIndex == 1)
- {
- fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
- }
- else if (dto.FileIndex == 2)
- {
- fileName = "省外办-报批.docx";
- bold = false;
- titleFont = "方正黑体简体";
- timeFont = "Times New Roman";
- contentFont = "方正仿宋_GBK";
- }
- else if (dto.FileIndex == 3)
- {
- fileName = "市外办-报批.docx";
- titleFont = "方正黑体简体";
- timeFont = "Times New Roman";
- contentFont = "方正仿宋简体";
- }
- tempPath = tempPath + fileName;
- //载入模板
- Document doc = new Document(tempPath);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- Aspose.Words.Tables.Row titleRowClone = null;
- Aspose.Words.Tables.Row CenterRowClone = null;
- int index = 0;
- int indexChi = 0;
- int SetIndex = 0;
- var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
- //获取数据,放到datatable
- foreach (var item in ApprovalTravelArr)
- {
- if (index > 0)
- {
- titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
- tableOne.AppendChild(titleRowClone);
- }
- var textTime = item.Date;
- var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
- SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
- SetIndex++;
- if (ChiRep.Count > 0)
- {
- foreach (var itemChi in ChiRep)
- {
- var txtTime = itemChi.Time;
- var txtDetail = itemChi.Details;
- if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
- {
- //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
- //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
- //indexChi++;
- //SetIndex++;
- break;
- }
- if (indexChi > 0)
- {
- CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
- tableOne.AppendChild(CenterRowClone);
- }
- SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
- SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
- indexChi++;
- SetIndex++;
- }
- }
- //else
- //{
- // if (indexChi > 0)
- // {
- // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
- // tableOne.AppendChild(CenterRowClone);
- // }
- // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
- // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
- // indexChi++;
- // SetIndex++;
- //}
- index++;
- }
- string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
- doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
- jw.Code = 200;
- jw.Msg = "";
- return Ok(jw);
- }
- private string ParseBlackTime(string time)
- {
- // 匹配可能只有分钟的情况
- string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
- System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
- if (match.Success)
- {
- string hours = match.Groups[1].Value;
- string minutes = match.Groups[2].Value;
- // 如果小时部分为空,则只显示分钟
- if (string.IsNullOrEmpty(hours))
- {
- return $"{minutes}分钟";
- }
- // 如果分钟部分为空,则只显示小时
- else if (string.IsNullOrEmpty(minutes))
- {
- return $"{hours}小时";
- }
- // 否则显示完整格式
- else
- {
- return $"{hours}小时{minutes}分钟";
- }
- }
- else
- {
- return "未知时长";
- }
- }
- private string intToString(int numberVal)
- {
- string numberval = numberVal.ToString();
- Dictionary<char, string> Number = new Dictionary<char, string>();
- Number.Add('1', "一");
- Number.Add('2', "二");
- Number.Add('3', "三");
- Number.Add('4', "四");
- Number.Add('5', "五");
- Number.Add('6', "六");
- Number.Add('7', "七");
- Number.Add('8', "八");
- Number.Add('9', "九");
- string stringNumberVal = string.Empty;
- for (int i = 0; i < numberval.Length; i++)
- {
- if (i == 0)
- {
- stringNumberVal += Number[numberval[i]];
- }
- else if (i >= 1)
- {
- if (numberval[i] == '0')
- {
- stringNumberVal = "十";
- }
- else
- {
- stringNumberVal += "十" + Number[numberval[i]];
- }
- }
- }
- return stringNumberVal;
- }
- private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
- {
- //获取table中的某个单元格,从0开始
- Cell lshCell = table.Rows[rows].Cells[cells];
- //将单元格中段落移除
- foreach (Paragraph item in lshCell.Paragraphs)
- {
- lshCell.Paragraphs.Remove(item);
- }
- if (val.Contains("\r\n"))
- {
- var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
- foreach (var item in spArr)
- {
- //新建一个段落
- Paragraph p = new Paragraph(doc);
- var r = new Run(doc, item);
- //设置字体
- if (!string.IsNullOrEmpty(font))
- {
- r.Font.Name = font;
- }
- r.Font.Bold = bold;
- //把设置的值赋给之前新建的段落
- p.AppendChild(r);
- //将此段落加到单元格内
- lshCell.AppendChild(p);
- }
- }
- else
- {
- //新建一个段落
- Paragraph p = new Paragraph(doc);
- var r = new Run(doc, val);
- //设置字体
- if (!string.IsNullOrEmpty(font))
- {
- r.Font.Name = font;
- }
- r.Font.Bold = bold;
- //把设置的值赋给之前新建的段落
- p.AppendChild(r);
- //将此段落加到单元格内
- lshCell.AppendChild(p);
- }
- }
- //[HttpPost]
- //public async Task<IActionResult> ServerHttp(string paramStr)
- //{
- // paramStr = paramStr.TrimEnd('\'');
- // paramStr = paramStr.TrimStart('\'');
- // JsonView jw = JsonView(false);
- // JObject param = JObject.Parse(paramStr);
- // if (!param.ContainsKey("url"))
- // {
- // jw.Msg = "url null";
- // return Ok(jw);
- // }
- // string url = param["url"]!.ToString();
- // var methon = "get";
- // Dictionary<string, string> headValues = null;
- // string bodyStr = string.Empty;
- // if (param.ContainsKey("methon"))
- // {
- // methon = param["methon"]!.ToString().ToLower();
- // }
- // if (param.ContainsKey("header"))
- // {
- // var header = param["header"]!.ToString();
- // JObject headerJobject = JObject.Parse(header);
- // headValues = new Dictionary<string, string>();
- // foreach (JProperty item in headerJobject.Properties())
- // {
- // var value = item.Value.ToString();
- // var head = item.Path;
- // headValues.Add(head, value);
- // }
- // }
- // HttpClient client = new HttpClient();
- // string responseString = string.Empty;
- // StringContent content = null;
- // if (headValues != null)
- // {
- // foreach (var item in headValues.Keys)
- // {
- // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
- // {
- // if (param.ContainsKey("body"))
- // {
- // bodyStr = param["body"]!.ToString();
- // }
- // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
- // }
- // else
- // {
- // client.DefaultRequestHeaders.Add(item, headValues[item]);
- // }
- // }
- // }
- // try
- // {
- // if (methon == "get")
- // {
- // responseString = await client.GetStringAsync(url);
- // }
- // else if (methon == "post")
- // {
- // var request = new HttpRequestMessage(HttpMethod.Post, url)
- // {
- // Content = content
- // };
- // var response = await client.SendAsync(request);
- // try
- // {
- // Stream responseStream = await response.Content.ReadAsStreamAsync();
- // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
- // {
- // using (StreamReader reader = new StreamReader(gzipStream))
- // {
- // responseString = await reader.ReadToEndAsync();
- // }
- // }
- // }
- // catch (Exception)
- // {
- // responseString = await response.Content.ReadAsStringAsync();
- // }
- // }
- // else
- // {
- // responseString = "methon error";
- // }
- // jw = JsonView(true, "success", responseString);
- // }
- // catch (Exception ex)
- // {
- // jw.Msg = "error " + ex.Message;
- // jw.Data = ex.StackTrace;
- // }
- // finally
- // {
- // client.Dispose();
- // }
- // return Ok(jw);
- //}
- #endregion
- #region 团组接待意见调查
- /// <summary>
- /// 团组接待意见调查 - 信息管理
- /// 基础数据(团组)
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireInit()
- {
- var groupData = await _groupRepository.Query(x => x.IsDel == 0)
- .Select(x => new
- {
- x.Id,
- GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
- })
- .OrderByDescending(x => x.Id)
- .ToListAsync();
- return Ok(JsonView(groupData, groupData.Count));
- }
- /// <summary>
- /// 团组接待意见调查 - 信息管理
- /// 列表
- /// </summary>
- /// <param name="groupId"></param>
- /// <returns></returns>
- [HttpGet("{groupId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireManageList(int groupId)
- {
- if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
- var data = await _opinionaireRep.Query(x => x.DiId == groupId)
- .Select(x => new
- {
- x.Id,
- x.TourGuideName,
- x.CityName,
- CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
- x.CreateTime
- })
- .OrderBy(x => x.Id)
- .ToListAsync();
- return Ok(JsonView(data));
- }
- /// <summary>
- /// 团组接待意见调查 - 信息管理
- /// 保存
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
- {
- var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
- if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
- var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
- var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
- _opinionaireRep.BeginTran();
- if (addData != null && addData.Count > 0)
- {
- foreach (var item in addData)
- {
- item.CreateUserId = currUserInfo.UserId;
- item.DiId = dto.DiId;
- }
- var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
- }
- if (updData != null && updData.Count > 0)
- {
- var upd = await _opinionaireRep._sqlSugar
- .Updateable(updData)
- .UpdateColumns(x => new { x.CityName, x.TourGuideName })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- }
- _opinionaireRep.CommitTran();
- return Ok(JsonView("操作成功!"));
- }
- /// <summary>
- /// 团组接待意见调查 - 信息管理
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("{id}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireManageDel(int id)
- {
- var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
- if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
- if (id < 1) Ok(JsonView(false, "请传入有效的id"));
- var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
- if (!del) return Ok(JsonView("操作失败!"));
- return Ok(JsonView("操作成功!"));
- }
- /// <summary>
- /// 团组接待意见调查 - 用户
- /// 列表
- /// </summary>
- /// <param name="diId"></param>
- /// <returns></returns>
- [HttpGet("{diId}")]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireUserList(int diId)
- {
- if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
- var sql = string.Format(@"
- SELECT
- o.Id,
- o.DiId,
- di.TeamName AS 'GroupName',
- di.VisitPNumber AS 'PeopleNumber',
- di.ClientName AS 'LeadGroup',
- di.VisitCountry AS 'Travel',
- di.VisitDays AS 'Days',
- o.CityName,
- o.TourGuideName,
- o.Catering,
- o.CateringReason,
- o.Stay,
- o.StayReason,
- o.[Route],
- o.RouteReason,
- o.OfficialActivity,
- o.OfficialActivityReason,
- o.TourGuide,
- o.TourGuideReason,
- o.[Translate],
- o.TranslateReason,
- o.Trip,
- o.TripReason,
- o.ESFileName,
- o.SignatureDate,
- o.Remark
- FROM
- Grp_Opinionaire o
- LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
- WHERE
- o.IsDel = 0
- AND o.DiId = {0}
- ORDER BY
- o.Id ASC", diId);
- var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
- if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
- return Ok(JsonView(data));
- }
- /// <summary>
- /// 团组接待意见调查 - 用户
- /// 保存
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
- {
- if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
- foreach (var item in dto)
- {
- if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
- if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
- if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
- if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
- if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
- if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
- if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
- if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
- }
- var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
- if (!Directory.Exists(filePathBase))
- {
- Directory.CreateDirectory(filePathBase);
- }
- #region 上传文件
- var filePaths = new List<string>();
- foreach (var item in dto)
- {
- var file = item.File;
- // 将文件保存到指定位置
- var filePath = Path.Combine(filePathBase, file.FileName);
- using (var stream = new FileStream(filePath, FileMode.Create))
- {
- await file.CopyToAsync(stream);
- }
- //验证文件是否上传成功
- if (!System.IO.File.Exists(filePath))
- {
- foreach (var filePathStr in filePaths)
- {
- System.IO.File.Delete(filePathStr);
- }
- return Ok(JsonView(false, "文件上传失败!"));
- }
- item.ESFileName = file.FileName;
- }
- #endregion
- var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
- var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
- .UpdateColumns(x => new
- {
- x.Catering,
- x.CateringReason,
- x.Stay,
- x.StayReason,
- x.Route,
- x.RouteReason,
- x.OfficialActivity,
- x.OfficialActivityReason,
- x.TourGuide,
- x.TourGuideReason,
- x.Translate,
- x.TranslateReason,
- x.Trip,
- x.TripReason,
- x.ESFileName,
- x.SignatureDate,
- x.Remark
- })
- .WhereColumns(x => new { x.Id })
- .ExecuteCommandAsync();
- if (upd < 1)
- {
- foreach (var filePathStr in filePaths)
- {
- System.IO.File.Delete(filePathStr);
- }
- return Ok(JsonView(false));
- }
- return Ok(JsonView(true));
- }
- #endregion
- #region 团组餐厅相关信息
- /// <summary>
- /// 团组相关餐厅信息
- /// 基础数据(团组)
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantInit()
- {
- return Ok(await _restaurantRep.InitAsync());
- }
- /// <summary>
- /// 团组相关餐厅信息
- /// Item
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
- {
- int portType = dto.PortType,
- groupId = dto.GroupId;
- if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
- if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
- return Ok(await _restaurantRep.ItemAsync(portType, groupId));
- }
- /// <summary>
- /// 团组相关餐厅信息
- /// List
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
- {
- int portType = dto.PortType,
- groupId = dto.GroupId;
- if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
- if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
- var sql = string.Format(@" SELECT
- ri.Id,
- ri.GroupId,
- ri.Date,
- ri.StartTime,
- ri.EndTime,
- CASE WHEN ri.Type = 1 THEN '早餐'
- WHEN ri.Type = 2 THEN '午餐'
- WHEN ri.Type = 3 THEN '晚餐'
- ELSE '其他'
- END AS 'Type',
- ri.Name,
- ri.Address,
- ri.Tel,
- ri.Remark,
- ri.CreateTime,
- u.CnName AS CreateUserName
- FROM
- Grp_RestaurantInfo ri
- LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
- WHERE
- ri.IsDel = 0
- AND ri.GroupId = {0}
- ORDER BY
- ri.Date ASC
- ", groupId);
- var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
- if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
- return Ok(JsonView(infos));
- }
- /// <summary>
- /// 团组相关餐厅信息
- /// Info
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
- {
- int portType = dto.PortType,
- id = dto.Id;
- if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
- if (id < 1) return Ok(JsonView(false, MsgTips.Id));
- return Ok(await _restaurantRep.InfoAsync(portType, id));
- }
- /// <summary>
- /// 团组相关餐厅信息
- /// Op
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
- {
- if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
- if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
- return Ok(await _restaurantRep.OpAsync(dto));
- }
- /// <summary>
- /// 团组相关餐厅信息
- /// Del
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
- {
- int userId = dto.DeleteUserId;
- var id = dto.Id;
- if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
- if (id < 1) return Ok(JsonView(false, MsgTips.Id));
- return Ok(await _restaurantRep.DelAsync(dto));
- }
- #endregion
- // /// <summary>
- // ///
- // /// </summary>
- // /// <param name="_dto"></param>
- // /// <returns></returns>
- // [HttpPost]
- // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
- // {
- // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
- // string sql = string.Format(@" Select * From Visa With(Nolock) ");
- // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
- // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
- // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
- // dic_psg.Add("客人", 974);
- // dic_psg.Add("司机", 975);
- // dic_psg.Add("导游", 976);
- // dic_psg.Add("公司内部人员", 977);
- // dic_psg.Add("司机/导游/公司内部人员", 978);
- // foreach (var item in list_visa)
- // {
- // Grp_VisaInfo temp = new Grp_VisaInfo();
- // temp.Id = item.Id;
- // temp.DIId = item.DIId;
- // temp.VisaClient = item.VisaClient;
- // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
- // temp.VisaCurrency = item.VisaCurrency;
- // temp.IsThird = item.IsThird;
- // if (dic_psg.ContainsKey(item.PassengerType))
- // {
- // temp.PassengerType = dic_psg[item.PassengerType];
- // }
- // else {
- // temp.PassengerType = -1;
- // }
- // temp.VisaNumber = item.VisaNumber;
- // temp.VisaFreeNumber = item.VisaFreeNumber;
- // temp.CreateUserId = item.Operators;
- // DateTime dt_ct;
- // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
- // if (b_ct)
- // {
- // temp.CreateTime = dt_ct;
- // }
- // else
- // {
- // temp.CreateTime = DateTime.Now;
- // }
- // temp.DeleteTime = "";
- // temp.DeleteUserId = 0;
- // temp.Remark = item.Remark;
- // if (string.IsNullOrEmpty(temp.Remark)) {
- // temp.Remark = "";
- // }
- // temp.IsDel = item.IsDel;
- // temp.VisaDescription = item.VisaAttachment;
- // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
- //([Id]
- // ,[DIId]
- // ,[VisaClient]
- // ,[VisaPrice]
- // ,[VisaCurrency]
- // ,[IsThird]
- // ,[PassengerType]
- // ,[VisaNumber]
- // ,[VisaFreeNumber]
- // ,[CreateUserId]
- // ,[CreateTime]
- // ,[DeleteTime]
- // ,[DeleteUserId]
- // ,[Remark]
- // ,[IsDel]
- // ,[visaDescription])
- // VALUES
- // ({0},{1},'{2}',{3},{4}
- //,{5},{6},{7},{8},{9}
- //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
- //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
- //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
- //);
- // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
- // }
- // return Ok(JsonView(true, "操作成功!"));
- // }
- /// <summary>
- /// 123132123
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
- {
- _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
- string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
- List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
- _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
- Dictionary<int, int> dicDetail = new Dictionary<int, int>();
- dicDetail.Add(789, 1034);
- dicDetail.Add(790, 1035);
- dicDetail.Add(791, 1036);
- dicDetail.Add(792, 1037);
- dicDetail.Add(793, 1038);
- dicDetail.Add(794, 1039);
- dicDetail.Add(795, 1040);
- dicDetail.Add(796, 1041);
- dicDetail.Add(797, 1042);
- dicDetail.Add(798, 1043);
- dicDetail.Add(801, 1044);
- dicDetail.Add(802, 1045);
- dicDetail.Add(803, 1046);
- Dictionary<int, int> dic = new Dictionary<int, int>();
- dic.Add(806, 1027);
- dic.Add(807, 1028);
- dic.Add(808, 1029);
- dic.Add(809, 1030);
- dic.Add(810, 1031);
- dic.Add(811, 1032);
- dic.Add(812, 1033);
- foreach (var item in list_visa)
- {
- Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
- temp.Coefficient = item.coefficient;
- DateTime dtCrt;
- bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
- if (b1)
- {
- temp.CreateTime = dtCrt;
- }
- else
- {
- temp.CreateTime = DateTime.Now;
- }
- temp.CreateUserId = item.Operators;
- temp.DeleteTime = "";
- temp.DeleteUserId = 0;
- temp.DiId = int.Parse(item.DIID);
- temp.FilePath = item.FilePath;
- temp.IsDel = item.IsDel;
- temp.Price = item.Price;
- temp.PriceCount = 1;
- temp.PriceCurrency = item.Currency;
- int detailId = 0;
- if (dicDetail.ContainsKey(item.PriceTypeDetail))
- {
- detailId = dicDetail[item.PriceTypeDetail];
- }
- temp.PriceDetailType = detailId;
- temp.PriceDt = DateTime.Now;
- temp.PriceName = item.PriceName;
- temp.PriceSum = item.Price;
- int tid = 0;
- if (dic.ContainsKey(item.PriceType))
- {
- tid = dic[item.PriceType];
- }
- temp.PriceType = tid;
- temp.Remark = item.Remark;
- await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
- }
- return Ok(JsonView(true, "操作成功!"));
- }
- [HttpPost]
- public IActionResult TimeTest()
- {
- var jw = JsonView(false, "error");
- _sqlSugar.BeginTran();
- try
- {
- var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
- .Select(x => new Crm_NewClientData
- {
- Id = x.Id,
- Client = x.Client,
- Contact = x.Contact,
- Location = x.Location,
- })
- .ToList();
- var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
- _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
- Stopwatch stopwatch = new Stopwatch();
- // 开始计时
- stopwatch.Start();
- foreach (var item in clientList)
- {
- EncryptionProcessor.DecryptProperties(item);
- }
- stopwatch.Stop();
- jw.Code = 200;
- jw.Data = stopwatch.ElapsedMilliseconds;
- jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
- }
- catch (Exception ex)
- {
- jw.Code = 400;
- jw.Msg = ex.Message;
- }
- return Ok(jw);
- }
- }
- }
|