1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397 |
- using Aspose.Cells;
- using Aspose.Words;
- using Aspose.Words.Drawing;
- using Aspose.Words.Tables;
- using EyeSoft.Collections.Generic;
- using EyeSoft.IO;
- using Microsoft.AspNetCore.SignalR;
- using MySqlX.XDevAPI.Relational;
- using NPOI.HSSF.UserModel;
- using NPOI.SS.Format;
- using NPOI.SS.UserModel;
- using NPOI.SS.Util;
- using NPOI.XSSF.UserModel;
- using OASystem.API.OAMethodLib;
- 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.QiYeWeChatAPI.AppNotice;
- 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;
- using OASystem.Domain.ViewModels.Groups;
- using OASystem.Domain.ViewModels.Statistics;
- using OASystem.Infrastructure.Repositories.Financial;
- using OASystem.Infrastructure.Repositories.Groups;
- using OfficeOpenXml;
- using Org.BouncyCastle.Asn1.Ocsp;
- using Quartz.Util;
- using SqlSugar;
- using SqlSugar.Extensions;
- using System.Collections;
- using System.Data;
- using System.Data.OleDb;
- using System.Diagnostics;
- using System.Globalization;
- using System.IO;
- using System.IO.Compression;
- using System.Net.Http;
- using System.Reflection.PortableExecutable;
- using System.Security.Cryptography;
- using Ubiety.Dns.Core;
- using static NPOI.POIFS.Crypt.CryptoFunctions;
- using static OASystem.API.OAMethodLib.JWTHelper;
- using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
- using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
- 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; //对外收款账单仓库
- 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
- )
- {
- _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;
- }
- #region 流程管控
- /// <summary>
- /// 获取团组流程管控信息
- /// </summary>
- /// <param name="paras">参数Json字符串</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="paras"></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>
- /// 接团信息列表
- /// </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
- /// </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);
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
- JietuanOperator,IsSure,CreateTime,IsBid
- From (
- Select row_number() over(order by gdi.CreateTime 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,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", 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));
- }
- 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> GroupOperation(GroupOperationDto dto)
- {
- try
- {
- 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;
- //添加时 默认加入团组汇率
- 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
- if (diId > 0)
- {
- await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
- }
- #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
- return Ok(JsonView(true, "操作成功!", diId));
- }
- catch (Exception ex)
- {
- Logs("[response]" + JsonConvert.SerializeObject(dto));
- Logs(ex.Message);
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 接团流程操作(增改)
- /// 安卓端使用 建团时添加客户名单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
- {
- try
- {
- #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)
- {
- 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)
- {
- 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)
- {
- try
- {
- var groupData = await _groupRepository.GroupDel(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true));
- }
- catch (Exception ex)
- {
- Logs("[response]" + JsonConvert.SerializeObject(dto));
- Logs(ex.Message);
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <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;
- List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
- List<int> userIds = new List<int>();
- listUser.ForEach(s => userIds.Add(s.Id));
- 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,
- CreateTime,
- IsBid
- FROM
- (
- SELECT
- ROW_NUMBER() OVER(
- ORDER BY
- gdi.CreateTime 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,
- 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
- AND gdi.IsBid = 0
- AND gdi.CreateTime 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();
- foreach (var item in groupList)
- {
- item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
- }
- #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));
- }
- #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>
- /// <param name="dto"></param>
- /// <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="paras">参数Json字符串</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为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
- List<SimplClientInfo> 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);
- List<Grp_CreditCardPayment> entityList = _groupRepository
- .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
- .Where(exp.ToExpression())
- .ToList();
- List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
- List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
- /*
- * 76://酒店预订
- */
- List<Grp_HotelReservations> _HotelReservations = await _groupRepository
- .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
- .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 79://车/导游地接
- */
- List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
- .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
- .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 80: //签证
- */
- List<Grp_VisaInfo> _VisaInfos = await _groupRepository
- .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- *81: //邀请/公务活动
- */
- List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
- .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 82: //团组客户保险
- */
- List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * Lable = 85 机票预订
- */
- List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
- .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 85 机票预定
- */
- List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 98 其他款项
- */
- List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
- .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 285:收款退还
- */
- List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
- .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 1015: //超支费用
- */
- List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 币种信息
- */
- var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
- /*
- * 车/导游地接 费用类型
- */
- var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
- /*
- * 车/导游地接 费用类型
- */
- var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
- var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
- var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
- /*
- * 用户信息
- */
- var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
- /*
- * 费用模块
- */
- Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(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)
- {
- Grp_CreditCardPaymentDetailView _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;
- }
- }
- /*
- * 应付款金额
- */
- Sys_SetData 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";
- }
- /*
- * 剩余尾款
- */
- 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/>";
- if (hotelReservations.SingleRoomPrice > 0)
- {
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
- __isSingle = true;
- }
- if (hotelReservations.DoubleRoomPrice > 0)
- {
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
- __isDouble = true;
- }
- if (hotelReservations.SuiteRoomPrice > 0)
- {
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
- __isSuite = true;
- }
- if (hotelReservations.OtherRoomPrice > 0)
- {
- roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
- __isOther = true;
- }
- if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
- 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} 是否由地接代付:{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 = " - ";
- Sys_Users _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
- {
- Sys_Users _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;
- if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
- /*
- * 费用总计
- */
- ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
- {
- CurrencyId = entity.PaymentCurrency,
- CurrencyName = PaymentCurrency_WaitPay,
- AmountPayable = entity.PayMoney,
- ThisPayment = OriginalCurrPay,
- BalancePayment = BalanceStr,
- AuditedFunds = auditFee
- });
- _detail.IsAuditGM = entity.IsAuditGM;
- detailList.Add(_detail);
- }
- #endregion
- _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
- /*
- * 下方描述处理
- */
- List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
- CreditCardPaymentCurrencyPriceItem 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(@"已审费用总额: ");
- foreach (var item in nonDuplicat)
- {
- 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"), item.CurrencyName);
- //单独处理此次付款金额
- if (item.CurrencyId == 836) //人民币
- {
- thisPaymentStr += string.Format(@"{0}{1} | ", thisPayment.ToString("#0.00"), item.CurrencyName);
- }
- else
- {
- thisPaymentStr += string.Format(@"{0}{1} | ", thisPayment.ToString("#0.00"), item.CurrencyName);
- }
- balancePaymentStr += string.Format(@"{0}{1} | ", balancePayment.ToString("#0.00"), item.CurrencyName);
- //单独处理已审核费用
- if (item.CurrencyId == 836) //人民币
- {
- decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
- auditedFundsStr += string.Format(@"{0}{1} |", auditedFunds.ToString("#0.00"), item.CurrencyName);
- }
- else
- {
- auditedFundsStr += string.Format(@"{0}{1} |", "0.00", item.CurrencyName);
- }
- }
- }
- _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
- _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
- _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
- _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.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)
- {
- try
- {
- 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);
- }
- catch (Exception ex)
- {
- }
- #endregion
- 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> 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();
- 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 = _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 ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
- int sign = (int)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);
- #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="file"></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="dto"></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>
- /// <param name="dto"></param>
- /// <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);
- }
- 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));
- }
- }
- /// <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>
- /// <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.Id, 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 = _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>
- //[HttpPost]
- //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
- //{
- // try
- // {
- // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
- // if (data.Code != 0)
- // {
- // return Ok(JsonView(false, data.Msg));
- // }
- // return Ok(JsonView(true, "查询成功!"));
- // }
- // catch (Exception ex)
- // {
- // return Ok(JsonView(false, ex.Message));
- // throw;
- // }
- //}
- /// <summary>
- /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> SetDayAndCostAreaChange()
- {
- try
- {
- var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
- var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
- var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
- var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
- foreach (var item in unite) //处理交集数据
- {
- dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
- }
- foreach (var item in merge) //处理差集数据
- {
- int nationalTravelFeeId = 0;
- var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
- if (cityData != null) nationalTravelFeeId = cityData.Id;
- else
- {
- var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
- if (countryData != null) nationalTravelFeeId = countryData.Id;
- }
- dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
- }
- //只更新dayAndCost 的 nationalTravelFeeId;
- var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
- if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
- else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
- {
- try
- {
- var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
- string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
- //SetDataInfoView
- var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
- var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
- List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
- var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
- List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
- var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
- List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
- //默认币种显示
- List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
- {
- new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
- new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
- new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
- new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
- new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
- };
- var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
- if (_currencyRate.Count > 0)
- {
- foreach (var item in _currencyInfos)
- {
- var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
- if (rateInfo != null)
- {
- decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
- rate1 *= 1.035M;
- item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
- }
- }
- }
- return Ok(JsonView(true, "查询成功!", new
- {
- GroupNameData = groupNameData.Data,
- CurrencyData = _CurrencyData,
- WordTypeData = _WordTypeData,
- ExcelTypeData = _ExcelTypeData,
- CurrencyInit = _currencyInfos
- }));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用
- /// 实时汇率 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);
- //默认币种显示
- List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
- {
- new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
- new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
- new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
- new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
- new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
- };
- var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
- List<dynamic> reteInfos = new List<dynamic>();
- if (_currencyRate.Count > 0)
- {
- foreach (var item in _currencyInfos)
- {
- var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
- if (rateInfo != null)
- {
- item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
- decimal rate1 = item.Rate;
- rate1 *= 1.03M;
- decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
- reteInfos.Add(new
- {
- currCode = item.CurrencyCode,
- currName = item.CurrencyName,
- rate = rate2,
- lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
- });
- }
- }
- }
- var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
- var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
- return Ok(JsonView(true, "查询成功!", new
- {
- //GroupNameData = groupNameData.Data,
- visaData = visaData.Data,
- airData = airData.Data,
- reteInfos = reteInfos
- }));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - Info
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(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>
- /// 团组模块 - 出入境费用 - Add And Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
- 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 downlaod
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [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).First();
- var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
- if (_EnterExitCosts == null)
- {
- return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
- }
- //数据源
- List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
- List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
- List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
- List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).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
- {
- Name = dc.LastName + dc.FirstName,
- Sex = dc.Sex,
- Birthday = dc.BirthDay,
- Company = cc.CompanyFullName,
- Job = dc.Job
- })
- .ToList();
- 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 = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
- decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
- decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
- decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
- decimal insidePayTotal = _EnterExitCosts.InsidePay;
- //境内费用(其他费用)
- 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}";
- 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")} 元/人(头等舱)";
- }
- dic.Add("AirTotalStr", airTotalStr);
- dic.Add("AirPriceStr", airPriceStr);
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- 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;
- //住宿费
- 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);
- }
- decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
- decimal subJJC = 0.00M,
- subGWC = 0.00M,
- subTDC = 0.00M;
- //经济舱
- if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
- //公务舱
- if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
- //头等舱
- if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
- 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)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- #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")} 元,";
- 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")}元,";
- 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;
- 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", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).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;
- 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, 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.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
- if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
- 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.Count < 1)
- {
- return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
- }
- //获取模板
- 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]
- [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);
- if (_view.Code == 0)
- {
- return Ok(JsonView(true, "操作成功"));
- }
- return Ok(JsonView(false, "操作失败"));
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 子项删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [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>
- /// 团组模块 - 出入境国家费用标准 List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
- {
- try
- {
- Stopwatch sw = new Stopwatch();
- sw.Start();
- string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* 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");
- var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
- //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
- //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
- //foreach (var item in nationalTravel)
- //{
- // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
- // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
- // if (otherData != null)
- // {
- // cityData.Remove(otherData);
- // cityData.Add(otherData);
- // }
- // nationalTravelFeeData1.Add(new
- // {
- // Country = item.Country,
- // CityData = cityData
- // });
- //}
- sw.Stop();
- return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <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)
- {
- List<string> cityData1 = new List<string>();
- cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
- var countryData2 = new
- {
- CountryName = item,
- CityData = cityData1
- };
- 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;
- if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
- if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
- if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
- string whereSql = string.Empty;
- if (!string.IsNullOrEmpty(dto.Country))
- {
- whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
- }
- if (!string.IsNullOrEmpty(dto.City))
- {
- whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
- }
- string pageSql = string.Format(@"Select * From (
- Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
- ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
- 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} ) temp ", whereSql);
- RefAsync<int> total = 0;
- var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).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.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)
- {
- try
- {
- var data = await _enterExitCostRep.PostNationalTravelFeeOperate(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>
- /// 团组模块 - 出入境国家费用标准 - Del
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
- {
- try
- {
- 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, "操作成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <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.Count > 0)
- {
- var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
- if (add > 0)
- {
- return Ok(JsonView(true, "操作成功!"));
- }
- }
- return Ok(JsonView(false, "未操作!"));
- }
- #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).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);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- #endregion
- #region 签证提成录入
- /// <summary>
- /// 签证提成录入
- /// 基础数据
- /// </summary>
- /// <param name="_dto"></param>
- /// <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).ToString("#0.00")} CNY;";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- 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 = 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 = 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 = 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 = 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.Id).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
- {
- _sqlSugar.BeginTran();
- foreach (var item in dto.Arr)
- {
- if (item.Id == 0)
- {
- throw new Exception("请传入正确的Id");
- }
- _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);
- }
- /// <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();
- }
- //创建数据源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)
- {
- 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
- }
- 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;
- }
- #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.Id 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); //团组列表信息
- var create = _GroupCostRepository.
- CreateGroupCostByBlackCode(dto.Diid);
- if (groupCost.Count == 0 && create.Code == 0)
- {
- groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
- }
- 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 == dto.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 = 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 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
- {
- 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);
- var Create = _GroupCostRepository.
- CreateGroupCostByBlackCode(dto.Diid);
- jw.Msg = Create.Msg;
- if (Create.Code == 0)
- {
- jw.Code = 200;
- jw.Data = new
- {
- groupCost = Create.Data,
- blackCodeIsTrue = true
- };
- }
- else
- {
- jw.Code = 400;
- jw.Data = new
- {
- groupCost = Create.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);
- }
- #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 应用推送
- 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);
- //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.iOS_PushNotifications("051", title, "", content);
- }
- catch (Exception ex)
- {
- _logger.LogInformation($"【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);
- 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);
- //await GeneralMethod.iOS_PushNotifications("051", "费用审核", "", content);
- }
- catch (Exception ex)
- {
- }
- #endregion
- return Ok(_view);
- }
- /// <summary>
- /// 酒店自动审核测试
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></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
- return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
- }
- /// <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>().Where(it => it.IsDel == 0).ToListAsync();
- 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);
- 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.CreateTime 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);
- 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 = "";
- 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);
- }
- 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>
- /// <param name="dto"></param>
- /// <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>
- /// 接团客户名单
- /// 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++)
- {
- 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];
- 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}|";
- }
- //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);
- }
- }
- //删除多余行
- 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; }
- }
- #endregion
- #region 团组倒推表
- /// <summary>
- /// 倒推表基础数据
- /// Init
- /// </summary>
- /// <param name="dto"></param>
- /// <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;
- //载入模板
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
- 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
- var fileDir = AppSettingsHelper.Get("WordBasePath");
- string fileName = $"{teamName}团出行准备流程表.doc";
- string filePath = fileDir + $@"InvertedList/{fileName}";
- doc.Save(filePath);
- string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
- return Ok(JsonView(true, "操作成功!", Url));
- }
- #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>
- /// <param name="dto"></param>
- /// <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.CreateUserId)
- .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.Id).ToList();
- var group = groupList.First();
- var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
- group = groupList.First(x => x.Id == diid);
- 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")
- },
- };
- var resultArr = new ArrayList();
- var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
- if (content.Count == 0)
- {
- var stay = "-";
- var cityPath = "-";
- //添加城市路径以及住宿地
- //黑屏代码数据
- DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
- if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
- {
- jw = JsonView(true, "黑屏代码有误!", data);
- return Ok(jw);
- }
- 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();
- }
- 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 = x1.Time == null ? 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);
- }
- //黑屏代码数据
- DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
- 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 timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
- var empty = "【未收入该三字码!请机票同事录入】";
- string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
- 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 (tbSelect.Length > 0)
- {
- List<string> threeCodeStr = new List<string>();
- bool isTrade = false;
- string trip = string.Empty;
- var rowLast = tbSelect.Last();
- var rowFirst = tbSelect.First();
- var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
- var airEndTime = rowLast["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)));
- foreach (var item in tbSelect)
- {
- 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();
- if (flightTime!.Contains(":"))
- {
- flightTime = flightTime.Replace(":", "小时");
- flightTime += "分钟";
- }
- if (flightTime.Contains("H"))
- {
- flightTime = flightTime.Replace("H", "小时");
- }
- if (flightTime.Contains("M"))
- {
- flightTime = flightTime.Replace("M", "分钟");
- }
- IFormatProvider ifp = new CultureInfo("zh-CN", true);
- if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
- {
- flightTime = flightDataTime.Hour > 0
- ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
- ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
- ? flightDataTime.Minute.ToString() + "分钟" : "";
- }
- //航班号
- 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,
- };
- }
- //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
- trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
- isTrade = Convert.ToBoolean(item["isTransitShipment"]);
- if (isTrade)
- {
- trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
- }
- 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
- });
- 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('-');
- }
- string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
- Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
- appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
- appro.Diid = dto.Diid;
- var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
- appro.Id = thisId;
- appro.CreateUserId = dto.Userid;
- appro.CreateTime = DateTime.Now;
- 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 < 5)
- {
- for (int j = chiarr.Count; j < 5; j++)
- {
- chiarr.Add(new
- Grp_ApprovalTravelDetails());
- }
- }
- resultArr.Add(new
- {
- appro.Id,
- appro.Date,
- appro.Diid,
- chiList = chiarr.Select(x1 => new
- {
- timeInterval = x1.Time == null ? 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/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
- //载入模板
- 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);
- SetIndex++;
- if (ChiRep.Count > 0)
- {
- foreach (var itemChi in ChiRep)
- {
- var txtTime = itemChi.Time;
- var txtDetail = itemChi.Details;
- if (indexChi > 0)
- {
- CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
- tableOne.AppendChild(CenterRowClone);
- }
- if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
- {
- SetCells(tableOne, doc, SetIndex, 0, "");
- SetCells(tableOne, doc, SetIndex, 1, "");
- indexChi++;
- SetIndex++;
- break;
- }
- SetCells(tableOne, doc, SetIndex, 0, txtTime);
- SetCells(tableOne, doc, SetIndex, 1, txtDetail);
- indexChi++;
- SetIndex++;
- }
- }
- else
- {
- if (indexChi > 0)
- {
- CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
- tableOne.AppendChild(CenterRowClone);
- }
- SetCells(tableOne, doc, SetIndex, 0, "");
- SetCells(tableOne, doc, SetIndex, 1, "");
- indexChi++;
- SetIndex++;
- }
- index++;
- }
- string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"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 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)
- {
- //获取table中的某个单元格,从0开始
- Cell lshCell = table.Rows[rows].Cells[cells];
- //将单元格中段落移除
- foreach (Node 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);
- //把设置的值赋给之前新建的段落
- p.AppendChild(r);
- //将此段落加到单元格内
- lshCell.AppendChild(p);
- }
- }
- else
- {
- //新建一个段落
- Paragraph p = new Paragraph(doc);
- var r = new Run(doc, val);
- //把设置的值赋给之前新建的段落
- 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 团组接待意见调查 Grp_ReceptionOpinionSurvey
- /// <summary>
- /// 团组接待意见调查 - 信息管理
- /// 基础数据(团组)
- /// </summary>
- /// <param name="dto"></param>
- /// <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="id"></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="id"></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
- // /// <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, "操作成功!"));
- }
- }
- }
|