GeneralMethod.cs 292 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220
  1. 
  2. using Aspose.Cells;
  3. using Aspose.Words;
  4. using Aspose.Words.Layout;
  5. using Aspose.Words.Saving;
  6. using Microsoft.AspNetCore.SignalR;
  7. using Microsoft.International.Converters.PinYinConverter;
  8. using NodaTime;
  9. using OASystem.API.OAMethodLib.File;
  10. using OASystem.API.OAMethodLib.Hub.HubClients;
  11. using OASystem.API.OAMethodLib.Hub.Hubs;
  12. using OASystem.API.OAMethodLib.JuHeAPI;
  13. using OASystem.API.OAMethodLib.KiMiApi;
  14. using OASystem.API.OAMethodLib.SignalR.Hubs;
  15. using OASystem.Domain.AesEncryption;
  16. using OASystem.Domain.Dtos.Groups;
  17. using OASystem.Domain.Entities.Customer;
  18. using OASystem.Domain.Entities.Financial;
  19. using OASystem.Domain.Entities.Groups;
  20. using OASystem.Domain.ViewModels.Financial;
  21. using OASystem.Domain.ViewModels.Groups;
  22. using OASystem.Domain.ViewModels.JuHeExchangeRate;
  23. using OASystem.Infrastructure.Repositories.CRM;
  24. using OASystem.Infrastructure.Repositories.Groups;
  25. using System.Data;
  26. using System.IdentityModel.Tokens.Jwt;
  27. using System.Security.Claims;
  28. namespace OASystem.API.OAMethodLib
  29. {
  30. public static class GeneralMethod
  31. {
  32. //团组信息
  33. private static readonly SqlSugarClient _sqlSugar = AutofacIocManager.Instance.GetService<SqlSugarClient>();
  34. private static readonly DelegationInfoRepository _dirRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
  35. private static readonly TeamRateRepository _teamRateRep = AutofacIocManager.Instance.GetService<TeamRateRepository>();
  36. private static readonly IJuHeApiService _juHeApi = AutofacIocManager.Instance.GetService<IJuHeApiService>();
  37. private static readonly SetDataRepository _setDataRep = AutofacIocManager.Instance.GetService<SetDataRepository>();
  38. private static readonly TableOperationRecordRepository _tableOperationRecordRep = AutofacIocManager.Instance.GetService<TableOperationRecordRepository>();
  39. private static readonly MessageRepository _messageRep = AutofacIocManager.Instance.GetService<MessageRepository>();
  40. private static readonly IHubContext<ChatHub, IChatClient> _hubContext = AutofacIocManager.Instance.GetService<IHubContext<ChatHub, IChatClient>>();
  41. private readonly static string[] weekdays = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  42. #region 团组操作-->团组归属部门
  43. /// <summary>
  44. /// 团组操作-->团组归属部门
  45. /// </summary>
  46. /// <returns></returns>
  47. public static async Task<List<GroupOpAffiliationBranchView>> GroupOpAffiliationBranchInit()
  48. {
  49. /*
  50. * 1.sq 和 gyy 等显示 市场部
  51. * 2.王鸽和主管及张总还有管理员号统一国交部
  52. * 2-1. 4 管理员 ,21 张海麟
  53. */
  54. //List<int> userIds = new List<int>() { 4, 21 };
  55. var userDepDatas = new List<GroupOpAffiliationBranchView>();
  56. //userDepDatas = _sqlSugar.Queryable<Sys_Users>()
  57. // .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  58. // .Where(u => u.IsDel == 0)
  59. // .Select((u, d) => new GroupOpAffiliationBranchView { value = userIds.Contains(u.Id) ? "国交部" : d.DepName, text = userIds.Contains(u.Id) ? "国交部" : d.DepName })
  60. // .ToList();
  61. //userDepDatas.Insert(0, new GroupOpAffiliationBranchView() { text = "公司", value = "公司" });
  62. userDepDatas.Insert(0, new GroupOpAffiliationBranchView() { text = "全部", value = "全部" });
  63. userDepDatas.Insert(1, new GroupOpAffiliationBranchView() { text = "国交部", value = "国交部" });
  64. userDepDatas.Insert(2, new GroupOpAffiliationBranchView() { text = "市场部", value = "市场部" });
  65. userDepDatas.Insert(3, new GroupOpAffiliationBranchView() { text = "策划部", value = "策划部" });
  66. return userDepDatas;
  67. }
  68. public class GroupOpAffiliationBranchView
  69. {
  70. public string value { get; set; }
  71. public string text { get; set; }
  72. }
  73. #endregion
  74. #region 员工注册默认添加基础页面
  75. /// <summary>
  76. /// 默认职位权限
  77. /// </summary>
  78. public static bool DefaultPostAuth(int depId, int postId, int userId, int createUserId)
  79. {
  80. if (depId < 1) return false;
  81. if (postId < 1) return false;
  82. if (userId < 1) return false;
  83. if (createUserId < 1) return false;
  84. List<DefaultPostPageAuthView> _defaultData = AppSettingsHelper.Get<DefaultPostPageAuthView>("DefaultPostPageData");
  85. if (_defaultData.Count < 1) return false;
  86. var postJobDatas = _dirRep._sqlSugar.Queryable<Sys_JobPost>().Where(it => it.IsDel == 0).ToList();
  87. List<int> pageData = new List<int>();
  88. //添加公司公共页面
  89. pageData.AddRange(_defaultData.Find(it => it.DepId == -1)?.PostPageAuths[0].PageIds ?? new List<int>());
  90. //添加部门页面
  91. var depPublicPageData = _defaultData.Find(it => it.DepId == depId);
  92. var jobPublicPageData = postJobDatas.Find(it => it.DepId == depId && it.Id == postId);
  93. if (depPublicPageData != null) //特殊部门
  94. {
  95. //公共页面
  96. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == -1)?.PageIds ?? new List<int>());
  97. if (depId == 7) //国交部特殊处理
  98. {
  99. List<string> postNames = new List<string>() { "主管", "经理" };
  100. //岗位页面
  101. if (jobPublicPageData != null)
  102. {
  103. if (postNames.Contains(jobPublicPageData.JobName))
  104. {
  105. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == 0)?.PageIds ?? new List<int>());
  106. }
  107. else
  108. {
  109. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == postId)?.PageIds ?? new List<int>());
  110. }
  111. }
  112. }
  113. #region 按照岗位默认分配页面 特殊处理 市场部-销售顾问
  114. var salesDefaultPages = new List<int>() {
  115. 27 , //团组操作
  116. 104, //接团客户名单
  117. 106, //倒推表
  118. 118, //出入境费用明细
  119. 168, //出入境国家三公费用标准
  120. 194, //出入境费用明细-草稿
  121. 196, //前期需求表单收集
  122. };
  123. var jobName = jobPublicPageData.JobName;
  124. if (!string.IsNullOrEmpty(jobName))
  125. {
  126. if (jobPublicPageData.JobName.Equals("销售顾问"))
  127. {
  128. pageData.AddRange(salesDefaultPages);
  129. pageData = pageData.Distinct().OrderBy(x => x).ToList();
  130. }
  131. }
  132. #endregion
  133. }
  134. else //通用部门
  135. {
  136. pageData.AddRange(_defaultData.Find(it => it.DepId == 0)?.PostPageAuths[0].PageIds ?? new List<int>());
  137. }
  138. if (pageData.Count > 0)
  139. {
  140. //页面操作权限数据(添加修改等...)
  141. var pageFunctionData = _dirRep._sqlSugar.Queryable<Sys_SystemMenuAndFunction>().Where(it => pageData.Contains(it.SmId) && it.IsDel == 0).ToList();
  142. var defaultPageData = pageFunctionData.Select(it => new Sys_UserAuthority()
  143. {
  144. UId = userId,
  145. SmId = it.SmId,
  146. FId = it.FId,
  147. CreateUserId = createUserId, //管理员
  148. CreateTime = DateTime.Now,
  149. IsDel = 0,
  150. IsTemp = 1
  151. }).ToList();
  152. if (defaultPageData.Count > 0)
  153. {
  154. //移除每个页面的审核权限,审核权限需要单独开启
  155. defaultPageData = defaultPageData.Where(it => it.FId != 12).ToList();
  156. //添加页面操作权限
  157. var s = _dirRep._sqlSugar.Fastest<Sys_UserAuthority>().PageSize(100000).BulkCopy(defaultPageData);
  158. if (s > 0)
  159. {
  160. return true;
  161. }
  162. }
  163. }
  164. return false;
  165. }
  166. #endregion
  167. #region 消息
  168. /// <summary>
  169. /// 消息 发布And 通知
  170. /// </summary>
  171. /// <param name="msgTypeEnum">
  172. /// 消息类型
  173. /// 1 公告通知
  174. /// 2 团组流程管控通知
  175. /// 3 团组业务操作通知
  176. /// 4 团组费用审核消息
  177. /// 5 团组签证进度通知
  178. /// 6 团组任务进度通知
  179. /// 7 日付申请通知
  180. /// </param>
  181. /// <param name="title">消息标题</param>
  182. /// <param name="content">消息内容</param>
  183. /// <param name="userIds"></param>
  184. /// <param name="diId">团组id</param>
  185. /// <param name="param">团组id</param>
  186. /// <returns></returns>
  187. public static async Task<bool> MessageIssueAndNotification(MessageTypeEnum msgTypeEnum, string title, string content, List<int> userIds, int diId = 0, string param = "")
  188. {
  189. MessageDto messageDto = new()
  190. {
  191. Type = msgTypeEnum,
  192. IssuerId = 4,//管理员
  193. DiId = diId,
  194. Title = title,
  195. Content = content,
  196. ReleaseTime = DateTime.Now,
  197. UIdList = userIds,
  198. Param = param
  199. };
  200. var status = await _messageRep.AddMsg(messageDto);//添加消息
  201. if (status)
  202. {
  203. //给在线在用户发送消息
  204. var connIds = UserStore.OnlineUser.Where(it => userIds.Contains(it.UserId)).Select(it => it.ConnectionId).ToList();
  205. var notificationTypeStr1 = GetMsgNotificationType(msgTypeEnum);
  206. var notificationTypeStr = JsonConvert.SerializeObject(
  207. new
  208. {
  209. UserIds = userIds,
  210. Msg = $"您有一条{notificationTypeStr1}相关的消息!"
  211. }
  212. );
  213. await _hubContext.Clients.Clients(connIds).ReceiveMessage($"您有一条{notificationTypeStr1}相关的消息!");
  214. return true;
  215. }
  216. return false;
  217. }
  218. /// <summary>
  219. /// 根据消息类型 获取 消息通知类型
  220. /// </summary>
  221. /// <returns></returns>
  222. public static string GetMsgNotificationType(MessageTypeEnum msgTypeEnum)
  223. {
  224. int notificationType = 0;
  225. string notificationStr = "";
  226. List<NotificationTypeView> notificationTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
  227. notificationType = notificationTypeViews.Where(it => it.MsgTypeIds.Contains((int)msgTypeEnum)).Select(it => it.TypeId).FirstOrDefault();
  228. if (notificationType == 1021) notificationStr = "操作";
  229. else if (notificationType == 1020) notificationStr = "任务";
  230. return notificationStr;
  231. }
  232. #endregion
  233. #region md5 加密
  234. /// <summary>
  235. /// MD5加密,和动网上的16/32位MD5加密结果相同,
  236. /// 使用的UTF8编码
  237. /// </summary>
  238. /// <param name="source">待加密字串</param>
  239. /// <param name="length">16或32值之一,其它则采用.net默认MD5加密算法</param>
  240. /// <returns>加密后的字串</returns>
  241. public static string Encrypt(string source, int length = 32)
  242. {
  243. if (string.IsNullOrWhiteSpace(source))
  244. return string.Empty;
  245. HashAlgorithm hashAlgorithm = CryptoConfig.CreateFromName("MD5") as HashAlgorithm;
  246. byte[] bytes = Encoding.UTF8.GetBytes(source);
  247. byte[] hashValue = hashAlgorithm.ComputeHash(bytes);
  248. StringBuilder sb = new StringBuilder();
  249. switch (length)
  250. {
  251. case 16://16位密文是32位密文的9到24位字符
  252. for (int i = 4; i < 12; i++)
  253. {
  254. sb.Append(hashValue[i].ToString("x2"));
  255. }
  256. break;
  257. case 32:
  258. for (int i = 0; i < 16; i++)
  259. {
  260. sb.Append(hashValue[i].ToString("x2"));
  261. }
  262. break;
  263. default:
  264. for (int i = 0; i < hashValue.Length; i++)
  265. {
  266. sb.Append(hashValue[i].ToString("x2"));
  267. }
  268. break;
  269. }
  270. return sb.ToString();
  271. }
  272. #endregion
  273. #region jwt
  274. /// <summary>
  275. /// 获取token
  276. /// </summary>
  277. /// <param name="_config"></param>
  278. /// <param name="Number"></param>
  279. /// <param name="uId"></param>
  280. /// <param name="uName"></param>
  281. /// <param name="exp"></param>
  282. /// <returns></returns>
  283. public static async Task<string> GetToken(IConfiguration _config, string Number, int uId, string uName, DateTime exp)
  284. {
  285. string userId = Guid.NewGuid().ToString().Replace("-", "");
  286. var claims = new[] {
  287. new Claim(ClaimTypes.NameIdentifier, uName),
  288. new Claim(ClaimTypes.NameIdentifier, uId.ToString()),
  289. new Claim(ClaimTypes.NameIdentifier, userId),
  290. new Claim("Number",Number)
  291. };
  292. var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["JwtSecurityKey"]));
  293. var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
  294. var token = new JwtSecurityToken(
  295. issuer: "OASystem.com",
  296. audience: "OASystem.com",
  297. claims: claims,
  298. expires: exp,
  299. signingCredentials: creds);
  300. var identity = new ClaimsIdentity(claims, "login");
  301. var principal = new ClaimsPrincipal(identity);
  302. // await _httpContext.SignInAsync (CookieAuthenticationDefaults.AuthenticationScheme, principal);
  303. return new JwtSecurityTokenHandler().WriteToken(token);
  304. }
  305. #endregion
  306. #region 数据类型转换
  307. /// <summary>
  308. /// object 转 Int
  309. /// </summary>
  310. /// <param name="obj"></param>
  311. /// <returns></returns>
  312. public static int GetInt(this object obj)
  313. {
  314. if (obj == null)
  315. return 0;
  316. var number = 0;
  317. var reslut = Int32.TryParse(obj.ToString(), out number);
  318. return number;
  319. }
  320. private static DateTime _dateStart = new DateTime(1970, 1, 1, 8, 0, 0);
  321. private static long _longTime = 621355968000000000;
  322. private static int _samllTime = 10000000;
  323. /// <summary>
  324. /// 时间戳 转 datetime
  325. /// </summary>
  326. /// <param name="timeStamp"></param>
  327. /// <returns></returns>
  328. public static DateTime GetTimeSpmpToDate(this object timeStamp)
  329. {
  330. if (timeStamp == null) return _dateStart;
  331. DateTime dateTime = new DateTime(_longTime + Convert.ToInt64(timeStamp) * _samllTime, DateTimeKind.Utc).ToLocalTime();
  332. return dateTime;
  333. }
  334. #endregion
  335. #region 用户页面操作功能 权限
  336. /// <summary>
  337. /// 用户页面操作功能(可使用)
  338. /// </summary>
  339. /// <param name="userId">用户Id</param>
  340. /// <param name="PageId">页面Id</param>
  341. /// <returns></returns>
  342. public static async Task<PageFunAuthViewBase> PostUserPageFuncDatas(int userId, int PageId)
  343. {
  344. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  345. List<UserPageFuncView> userPageFuncDatas = new List<UserPageFuncView>();
  346. string sql = string.Format(@"Select ua.UId As UserId, u.CnName As UserName, pa.ModuleId,pa.ModuleName,pa.PageId,pa.PageName,pa.PageIsEnable,
  347. pa.PagePhoneIsEnable,pa.FuncId,pa.FuncName,pa.FuncIsEnable
  348. From Sys_UserAuthority ua
  349. Left Join Sys_Users u On ua.UId = u.Id
  350. Left Join (
  351. Select sd.Id As ModuleId,sd.Name As ModuleName, smp.Id As PageId,smp.Name As PageName,smp.IsEnable As PageIsEnable,
  352. smp.phoneIsEnable As PagePhoneIsEnable,pfp.Id As FuncId,pfp.FunctionName As FuncName,pfp.IsEnable As FuncIsEnable
  353. From Sys_SystemMenuAndFunction smaf
  354. Left Join Sys_SystemMenuPermission smp On smaf.SmId = smp.Id
  355. Left Join Sys_SetData sd On sd.STid = 5 And smp.Mid = sd.Id
  356. Left Join Sys_PageFunctionPermission pfp On smaf.FId = pfp.Id
  357. Where smaf.IsDel = 0 And smp.IsDel = 0 And pfp.IsDel = 0 And sd.IsDel = 0 And smp.IsEnable = 1
  358. ) As pa On ua.SmId = pa.PageId And ua.FId = pa.FuncId
  359. Where ua.IsDel = 0 And ua.UId = {0} And pa.PageId = {1}
  360. Order By ModuleId,PageId,FuncId Asc", userId, PageId);
  361. userPageFuncDatas = await _dirRep._sqlSugar.SqlQueryable<UserPageFuncView>(sql).ToListAsync();
  362. if (userPageFuncDatas.Count <= 0)
  363. {
  364. return pageFunAuth;
  365. }
  366. UserPageFuncView userPageFunc = new UserPageFuncView();
  367. //查询 1
  368. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 1).FirstOrDefault();
  369. if (userPageFunc != null) pageFunAuth.CheckAuth = 1;
  370. //删除 2
  371. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 2).FirstOrDefault();
  372. if (userPageFunc != null) pageFunAuth.DeleteAuth = 1;
  373. //编辑 3
  374. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 3).FirstOrDefault();
  375. if (userPageFunc != null) pageFunAuth.EditAuth = 1;
  376. //下载 4
  377. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 4).FirstOrDefault();
  378. if (userPageFunc != null) pageFunAuth.FilesDownloadAuth = 1;
  379. //上传 5
  380. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 5).FirstOrDefault();
  381. if (userPageFunc != null) pageFunAuth.FilesUploadAuth = 1;
  382. //添加 11
  383. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 11).FirstOrDefault();
  384. if (userPageFunc != null) pageFunAuth.AddAuth = 1;
  385. //审核 12
  386. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 12).FirstOrDefault();
  387. if (userPageFunc != null) pageFunAuth.AuditAuth = 1;
  388. return pageFunAuth;
  389. }
  390. #endregion
  391. #region 业务模块 团组权限
  392. /// <summary>
  393. /// 业务模块 团组操作权限
  394. /// 验证 并返回可操作的团
  395. /// </summary>
  396. /// <param name="diId">团组Id</param>
  397. /// <param name="userId">用户Id</param>
  398. /// <param name="CTable">业务模块Id</param>
  399. /// <returns></returns>
  400. public static async Task<Result> PostGroupOperationAuth(int diId, int userId, int CTable)
  401. {
  402. Result _result = new Result { Code = -1, Msg = "No Operation Authorty!" };
  403. if (CTable < 1)
  404. {
  405. _result.Msg = "请填写正确的用户Id!";
  406. return _result;
  407. }
  408. var data = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.DIId == diId && it.UId == userId && it.CTId == CTable && it.IsDel == 0).First();
  409. if (data == null)
  410. {
  411. _result.Msg = "你没有本团下的该业务模块操作,请联系主管分配操作权限!";
  412. }
  413. else
  414. {
  415. _result.Code = 0;
  416. }
  417. return _result;
  418. }
  419. /// <summary>
  420. /// 业务模块 团组操作权限
  421. /// 返回可操作的团
  422. /// </summary>
  423. /// <param name="userId">用户Id</param>
  424. /// <param name="CTable">业务模块Id</param>
  425. /// <returns></returns>
  426. public static async Task<List<Web_ShareGroupInfoView>> PostOperationAuthReturnGroupInfosAsync(int userId, int CTable)
  427. {
  428. var shareGroupInfoViews = new List<Web_ShareGroupInfoView>();
  429. var taskData = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.UId == userId && it.CTId == CTable && it.IsDel == 0).ToList();
  430. if (taskData.Count < 1) return shareGroupInfoViews;
  431. var diIds = string.Join(",", taskData.Select(it => it.DIId).ToList());
  432. var sql = string.Format(@"Select Id,TeamName,TourCode,ClientName,VisitCountry,VisitStartDate,VisitEndDate,VisitDays,VisitPNumber
  433. From Grp_DelegationInfo Where Id In({0}) And IsDel = 0 Order By Id Desc", diIds);
  434. shareGroupInfoViews = await _dirRep._sqlSugar.SqlQueryable<Web_ShareGroupInfoView>(sql).ToListAsync();
  435. return shareGroupInfoViews;
  436. }
  437. #endregion
  438. #region 团组相关
  439. #region 建团按国家默认添加汇率 / 默认权限分配
  440. /// <summary>
  441. /// 团组汇率
  442. /// 建团时 添加基础汇率 CNY
  443. /// 按国家 添加 默认币种
  444. /// </summary>
  445. /// <param name="userId"></param>
  446. /// <param name="diId"></param>
  447. /// <returns></returns>
  448. public static async Task<Result> PostGroupRateAddInit(int userId, int diId)
  449. {
  450. Result result = new() { Code = -2 };
  451. if (userId < 1)
  452. {
  453. result.Msg = string.Format(@"请传入正确的userId");
  454. return result;
  455. }
  456. if (diId < 1)
  457. {
  458. result.Msg = string.Format(@"请传入正确的DiId");
  459. return result;
  460. }
  461. //美元(USD):1.0000|欧元(EUR):1.0000|墨西哥比索(MXN):1.0000
  462. string rateInit = string.Format(@"人民币(CNY):1.0000");
  463. //var gropInfo = _dirRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == diId).First();
  464. //if (gropInfo == null)
  465. //{
  466. // result.Msg = $@"未查询到团组信息!";
  467. // return result;
  468. //}
  469. var juheRateData = await _juHeApi.GetExchangeRateAsync();
  470. if (juheRateData.Error_code != 0)
  471. {
  472. result.Msg = juheRateData.Reason;
  473. return result;
  474. }
  475. List<ExchangeRateModel> exchangeRateModels = (List<ExchangeRateModel>)juheRateData.Result;
  476. if (exchangeRateModels.Count <= 0)
  477. {
  478. result.Msg = $@"未查询到聚合接口汇率信息!";
  479. return result;
  480. }
  481. if (exchangeRateModels.Count > 0)
  482. {
  483. var codes = _dirRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  484. for (int i = 0; i < exchangeRateModels.Count; i++)
  485. {
  486. string currencyName = exchangeRateModels[i].Name;
  487. string code = "";
  488. var currencyData = codes.Where(it => it.Remark == currencyName).FirstOrDefault();
  489. if (currencyData != null)
  490. {
  491. code = currencyData.Name;
  492. decimal currRate = 0.00M;
  493. string MSellPri = exchangeRateModels[i].MSellPri;
  494. if (!string.IsNullOrEmpty(MSellPri))
  495. {
  496. currRate = Convert.ToDecimal(MSellPri) / 100M;
  497. }
  498. rateInit += $@"|{currencyName}({code}):{currRate.ToString("#0.0000")}";
  499. }
  500. }
  501. }
  502. var cTableIds = _dirRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  503. if (cTableIds.Count < 1)
  504. {
  505. result.Msg = $@"未查询到操作模块信息!";
  506. return result;
  507. }
  508. List<Grp_TeamRate> grp_TeamRates = new List<Grp_TeamRate>();
  509. foreach (var item in cTableIds)
  510. {
  511. grp_TeamRates.Add(
  512. new Grp_TeamRate() { DiId = diId, CTable = item.Id, Remark = rateInit, CreateUserId = userId }
  513. );
  514. }
  515. if (grp_TeamRates.Count > 0)
  516. {
  517. var addId = _teamRateRep._sqlSugar.Insertable(grp_TeamRates).ExecuteCommand();
  518. if (addId < 1)
  519. {
  520. result.Msg = string.Format(@"添加失败!");
  521. return result;
  522. }
  523. }
  524. result.Code = 0;
  525. result.Msg = string.Format(@"操作成功!");
  526. return result;
  527. }
  528. /// <summary>
  529. /// 团组任务分配
  530. /// 建团时 默认按照岗位分配权限
  531. /// </summary>
  532. /// <param name="userId"></param>
  533. /// <param name="diId"></param>
  534. /// <param name="companyId"></param>
  535. /// <returns></returns>
  536. public static async Task<Result> PostGroupAuthAddInit(int userId, int diId, int companyId = 2)
  537. {
  538. Result result = new() { Code = -2 };
  539. if (userId < 0)
  540. {
  541. result.Msg = string.Format(@"请传入正确的userId");
  542. return result;
  543. }
  544. if (companyId < 0)
  545. {
  546. result.Msg = string.Format(@"请传入正确的companyId");
  547. return result;
  548. }
  549. if (diId < 0)
  550. {
  551. result.Msg = string.Format(@"请传入正确的DiId");
  552. return result;
  553. }
  554. var usersData = await _teamRateRep._sqlSugar.Queryable<Sys_Users>()
  555. .LeftJoin<Sys_Department>((su, sd) => su.DepId == sd.Id && sd.IsDel == 0)
  556. .LeftJoin<Sys_JobPost>((su, sd, sjp) => su.JobPostId == sjp.Id && sjp.IsDel == 0)
  557. .Where(su => su.IsDel == 0)
  558. .Select((su, sd, sjp) => new
  559. {
  560. su.DepId,
  561. sd.DepName,
  562. su.JobPostId,
  563. sjp.JobName,
  564. su.Id,
  565. su.CnName
  566. })
  567. .ToListAsync();
  568. /*
  569. * 76 酒店预订 --> 国交部门 酒店,主管 岗位
  570. * 77 行程 --> 国交部门 经理,主管 岗位
  571. * 79 车/导游地接 --> 国交部门 OP,主管 岗位
  572. * 80 签证 --> 国交部门 签证 岗位
  573. * 81 邀请/公务活动 --> 国交部门 商邀 岗位
  574. * 82 团组客户保险 --> 国交部 经理,主管 岗位
  575. * 85 机票预订 --> 国交部门 机票 岗位
  576. * 98 其他款项 --> 总经办部门 总经理 岗位/国交部门(ALL) 岗位/财务部门(ALL) 岗位/策划部门(ALL) 岗位/人事部门 采购 岗位
  577. * 1015 超支费用,69 收款退还 --> 财务部门(ALL)岗位
  578. * 1015 超支费用 --> 国交部(ALL)岗位
  579. * 1081 文档下载 --> 国交部门 酒店,主管 岗位
  580. */
  581. var groupsTaskAssignments = new List<Grp_GroupsTaskAssignment>();
  582. // 76 酒店预订 --> 国交部门(7) 酒店(25)、主管(22) 岗位
  583. groupsTaskAssignments.AddRange(
  584. usersData
  585. .Where(it => it.DepId == 7 && (it.JobPostId == 25 || it.JobPostId == 22))
  586. .Select(it => new Grp_GroupsTaskAssignment()
  587. {
  588. DIId = diId,
  589. CTId = 76,
  590. UId = it.Id,
  591. CreateUserId = userId
  592. }).ToList()
  593. );
  594. // 77 行程 --> 国交部门(7) 经理(32),主管(22) 岗位
  595. groupsTaskAssignments.AddRange(
  596. usersData
  597. .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 32))
  598. .Select(it => new Grp_GroupsTaskAssignment()
  599. {
  600. DIId = diId,
  601. CTId = 77,
  602. UId = it.Id,
  603. CreateUserId = userId
  604. }).ToList()
  605. );
  606. //79 车/导游地接 --> 国交部门(7) OP(28)、主管(22) 岗位
  607. //groupsTaskAssignments.AddRange(
  608. // usersData.Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 28))
  609. // .Select(it => new Grp_GroupsTaskAssignment()
  610. // {
  611. // DIId = diId,
  612. // CTId = 79,
  613. // UId = it.Id,
  614. // CreateUserId = userId
  615. // }).ToList()
  616. //);
  617. //81 邀请/公务活动 --> 国交部门(7) 商邀(27) 岗位
  618. //groupsTaskAssignments.AddRange(
  619. // usersData.Where(it => it.DepId == 7 && it.JobPostId == 27)
  620. // .Select(it => new Grp_GroupsTaskAssignment()
  621. // {
  622. // DIId = diId,
  623. // CTId = 81,
  624. // UId = it.Id,
  625. // CreateUserId = userId
  626. // }).ToList()
  627. //);
  628. //2024年8月26日16点27分 “邀请公务活动分配给王鸽(UserID:149)”
  629. //groupsTaskAssignments.Add(
  630. // new Grp_GroupsTaskAssignment()
  631. // {
  632. // DIId = diId,
  633. // CTId = 81,
  634. // UId = 149,
  635. // CreateUserId = userId
  636. // }
  637. //);
  638. //80 签证 --> 国交部门(7) 签证(26) 岗位
  639. //groupsTaskAssignments.AddRange(
  640. // usersData
  641. // .Where(it => it.DepId == 7 && it.JobPostId == 26)
  642. // .Select(it => new Grp_GroupsTaskAssignment()
  643. // {
  644. // DIId = diId,
  645. // CTId = 80,
  646. // UId = it.Id,
  647. // CreateUserId = userId
  648. // }).ToList()
  649. //);
  650. //82 团组客户保险 --> 国交部(7) 经理(32),主管(22) 岗位
  651. //2024-06-25 默认将保险权限分配给签证岗。 签证(26) 岗位
  652. List<int> insurancePositions = new List<int>() { 32, 22, 26 };
  653. groupsTaskAssignments.AddRange(
  654. usersData
  655. .Where(it => it.DepId == 7 && insurancePositions.Contains(it.JobPostId))
  656. .Select(it => new Grp_GroupsTaskAssignment()
  657. {
  658. DIId = diId,
  659. CTId = 82,
  660. UId = it.Id,
  661. CreateUserId = userId
  662. }).ToList()
  663. );
  664. //85 机票预订 --> 国交部门(7) 机票(24),主管(22) 岗位
  665. groupsTaskAssignments.AddRange(
  666. usersData
  667. .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 24))
  668. .Select(it => new Grp_GroupsTaskAssignment()
  669. {
  670. DIId = diId,
  671. CTId = 85,
  672. UId = it.Id,
  673. CreateUserId = userId
  674. }).ToList()
  675. );
  676. //98 其他款项 --> 总经办部门(1) 总经理(1) 岗位/国交部门(7)(ALL) 岗位/财务部门(3)(ALL) 岗位/策划部门(5)(ALL) 岗位/人事部门(4) 采购(74) 岗位
  677. var depIds = new List<int>() { 7, 3, 5 };
  678. var jobIds = new List<int>() { 1, 74 };
  679. groupsTaskAssignments.AddRange(
  680. usersData
  681. .Where(it => depIds.Contains(it.DepId) || jobIds.Contains(it.JobPostId))
  682. .Select(it => new Grp_GroupsTaskAssignment()
  683. {
  684. DIId = diId,
  685. CTId = 98,
  686. UId = it.Id,
  687. CreateUserId = userId
  688. }).ToList()
  689. );
  690. //2024年8月26日16点27分 “其他款项分配给王鸽(UserID:149)”
  691. groupsTaskAssignments.Add(new Grp_GroupsTaskAssignment()
  692. {
  693. DIId = diId,
  694. CTId = 98,
  695. UId = 149,
  696. CreateUserId = userId
  697. }
  698. );
  699. //1015 超支费用,285 收款退还 --> 财务部门(ALL)岗位
  700. groupsTaskAssignments.AddRange(
  701. usersData
  702. .Where(it => it.DepId == 3)
  703. .Select(it => new Grp_GroupsTaskAssignment()
  704. {
  705. DIId = diId,
  706. CTId = 1015,
  707. UId = it.Id,
  708. CreateUserId = userId
  709. }).ToList()
  710. );
  711. groupsTaskAssignments.AddRange(
  712. usersData
  713. .Where(it => it.DepId == 3)
  714. .Select(it => new Grp_GroupsTaskAssignment()
  715. {
  716. DIId = diId,
  717. CTId = 285,
  718. UId = it.Id,
  719. CreateUserId = userId
  720. }).ToList()
  721. );
  722. //1015 超支费用 --> 国交部(ALL)岗位
  723. groupsTaskAssignments.AddRange(
  724. usersData
  725. .Where(it => it.DepId == 7)
  726. .Select(it => new Grp_GroupsTaskAssignment()
  727. {
  728. DIId = diId,
  729. CTId = 1015,
  730. UId = it.Id,
  731. CreateUserId = userId
  732. }).ToList()
  733. );
  734. if (groupsTaskAssignments.Count > 0)
  735. {
  736. var addId = await _teamRateRep._sqlSugar.Insertable(groupsTaskAssignments).ExecuteCommandAsync();
  737. }
  738. result.Code = 0;
  739. result.Msg = string.Format(@"操作成功!");
  740. return result;
  741. }
  742. #endregion
  743. #region 员工是否是市场部人员
  744. /// <summary>
  745. /// 验证市场部客户人员
  746. /// </summary>
  747. /// <param name="userId"></param>
  748. /// <returns></returns>
  749. public static async Task<bool> IsMarketingStaff(int userId)
  750. {
  751. var userInfos = await _dirRep._sqlSugar
  752. .Queryable<Sys_Users>()
  753. .InnerJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  754. .Where((u, d) => u.IsDel == 0 && u.Id == userId && d.DepName.Contains("市场部"))
  755. .ToListAsync();
  756. if (userInfos.Count > 0) return true;
  757. return false;
  758. }
  759. #endregion
  760. #region 三公费用相关
  761. /// <summary>
  762. /// 保存操作前汇率
  763. /// </summary>
  764. /// <param name="currUserId"></param>
  765. /// <param name="diId"></param>
  766. /// <param name="linkModule"></param>
  767. /// <returns></returns>
  768. public static async Task<bool> RateRecordSave(int currUserId, int diId, string linkModule)
  769. {
  770. //var selectData = await _enterExitCostRep._sqlSugar.Queryable<Sys_ExchangeRateRecord>()
  771. // .Where(x => Convert.ToDateTime(x.RateDateTime).ToString("yyyy-MM-dd").Equals(DateTime.Now.ToString("yyyy-MM-dd")))
  772. // .FirstAsync();
  773. //if (selectData != null) return false;
  774. var _currencyRate = await _juHeApi.PostItemRateAsync(Array.Empty<string>());
  775. string rateInfoStr = string.Empty;
  776. var oaCurrencyData = await _sqlSugar.Queryable<Sys_SetData>()
  777. .Where(x => x.IsDel == 0 && x.STid == 66)
  778. .ToListAsync();
  779. foreach (var rate in _currencyRate)
  780. {
  781. var oaCurrncy = oaCurrencyData.Find(x => x.Remark.Equals(rate.Name));
  782. if (oaCurrncy == null) continue;
  783. //美元(USD):7.5|
  784. string rateStr = rate.FSellPri ?? "0.00";
  785. rateInfoStr += $"{rate.Name}({oaCurrncy.Name}):{rateStr}|";
  786. }
  787. if (string.IsNullOrEmpty(rateInfoStr)) return false;
  788. var add = await _sqlSugar
  789. .Insertable<Sys_ExchangeRateRecord>(new Sys_ExchangeRateRecord()
  790. {
  791. DiId = diId,
  792. LinkModule = linkModule,
  793. RateDateTime = DateTime.Now,
  794. RateInfo = rateInfoStr,
  795. CreateUserId = currUserId,
  796. IsDel = 0
  797. })
  798. .ExecuteCommandAsync();
  799. return add > 0;
  800. }
  801. /// <summary>
  802. /// 三公费用导入收款账单数据
  803. /// </summary>
  804. /// <param name="groupId"></param>
  805. /// <returns></returns>
  806. public static async Task<List<Fin_ForeignReceivables>> ReceivablesImportFeeAsync(int groupId)
  807. {
  808. var data = new List<Fin_ForeignReceivables>();
  809. var enterExitCosts = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == groupId).FirstAsync();
  810. var dayAndCosts = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == groupId).ToListAsync();
  811. var dayOtherCosts = await _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == groupId).ToListAsync(); //其他款项
  812. if (enterExitCosts == null) return data;
  813. //数据源
  814. var stayData = dayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  815. var mealData = dayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  816. var miscellaneousData = dayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  817. var trainData = dayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  818. //筛选 陪同人员 = 1
  819. var groupClientList = await _sqlSugar.Queryable<Grp_TourClientList>()
  820. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id)
  821. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id)
  822. .LeftJoin<Sys_SetData>((tcl, dc, cc, sd) => tcl.ShippingSpaceTypeId == sd.Id)
  823. .Where(tcl => tcl.IsDel == 0 &&
  824. tcl.DiId == groupId &&
  825. tcl.IsAccompany == 1
  826. )
  827. .Select((tcl, dc, cc, sd) => new
  828. {
  829. DiId = tcl.DiId,
  830. CompanyId = cc.Id,
  831. CompanyName = cc.CompanyFullName,
  832. ClienId = dc.Id,
  833. ClientName = dc.FirstName + dc.LastName,
  834. SpaceId = tcl.ShippingSpaceTypeId,
  835. SpaceName = sd.Name
  836. })
  837. .ToListAsync();
  838. if (!groupClientList.Any()) return data;
  839. decimal domesticFeeTotal = 0.00M, //境内费用
  840. economyClassFeeTotal = 0.00M, //经济舱费用
  841. businessClassFeeTotal = 0.00M, //公务舱费用
  842. firstClassFeeTotal = 0.00M, //头等舱费用
  843. stayFeeTotal = 0.00M, //住宿费
  844. mealsFeeTotal = 0.00M, //餐食费
  845. miscellaneousFeeTotal = 0.00M, //公杂费
  846. trainFeeTotal = 0.00M, //培训费
  847. otherPriceTotal = 0.00M; //其他款项
  848. //境内费用(其他费用)
  849. if (enterExitCosts.ChoiceOne == 1) domesticFeeTotal = enterExitCosts.InsidePay;
  850. //住宿费
  851. if (enterExitCosts.ChoiceThree == 1) stayFeeTotal = stayData.Sum(x => x.SubTotal);
  852. //伙食费
  853. if (enterExitCosts.ChoiceFour == 1) mealsFeeTotal = mealData.Sum(x => x.SubTotal);
  854. //公杂费
  855. if (enterExitCosts.ChoiceFive == 1) miscellaneousFeeTotal = miscellaneousData.Sum(x => x.SubTotal);
  856. //培训费
  857. if (enterExitCosts.ChoiceSix == 1) trainFeeTotal = trainData.Sum(x => x.SubTotal);
  858. //其他款项
  859. if (enterExitCosts.OtherExpenses_Checked == 1) otherPriceTotal = dayOtherCosts.Sum(x => x.SubTotal);
  860. decimal otherFeeTotal = domesticFeeTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainFeeTotal + otherPriceTotal;
  861. //国际旅费合计
  862. //经济舱
  863. if (enterExitCosts.SumJJC == 1) economyClassFeeTotal = enterExitCosts.OutsideJJPay + otherFeeTotal;
  864. //公务舱
  865. if (enterExitCosts.SumGWC == 1) businessClassFeeTotal = enterExitCosts.OutsideGWPay + otherFeeTotal;
  866. //头等舱
  867. if (enterExitCosts.SumTDC == 1) firstClassFeeTotal = enterExitCosts.OutsideTDPay + otherFeeTotal;
  868. var groupClientListGroup = groupClientList.GroupBy(x => x.CompanyId);
  869. foreach (var item in groupClientListGroup)
  870. {
  871. var companyName = AesEncryptionHelper.Decrypt(item.FirstOrDefault().CompanyName);
  872. var airTicketGroup = item.GroupBy(x => x.SpaceId);
  873. foreach (var airTicket in airTicketGroup)
  874. {
  875. int quantity = airTicket.Count();
  876. if (quantity > 0)
  877. {
  878. var price = 0.00M;
  879. var spaceName = airTicket.FirstOrDefault()?.SpaceName ?? string.Empty;
  880. if (spaceName.Equals("经济舱")) price = economyClassFeeTotal;
  881. else if (spaceName.Equals("公务舱")) price = businessClassFeeTotal;
  882. else if (spaceName.Equals("头等舱")) price = firstClassFeeTotal;
  883. if (price > 0)
  884. {
  885. decimal itemTotal = price * quantity;
  886. data.Add(new Fin_ForeignReceivables()
  887. {
  888. Id = 0,
  889. CreateTime = DateTime.Now,
  890. Diid = groupId,
  891. PriceName = $"{companyName}-{spaceName}",
  892. Price = price,
  893. Count = quantity,
  894. Unit = "人",
  895. ItemSumPrice = itemTotal,
  896. Currency = 836,
  897. Rate = 1.0000M,
  898. AddingWay = 2,
  899. Remark = "由出入境费用导入费用",
  900. });
  901. }
  902. }
  903. }
  904. }
  905. return data;
  906. }
  907. #endregion
  908. #region 根据团ID获取各板块实际操作人
  909. /// <summary>
  910. /// 获取 团组模块操作人
  911. /// </summary>
  912. /// <param name="groupId"></param>
  913. /// <returns></returns>
  914. public static List<GroupOperationUserView> GetGroupModuleOperators(int groupId)
  915. {
  916. var modoule = new GroupOperationUserView();
  917. var view = modoule.GetOperationUsersInit();
  918. if (groupId < 1) return view;
  919. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>()
  920. .Where(it => it.IsDel == 0 && it.Id == groupId)
  921. .First();
  922. if (groupInfo == null) return view;
  923. //获取团组下的操作人
  924. //车/导游地接
  925. var opUers = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  926. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 79)
  927. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  928. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  929. .Select((x, y, u) => new GroupOperationUserInfo
  930. {
  931. UserId = u.Id,
  932. UserName = u.CnName
  933. }).Distinct().ToList();
  934. view.Where(it => it.CTableId == 79).FirstOrDefault().OperationUsers = opUers;
  935. //签证
  936. var visaUsers = _sqlSugar.Queryable<Grp_VisaInfo>()
  937. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 80)
  938. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  939. .Where((x, y, u) => x.DIId == groupId && x.IsDel == 0)
  940. .Select((x, y, u) => new GroupOperationUserInfo
  941. {
  942. UserId = u.Id,
  943. UserName = u.CnName
  944. }).Distinct().ToList();
  945. view.Where(it => it.CTableId == 80).FirstOrDefault().OperationUsers = visaUsers;
  946. //保险
  947. var insUsers = _sqlSugar.Queryable<Grp_Customers>()
  948. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 82)
  949. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  950. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  951. .Select((x, y, u) => new GroupOperationUserInfo
  952. {
  953. UserId = u.Id,
  954. UserName = u.CnName
  955. }).Distinct().ToList();
  956. view.Where(it => it.CTableId == 82).FirstOrDefault().OperationUsers = insUsers;
  957. //邀请/公务活动
  958. var ioaUsers = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>()
  959. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 81)
  960. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  961. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  962. .Select((x, y, u) => new GroupOperationUserInfo
  963. {
  964. UserId = u.Id,
  965. UserName = u.CnName
  966. }).Distinct().ToList();
  967. if (!ioaUsers.Any())
  968. {
  969. ioaUsers = _sqlSugar.Queryable<Res_OfficialActivities>()
  970. .LeftJoin<Sys_Users>((x, y) => x.CreateUserId == y.Id)
  971. .Where((x, y) => x.DiId == groupId && x.IsDel == 0)
  972. .Select((x, y) => new GroupOperationUserInfo
  973. {
  974. UserId = y.Id,
  975. UserName = y.CnName
  976. }).Distinct().ToList();
  977. }
  978. view.Where(it => it.CTableId == 81).FirstOrDefault().OperationUsers = ioaUsers;
  979. //其他款项 98
  980. var otherUsers = _sqlSugar.Queryable<Grp_DecreasePayments>()
  981. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 98)
  982. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  983. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  984. .Select((x, y, u) => new GroupOperationUserInfo
  985. {
  986. UserId = u.Id,
  987. UserName = u.CnName
  988. }).Distinct().ToList();
  989. view.Where(it => it.CTableId == 98).FirstOrDefault().OperationUsers = otherUsers;
  990. //添加分配人员
  991. // 79 车/导游地接
  992. // 80 签证
  993. // 81 邀请/公务活动
  994. var setdataids = new List<int>() { 79, 81 };
  995. // 27 商邀
  996. // 28 OP
  997. var jobSetdataids = new List<int>() { 27, 28 };
  998. var q = _sqlSugar.Queryable<Grp_GroupsTaskAssignment, Sys_Users>(
  999. (ccta, su) => new JoinQueryInfos(
  1000. JoinType.Left, ccta.UId == su.Id && su.IsDel == 0))
  1001. .Where((ccta, su) =>
  1002. ccta.IsDel == 0 &&
  1003. ccta.DIId == groupId &&
  1004. jobSetdataids.Contains(su.JobPostId) &&
  1005. setdataids.Contains(ccta.CTId))
  1006. .Select((ccta, su) => new
  1007. {
  1008. userid = su.Id,
  1009. su.JobPostId,
  1010. ccta.CTId,
  1011. ccta.DIId,
  1012. su.CnName,
  1013. });
  1014. var qtb = q.ToDataTable();
  1015. foreach (var groupModule in view)
  1016. {
  1017. if (setdataids.Contains(groupModule.CTableId) && !groupModule.OperationUsers.Any())
  1018. {
  1019. var qtbUsers = qtb.AsEnumerable().
  1020. Where(x => x.Field<int>("CTId") == groupModule.CTableId).
  1021. Select(x => x.Field<int>("userid")).ToList();
  1022. groupModule.OperationUsers = qtbUsers.Select(x => new GeneralMethod.GroupOperationUserInfo()
  1023. {
  1024. UserId = x,
  1025. UserName = qtb.AsEnumerable().FirstOrDefault(y => y.Field<int>("userid") == x)?.Field<string>("CnName") ?? ""
  1026. }).ToList();
  1027. }
  1028. }
  1029. return view;
  1030. }
  1031. public class GroupOperationUserView
  1032. {
  1033. public int CTableId { get; set; }
  1034. public string CTableName { get; set; }
  1035. public List<GroupOperationUserInfo> OperationUsers { get; set; }
  1036. public GroupOperationUserView() { }
  1037. /// <summary>
  1038. /// 默认模块List
  1039. /// </summary>
  1040. /// <returns></returns>
  1041. public List<GroupOperationUserView> GetOperationUsersInit()
  1042. {
  1043. var modules = new List<GroupOperationUserView>() {
  1044. new(){ CTableId = 76,CTableName = "酒店预订",
  1045. OperationUsers=new List<GroupOperationUserInfo>(){ new() {UserId = 226,UserName = "宋夏雨" } } },
  1046. new(){ CTableId = 79,CTableName = "车/导游地接" },
  1047. new(){ CTableId = 80,CTableName = "签证" },
  1048. new(){ CTableId = 82,CTableName = "团组客户保险" },
  1049. new(){ CTableId = 81,CTableName = "邀请/公务活动" },
  1050. new(){ CTableId = 85,CTableName = "机票预订",
  1051. OperationUsers=new List<GroupOperationUserInfo>(){ new() {UserId = 385, UserName = "雍婷玉" } } },
  1052. new(){ CTableId = 98,CTableName = "其他款项" },
  1053. };
  1054. return modules;
  1055. }
  1056. }
  1057. public class GroupOperationUserInfo
  1058. {
  1059. public int UserId { get; set; }
  1060. public string UserName { get; set; }
  1061. }
  1062. #endregion
  1063. #endregion
  1064. #region 团组汇率
  1065. /// <summary>
  1066. /// 团组汇率
  1067. /// 获取板块 币种 及 汇率
  1068. /// 76 酒店预订 77 行程 79 车/导游地接
  1069. /// 80 签证 82 团组客户保险 85 机票预订
  1070. /// 98 其他款项 285 收款退还
  1071. /// </summary>
  1072. /// <param name="teamRateModels"></param>
  1073. /// <param name="cTable"></param>
  1074. /// <param name="currencyCodes"></param>
  1075. /// <returns>
  1076. /// string
  1077. /// eg: CNY 1.0000
  1078. /// </returns>
  1079. public static async Task<string> PostGroupRateByCTableAndCurrency(List<TeamRateModelView> teamRateModels, int cTable, List<string> currencyCodes)
  1080. {
  1081. string str = "";
  1082. List<string> currencyRates = new List<string>();
  1083. TeamRateModelView hotelRateData = teamRateModels.Where(it => it.CTableId == cTable).FirstOrDefault();
  1084. if (hotelRateData != null)
  1085. {
  1086. var hotelRates = hotelRateData.TeamRates;
  1087. foreach (var item in currencyCodes)
  1088. {
  1089. if (!string.IsNullOrEmpty(item))
  1090. {
  1091. var hotelRateInfo = hotelRates.Where(it => it.CurrencyCode.Equals(item)).FirstOrDefault();
  1092. if (hotelRateInfo != null)
  1093. {
  1094. string str1 = string.Format("{0} {1}\r\n", hotelRateInfo.CurrencyCode, hotelRateInfo.Rate.ToString("#0.0000"));
  1095. currencyRates.Add(str1);
  1096. }
  1097. }
  1098. }
  1099. if (currencyRates != null || currencyRates.Count > 0)
  1100. {
  1101. currencyRates = currencyRates.Distinct().ToList();
  1102. foreach (var item in currencyRates)
  1103. {
  1104. str += item;
  1105. }
  1106. }
  1107. }
  1108. return str;
  1109. }
  1110. /// <summary>
  1111. /// 团组汇率 币种 Item (来源:团组汇率)
  1112. /// 根据 团组Id And 业务类型(CTable)Id
  1113. /// api处理CTable = 285,默认返回CNY
  1114. /// </summary>
  1115. /// <param name="portType"></param>
  1116. /// <param name="diId"></param>
  1117. /// <param name="cTable"></param>
  1118. /// <returns></returns>
  1119. public static async Task<TeamRateModelGeneralView> PostGroupTeamRateByDiIdAndCTableId(int portType, int diId, int cTable)
  1120. {
  1121. TeamRateModelGeneralView _view = new TeamRateModelGeneralView();
  1122. _view = await _teamRateRep.PostGroupTeamRateByDiIdAndCTableId(portType, diId, cTable);
  1123. return _view;
  1124. }
  1125. /// <summary>
  1126. /// 汇率备注拆分
  1127. /// (美元(USD):7.2370|日元(JPY):0.0499|欧元(EUR):8.3000|英镑(GBP):9.1996|港币(HKD):0.9291)
  1128. /// </summary>
  1129. /// <param name="rateRemark"></param>
  1130. /// <returns></returns>
  1131. public static async Task<List<TeamRateDescAddCurrencyIdView>> SplitExchangeRate(this string rateRemark)
  1132. {
  1133. List<TeamRateDescAddCurrencyIdView> _view = new List<TeamRateDescAddCurrencyIdView>();
  1134. List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();
  1135. #region 获取所有币种
  1136. string sql = string.Format(@"select * from Sys_SetData where STid = {0} and isdel = 0", 66);
  1137. var DBdata = _setDataRep.GetListBySqlWithNolock(sql);
  1138. if (DBdata == null || DBdata.Count == 0)
  1139. {
  1140. return _view;
  1141. }
  1142. currencyDatas = DBdata.Select(x => new SetDataInfoView
  1143. {
  1144. Name = x.Name,
  1145. Id = x.Id,
  1146. Remark = x.Remark,
  1147. }).ToList();
  1148. #endregion
  1149. #region 拆分remark里的汇率
  1150. if (string.IsNullOrEmpty(rateRemark))
  1151. {
  1152. return _view;
  1153. }
  1154. if (rateRemark.Contains("|"))
  1155. {
  1156. string[] currencyArr = rateRemark.Split("|");
  1157. foreach (string currency in currencyArr)
  1158. {
  1159. string[] currency1 = currency.Split(":");
  1160. string[] currency2 = currency1[0].Split("(");
  1161. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  1162. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  1163. {
  1164. CurrencyId = currencyDatas.Find(it => it.Name == currencyCode).Id,
  1165. CurrencyCode = currencyCode,
  1166. CurrencyName = currency2[0],
  1167. Rate = decimal.Parse(currency1[1]),
  1168. };
  1169. _view.Add(rateDescView);
  1170. }
  1171. }
  1172. else
  1173. {
  1174. try
  1175. {
  1176. string[] currency1 = rateRemark.Split(":");
  1177. string[] currency2 = currency1[0].Split("(");
  1178. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  1179. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  1180. {
  1181. CurrencyId = currencyDatas.Find(it => it.Name == currencyCode).Id,
  1182. CurrencyCode = currencyCode,
  1183. CurrencyName = currency2[0],
  1184. Rate = decimal.Parse(currency1[1]),
  1185. };
  1186. _view.Add(rateDescView);
  1187. }
  1188. catch (Exception)
  1189. {
  1190. return _view;
  1191. }
  1192. }
  1193. #endregion
  1194. return _view;
  1195. }
  1196. #endregion
  1197. #region 汉字转换拼音
  1198. private static Dictionary<int, List<string>> GetTotalPingYinDictionary(string text)
  1199. {
  1200. var chs = text.ToCharArray();
  1201. //记录每个汉字的全拼
  1202. Dictionary<int, List<string>> totalPingYinList = new Dictionary<int, List<string>>();
  1203. for (int i = 0; i < chs.Length; i++)
  1204. {
  1205. var pinyinList = new List<string>();
  1206. //是否是有效的汉字
  1207. if (ChineseChar.IsValidChar(chs[i]))
  1208. {
  1209. ChineseChar cc = new ChineseChar(chs[i]);
  1210. pinyinList = cc.Pinyins.Where(p => !string.IsNullOrWhiteSpace(p)).ToList();
  1211. }
  1212. else
  1213. {
  1214. pinyinList.Add(chs[i].ToString());
  1215. }
  1216. //去除声调,转小写
  1217. pinyinList = pinyinList.ConvertAll(p => Regex.Replace(p, @"\d", "").ToLower());
  1218. //去重
  1219. pinyinList = pinyinList.Where(p => !string.IsNullOrWhiteSpace(p)).Distinct().ToList();
  1220. if (pinyinList.Any())
  1221. {
  1222. totalPingYinList[i] = pinyinList;
  1223. }
  1224. }
  1225. return totalPingYinList;
  1226. }
  1227. /// <summary>
  1228. /// 获取汉语拼音全拼
  1229. /// </summary>
  1230. /// <param name="text">The string.</param>
  1231. /// <returns></returns>
  1232. public static List<string> GetTotalPingYin(this string text)
  1233. {
  1234. var result = new List<string>();
  1235. foreach (var pys in GetTotalPingYinDictionary(text))
  1236. {
  1237. var items = pys.Value;
  1238. if (result.Count <= 0)
  1239. {
  1240. result = items;
  1241. }
  1242. else
  1243. {
  1244. //全拼循环匹配
  1245. var newTotalPingYinList = new List<string>();
  1246. foreach (var totalPingYin in result)
  1247. {
  1248. newTotalPingYinList.AddRange(items.Select(item => totalPingYin + item));
  1249. }
  1250. newTotalPingYinList = newTotalPingYinList.Distinct().ToList();
  1251. result = newTotalPingYinList;
  1252. }
  1253. }
  1254. return result;
  1255. }
  1256. /// <summary>
  1257. /// 获取中文第一个拼音
  1258. /// </summary>
  1259. /// <param name="text"></param>
  1260. /// <param name="isUp"></param>
  1261. /// <returns></returns>
  1262. public static string GetTotalPingYinFirst(this string text, bool isUp = true)
  1263. {
  1264. var returnstr = string.Empty;
  1265. var enResult = text.GetTotalPingYin();
  1266. if (enResult.Count == 0)
  1267. {
  1268. returnstr = text;
  1269. }
  1270. else if (isUp)
  1271. {
  1272. returnstr = enResult[0].ToUpper();
  1273. }
  1274. else
  1275. {
  1276. returnstr = enResult[0].ToLower();
  1277. }
  1278. return returnstr;
  1279. }
  1280. /// <summary>
  1281. /// 获取汉语拼音首字母
  1282. /// </summary>
  1283. /// <param name="text"></param>
  1284. /// <returns></returns>
  1285. public static List<string> GetFirstPingYin(this string text)
  1286. {
  1287. var result = new List<string>();
  1288. foreach (var pys in GetTotalPingYinDictionary(text))
  1289. {
  1290. var items = pys.Value;
  1291. if (result.Count <= 0)
  1292. {
  1293. result = items.ConvertAll(p => p.Substring(0, 1)).Distinct().ToList();
  1294. }
  1295. else
  1296. {
  1297. //首字母循环匹配
  1298. var newFirstPingYinList = new List<string>();
  1299. foreach (var firstPingYin in result)
  1300. {
  1301. newFirstPingYinList.AddRange(items.Select(item => firstPingYin + item.Substring(0, 1)));
  1302. }
  1303. newFirstPingYinList = newFirstPingYinList.Distinct().ToList();
  1304. result = newFirstPingYinList;
  1305. }
  1306. }
  1307. return result;
  1308. }
  1309. #endregion
  1310. #region 新客户资料表 操作记录
  1311. /// <summary>
  1312. /// 新客户资料表
  1313. /// 操作记录添加
  1314. /// </summary>
  1315. /// <param name="portType"></param>
  1316. /// <param name="operationEnum"></param>
  1317. /// <param name="userId"></param>
  1318. /// <param name="dataId"></param>
  1319. /// <param name="remark"></param>
  1320. /// <returns></returns>
  1321. public static async Task<bool> NewClientOperationRecord(int portType, OperationEnum operationEnum, int userId, int dataId, string remark)
  1322. {
  1323. Crm_TableOperationRecord _TableOperationRecord = new Crm_TableOperationRecord()
  1324. {
  1325. TableName = "Crm_NewClientData",
  1326. PortType = portType,
  1327. OperationItem = operationEnum,
  1328. DataId = dataId,
  1329. CreateUserId = userId,
  1330. CreateTime = DateTime.Now,
  1331. Remark = remark
  1332. };
  1333. bool add = await _tableOperationRecordRep._Add(_TableOperationRecord);
  1334. if (add) return false;
  1335. return false;
  1336. }
  1337. #endregion
  1338. #region 金额转大写
  1339. /// <summary>
  1340. /// 金额转换为大写数字
  1341. /// <para>1、支持的最大数字:999999999999.99(玖仟玖佰玖拾玖亿玖仟玖佰玖拾玖万玖仟玖佰玖拾玖元玖角玖分)</para>
  1342. /// <para>2、小数点后最多支持两位</para>
  1343. /// </summary>
  1344. /// <param name="num">数值</param>
  1345. /// <returns></returns>
  1346. public static string ConvertCNYUpper(this decimal num)
  1347. {
  1348. if (num == 0)
  1349. {
  1350. return "零元";
  1351. }
  1352. // 解决327000000转换后缺少单位万的问题
  1353. return ConvertToChinese(num);
  1354. }
  1355. #region 实例
  1356. /// <summary>
  1357. /// 要转换的数字
  1358. /// </summary>
  1359. private static decimal j;
  1360. /// <summary>
  1361. ///
  1362. /// </summary>
  1363. private static string[] NumChineseCharacter = new string[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
  1364. /// <summary>
  1365. /// 判断输入的数字是否大于double类型
  1366. /// </summary>
  1367. private static bool IsNumber
  1368. {
  1369. get
  1370. {
  1371. if (j > decimal.MaxValue || j <= 0)
  1372. return false;
  1373. else
  1374. return true;
  1375. }
  1376. }
  1377. /// <summary>
  1378. /// 数字转换成大写汉字主函数
  1379. /// </summary>
  1380. /// <returns>返回转换后的大写汉字</returns>
  1381. public static string ConvertToChinese(decimal m)
  1382. {
  1383. j = m;
  1384. string bb = "";
  1385. if (IsNumber)
  1386. {
  1387. string str = j.ToString();
  1388. string[] Num = str.Split('.');
  1389. if (Num.Length == 1)
  1390. {
  1391. bb = NumberString(Num[0]) + "元整";
  1392. bb = bb.Replace("零零", "零");
  1393. }
  1394. else
  1395. {
  1396. bb = NumberString(Num[0]) + "元";
  1397. bb += FloatString(Num[1]);
  1398. bb = bb.Replace("零零", "零");
  1399. }
  1400. }
  1401. else
  1402. {
  1403. throw new FormatException("你输入的数字格式不正确或不是数字!");
  1404. }
  1405. return bb;
  1406. }
  1407. /// <summary>
  1408. /// 小数位转换只支持两位的小数
  1409. /// </summary>
  1410. /// <param name="Num">转换的小数</param>
  1411. /// <returns>小数转换成汉字</returns>
  1412. private static string FloatString(string Num)
  1413. {
  1414. string cc = "";
  1415. if (Num.Length > 2)
  1416. {
  1417. throw new FormatException("小数位数过多.");
  1418. }
  1419. else
  1420. {
  1421. string bb = ConvertString(Num);
  1422. int len = bb.IndexOf("零");
  1423. if (len != 0)
  1424. {
  1425. bb = bb.Replace("零", "");
  1426. if (bb.Length == 1)
  1427. {
  1428. cc = bb.Substring(0, 1) + "角";
  1429. }
  1430. else
  1431. {
  1432. cc = bb.Substring(0, 1) + "角";
  1433. cc += bb.Substring(1, 1) + "分";
  1434. }
  1435. }
  1436. else
  1437. cc = bb + "分";
  1438. }
  1439. return cc;
  1440. }
  1441. /// <summary>
  1442. /// 判断数字位数以进行拆分转换
  1443. /// </summary>
  1444. /// <param name="Num">要进行拆分的数字</param>
  1445. /// <returns>转换成的汉字</returns>
  1446. private static string NumberString(string Num)
  1447. {
  1448. string bb = "";
  1449. if (Num.Length <= 4)
  1450. {
  1451. bb = Convert4(Num);
  1452. }
  1453. else if (Num.Length > 4 && Num.Length <= 8)
  1454. {
  1455. bb = Convert4(Num.Substring(0, Num.Length - 4)) + "万";
  1456. bb += Convert4(Num.Substring(Num.Length - 4, 4));
  1457. }
  1458. else if (Num.Length > 8 && Num.Length <= 12)
  1459. {
  1460. bb = Convert4(Num.Substring(0, Num.Length - 8)) + "亿";
  1461. if (Convert4(Num.Substring(Num.Length - 8, 4)) == "")
  1462. if (Convert4(Num.Substring(Num.Length - 4, 4)) != "")
  1463. bb += "零";
  1464. else
  1465. bb += "";
  1466. else
  1467. bb += Convert4(Num.Substring(Num.Length - 8, 4)) + "万";
  1468. bb += Convert4(Num.Substring(Num.Length - 4, 4));
  1469. }
  1470. else
  1471. {
  1472. throw new Exception("整数部分最多支持12位");
  1473. }
  1474. return bb;
  1475. }
  1476. /// <summary>
  1477. /// 四位数字的转换
  1478. /// </summary>
  1479. /// <param name="Num">准备转换的四位数字</param>
  1480. /// <returns>转换以后的汉字</returns>
  1481. private static string Convert4(string Num)
  1482. {
  1483. string bb = "";
  1484. if (Num.Length == 1)
  1485. {
  1486. bb = ConvertString(Num);
  1487. }
  1488. else if (Num.Length == 2)
  1489. {
  1490. bb = ConvertString(Num);
  1491. bb = Convert2(bb);
  1492. }
  1493. else if (Num.Length == 3)
  1494. {
  1495. bb = ConvertString(Num);
  1496. bb = Convert3(bb);
  1497. }
  1498. else
  1499. {
  1500. bb = ConvertString(Num);
  1501. string cc = "";
  1502. string len = bb.Substring(0, 4);
  1503. if (len != "零零零零")
  1504. {
  1505. len = bb.Substring(0, 3);
  1506. if (len != "零零零")
  1507. {
  1508. bb = bb.Replace("零零零", "");
  1509. if (bb.Length == 1)
  1510. {
  1511. bb = bb.Substring(0, 1) + "仟";
  1512. }
  1513. else
  1514. {
  1515. if (bb.Substring(0, 1) != "零" && bb.Substring(0, 2) != "零")
  1516. cc = bb.Substring(0, 1) + "仟";
  1517. else
  1518. cc = bb.Substring(0, 1);
  1519. bb = cc + Convert3(bb.Substring(1, 3));
  1520. }
  1521. }
  1522. else
  1523. {
  1524. bb = bb.Replace("零零零", "零");
  1525. }
  1526. }
  1527. else
  1528. {
  1529. bb = bb.Replace("零零零零", "");
  1530. }
  1531. }
  1532. return bb;
  1533. }
  1534. /// <summary>
  1535. /// 将数字转换成汉字
  1536. /// </summary>
  1537. /// <param name="Num">需要转换的数字</param>
  1538. /// <returns>转换后的汉字</returns>
  1539. private static string ConvertString(string Num)
  1540. {
  1541. string bb = "";
  1542. for (int i = 0; i < Num.Length; i++)
  1543. {
  1544. bb += NumChineseCharacter[int.Parse(Num.Substring(i, 1))];
  1545. }
  1546. return bb;
  1547. }
  1548. /// <summary>
  1549. /// 两位数字的转换
  1550. /// </summary>
  1551. /// <param name="Num">两位数字</param>
  1552. /// <returns>转换后的汉字</returns>
  1553. private static string Convert2(string Num)
  1554. {
  1555. string bb = ""; string cc = "";
  1556. string len = Num.Substring(0, 1);
  1557. if (len != "零")
  1558. {
  1559. bb = Num.Replace("零", "");
  1560. if (bb.Length == 1)
  1561. {
  1562. cc = bb.Substring(0, 1) + "拾";
  1563. }
  1564. else
  1565. {
  1566. cc = bb.Substring(0, 1) + "拾";
  1567. cc += bb.Substring(1, 1);
  1568. }
  1569. }
  1570. else
  1571. cc = Num;
  1572. return cc;
  1573. }
  1574. /// <summary>
  1575. /// 三位数字的转换
  1576. /// </summary>
  1577. /// <param name="Num">三位数字</param>
  1578. /// <returns>转换后的汉字</returns>
  1579. private static string Convert3(string Num)
  1580. {
  1581. string bb = ""; string cc = "";
  1582. string len = Num.Substring(0, 2);
  1583. if (len != "零零")
  1584. {
  1585. bb = Num.Replace("零零", "");
  1586. if (bb.Length == 1)
  1587. {
  1588. bb = bb.Substring(0, 1) + "佰";
  1589. }
  1590. else
  1591. {
  1592. if (bb.Substring(0, 1) != "零")
  1593. cc = bb.Substring(0, 1) + "佰";
  1594. else
  1595. cc = bb.Substring(0, 1);
  1596. bb = cc + Convert2(bb.Substring(1, 2));
  1597. }
  1598. }
  1599. else
  1600. {
  1601. bb = Num.Replace("零零", "零");
  1602. }
  1603. return bb;
  1604. }
  1605. #endregion
  1606. #endregion
  1607. #region 数字验证
  1608. /// <summary>
  1609. /// 验证数字字符串
  1610. /// </summary>
  1611. /// <param name="numStr"></param>
  1612. /// <returns></returns>
  1613. public static bool IsNumeric(this string numStr)
  1614. {
  1615. bool isNumeric = Regex.IsMatch(numStr, @"^\d+$");
  1616. if (isNumeric)
  1617. {
  1618. return true;
  1619. }
  1620. return false;
  1621. }
  1622. #endregion
  1623. #region 日期 格式转换
  1624. /// <summary>
  1625. /// 验证日期字符串
  1626. /// </summary>
  1627. /// <param name="str"></param>
  1628. /// <returns></returns>
  1629. public static string ConvertToDatetime(this string str)
  1630. {
  1631. if (!string.IsNullOrEmpty(str))
  1632. {
  1633. DateTime currentDate = Convert.ToDateTime(str);
  1634. return $"{currentDate.Year}年{currentDate.Month}月{currentDate.Day}日";
  1635. }
  1636. return "";
  1637. }
  1638. #endregion
  1639. #region 月份/季度
  1640. /// <summary>
  1641. /// 获取月份对应的起始天数
  1642. /// </summary>
  1643. /// <param name="year"></param>
  1644. /// <returns></returns>
  1645. public static List<MonthInfo> GetMonthInfos(int year)
  1646. {
  1647. List<MonthInfo> months = new List<MonthInfo>();
  1648. if (year > 1)
  1649. {
  1650. for (int i = 1; i < 13; i++)
  1651. {
  1652. months.Add(new MonthInfo()
  1653. {
  1654. Month = i,
  1655. Days = new DaysInfo() { BeginDays = 1, EndDays = DateTime.DaysInMonth(year, i) }
  1656. });
  1657. }
  1658. }
  1659. return months;
  1660. }
  1661. /// <summary>
  1662. /// 获取季度对应的起始天数
  1663. /// </summary>
  1664. /// <param name="year"></param>
  1665. /// <returns></returns>
  1666. public static List<MonthInfo> GetQuarter(int year)
  1667. {
  1668. List<MonthInfo> months = new List<MonthInfo>();
  1669. months.Add(new MonthInfo() { Month = 1, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //1.1 - 3.31
  1670. months.Add(new MonthInfo() { Month = 2, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //4.1 - 6.30
  1671. months.Add(new MonthInfo() { Month = 3, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //7.1 - 9.31
  1672. months.Add(new MonthInfo() { Month = 4, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //10.1 - 12.31
  1673. return months;
  1674. }
  1675. public class MonthInfo
  1676. {
  1677. public int Month { get; set; }
  1678. public DaysInfo Days { get; set; }
  1679. }
  1680. public class DaysInfo
  1681. {
  1682. public int BeginDays { get; set; }
  1683. public int EndDays { get; set; }
  1684. }
  1685. #endregion
  1686. #region op行程单,黑屏幕代码
  1687. public static string GetCountryStandingTime(int diId)
  1688. {
  1689. DataTable datas = GetTableByBlackCode(diId);
  1690. string countryStr = "[黑屏代码未录入].";
  1691. if (datas.Rows.Count > 0)
  1692. {
  1693. var airDatas = from row in datas.AsEnumerable()
  1694. select new
  1695. {
  1696. Three = row.Field<string>("Three"),
  1697. Day = row.Field<string>("Day"),
  1698. ArrivedDate = row.Field<string>("ArrivedDate"),
  1699. };
  1700. //三字码信息
  1701. List<Res_ThreeCode> listcode = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToList();
  1702. //string countryStr = "";
  1703. int index = 0;
  1704. List<string> cityCodes = new List<string>();
  1705. //去掉开始和结束城市
  1706. foreach (var row in airDatas)
  1707. {
  1708. if (!string.IsNullOrEmpty(row.Three))
  1709. {
  1710. if (index == 0) cityCodes.Add(row.Three.Substring(3, 3)); //到达国家
  1711. else if (airDatas.Count() - 1 == index) cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
  1712. else cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
  1713. }
  1714. index++;
  1715. }
  1716. cityCodes = cityCodes.Distinct().ToList();
  1717. if (cityCodes.Count > 0) countryStr = "";
  1718. foreach (var item in cityCodes)
  1719. {
  1720. var airData = airDatas.Where(it => it.Three.Contains(item)).ToList();
  1721. string country = listcode.Find(it => it.Three.Equals(item))?.Country ?? "Unknown";
  1722. if (country.Equals("中国"))
  1723. {
  1724. country = listcode.Find(it => it.Three.Equals(item))?.City ?? "Unknown";
  1725. }
  1726. //int days = 0;
  1727. if (airData.Count == 2)
  1728. {
  1729. DateTime arr_dt = Convert.ToDateTime(airData[0].ArrivedDate); //抵达时间
  1730. DateTime dep_dt = Convert.ToDateTime(airData[1].Day); //离开时间
  1731. //days = (dep_dt - arr_dt).Days;
  1732. //countryStr += $@"{country}停留{days}日、";
  1733. countryStr += $@"{country}停留 日、";
  1734. }
  1735. }
  1736. if (countryStr.Length > 0) countryStr = countryStr.Substring(0, countryStr.Length - 1);
  1737. }
  1738. return countryStr;
  1739. }
  1740. /// <summary>
  1741. ///根据机票黑屏代码整理DataTable
  1742. /// </summary>
  1743. /// <param name="diid"></param>
  1744. /// <returns></returns>
  1745. public static DataTable GetTableByBlackCode1(int diid)
  1746. {
  1747. //黑屏代码信息
  1748. List<Air_TicketBlackCode> listcode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  1749. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  1750. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  1751. DataTable dt = new DataTable();
  1752. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  1753. dt.Columns.Add("Date", typeof(string));//起飞日期
  1754. dt.Columns.Add("Three", typeof(string));//三字码
  1755. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  1756. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  1757. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  1758. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  1759. dt.Columns.Add("AirModel", typeof(string)); //机型
  1760. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  1761. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  1762. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  1763. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  1764. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  1765. //判断是否录入黑屏代码
  1766. if (listcode.Count == 0 || listcode == null)
  1767. {
  1768. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  1769. }
  1770. else
  1771. {
  1772. //读取单段黑屏代码
  1773. for (int i = 0; i < listcode.Count; i++)
  1774. {
  1775. //去除序号
  1776. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  1777. //去除多余空格,方法一Linq扩展方法
  1778. CodeList = CodeList.Where(str => str != "").ToArray();
  1779. CodeList = CodeList.Where(str => str != " ").ToArray();
  1780. //年
  1781. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  1782. //读取单条黑屏代码
  1783. for (int j = 0; j < CodeList.Length; j++)
  1784. {
  1785. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  1786. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  1787. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1788. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  1789. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1790. //去除多余空格
  1791. Info = Info.Where(str => str != "").ToArray();
  1792. Info = Info.Where(str => str != " ").ToArray();
  1793. //判断黑屏代码是否正确拆分; 理应拆成9段
  1794. if (Info.Length < 9)
  1795. {
  1796. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  1797. }
  1798. else
  1799. {
  1800. try
  1801. {
  1802. //月
  1803. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  1804. //日
  1805. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  1806. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  1807. if (j > 0)
  1808. {
  1809. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  1810. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1811. Temp = Temp.Where(str => str != "").ToArray();
  1812. Temp = Temp.Where(str => str != " ").ToArray();
  1813. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  1814. // 如果相邻月份之差小于0,则证明次一条年份需+1
  1815. if (month - monthTemp < 0)
  1816. {
  1817. year = year + 1;
  1818. }
  1819. //如果相邻代码三字码不顶真,提醒
  1820. string FootThree = Temp[2].Substring(3, 3);
  1821. string HeadThree = Info[2].Substring(0, 3);
  1822. if (FootThree != HeadThree)
  1823. {
  1824. //DelegationInfoService s = new DelegationInfoService();
  1825. //UsersService us = new UsersService();
  1826. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  1827. //77 行程
  1828. List<Grp_GroupsTaskAssignment> list2 = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  1829. foreach (var temp in list2)
  1830. {
  1831. //if (temp.UId != 21)
  1832. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  1833. // "黑屏代码提醒",
  1834. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  1835. }
  1836. //85 机票预订
  1837. List<Grp_GroupsTaskAssignment> list6 = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  1838. foreach (var temp in list6)
  1839. {
  1840. //if (temp.UId != 21)
  1841. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  1842. // "黑屏代码提醒",
  1843. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  1844. }
  1845. }
  1846. }
  1847. #endregion
  1848. #region 判断到达日期是否需要加1
  1849. if (Info[4].Contains("+"))
  1850. {
  1851. //日期+1
  1852. day = day + 1;
  1853. //判断是否进入下一月
  1854. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  1855. {
  1856. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  1857. month = month + 1;
  1858. //判断是否进入下一年
  1859. if (month > 12)
  1860. {
  1861. month = month - 12;
  1862. year = year + 1;
  1863. }
  1864. }
  1865. //月份整理格式
  1866. string monthTemp = month.ToString();
  1867. if (month < 10)
  1868. {
  1869. monthTemp = "0" + monthTemp;
  1870. }
  1871. //日期整理格式
  1872. string daytemp = day.ToString();
  1873. if (day < 10)
  1874. {
  1875. daytemp = "0" + daytemp;
  1876. }
  1877. string temp = Info[4].Split('+')[0];
  1878. //添加起飞数据
  1879. dt.Rows.Add(Info[0],
  1880. Info[1],
  1881. Info[2],
  1882. Info[3],
  1883. temp,
  1884. Info[5],
  1885. Info[6],
  1886. Info[7],
  1887. Info[8],
  1888. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  1889. year + "-" + monthTemp + "-" + daytemp,
  1890. "",
  1891. "0");
  1892. //加1天,添加到达数据
  1893. dt.Rows.Add(Info[0],
  1894. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  1895. Info[2],
  1896. Info[3],
  1897. temp,
  1898. Info[5],
  1899. Info[6],
  1900. Info[7],
  1901. Info[8],
  1902. year + "-" + monthTemp + "-" + daytemp,
  1903. year + "-" + monthTemp + "-" + daytemp,
  1904. "",
  1905. "1");
  1906. }
  1907. else
  1908. {
  1909. //月份整理格式
  1910. string monthTemp = month.ToString();
  1911. if (month < 10)
  1912. {
  1913. monthTemp = "0" + monthTemp;
  1914. }
  1915. //日期整理格式
  1916. string daytemp = day.ToString();
  1917. if (day < 10)
  1918. {
  1919. daytemp = "0" + daytemp;
  1920. }
  1921. dt.Rows.Add(Info[0],
  1922. Info[1],
  1923. Info[2],
  1924. Info[3],
  1925. Info[4],
  1926. Info[5],
  1927. Info[6],
  1928. Info[7],
  1929. Info[8],
  1930. year + "-" + monthTemp + "-" + daytemp,
  1931. year + "-" + monthTemp + "-" + daytemp,
  1932. "",
  1933. "0");
  1934. }
  1935. #endregion
  1936. }
  1937. catch (Exception ex)
  1938. {
  1939. string exstr = ex.Message.ToString();
  1940. }
  1941. }
  1942. }
  1943. //排序
  1944. dt.DefaultView.Sort = "Day asc";
  1945. dt = dt.DefaultView.ToTable();
  1946. }
  1947. }
  1948. return dt;
  1949. }
  1950. private readonly static string[] excludeArr = new string[] { "[中转]", "[转机]", "[国内]" };
  1951. /// <summary>
  1952. ///根据机票黑屏代码整理DataTable
  1953. /// </summary>
  1954. /// <param name="diid"></param>
  1955. /// <returns></returns>
  1956. public static DataTable GetTableByBlackCode(int diid)
  1957. {
  1958. //黑屏代码信息
  1959. List<Air_TicketBlackCode> listcode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  1960. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  1961. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  1962. DataTable dt = new DataTable();
  1963. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  1964. dt.Columns.Add("Date", typeof(string));//起飞日期
  1965. dt.Columns.Add("Three", typeof(string));//三字码
  1966. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  1967. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  1968. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  1969. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  1970. dt.Columns.Add("AirModel", typeof(string)); //机型
  1971. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  1972. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  1973. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  1974. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  1975. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  1976. //添加转机标识
  1977. dt.Columns.Add("isTransitShipment", typeof(bool));
  1978. //判断是否录入黑屏代码
  1979. if (listcode.Count == 0 || listcode == null)
  1980. {
  1981. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null, false);
  1982. }
  1983. else
  1984. {
  1985. //读取单段黑屏代码
  1986. for (int i = 0; i < listcode.Count; i++)
  1987. {
  1988. //去除序号
  1989. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  1990. //去除多余空格,方法一Linq扩展方法
  1991. CodeList = CodeList.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  1992. //读取单条黑屏代码
  1993. for (int j = 0; j < CodeList.Length; j++)
  1994. {
  1995. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  1996. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  1997. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1998. //去除多余空格
  1999. Info = Info.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  2000. //判断黑屏代码是否正确拆分; 理应拆成9段
  2001. if (Info.TakeWhile((x) =>
  2002. {
  2003. return !excludeArr.Contains(x);
  2004. }).Count() != 9)
  2005. {
  2006. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null, false);
  2007. //MessageBoxEx.Show("第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误, 请联系机票同事核对");
  2008. return dt;
  2009. }
  2010. else
  2011. {
  2012. try
  2013. {
  2014. var monthEn = Info[1].Substring(4, 3);
  2015. //月
  2016. int month = Convert.ToInt32(GetLonger(monthEn));
  2017. //日
  2018. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  2019. var time = new DateTime(DateTime.Now.Year, month, day); //
  2020. var isExist = Info.Contains("[中转]");
  2021. //dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  2022. //dt.Columns.Add("Date", typeof(string));//起飞日期
  2023. //dt.Columns.Add("Three", typeof(string));//三字码
  2024. //dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  2025. //dt.Columns.Add("EndTime", typeof(string));//到达时刻
  2026. //dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  2027. //dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  2028. //dt.Columns.Add("AirModel", typeof(string)); //机型
  2029. //dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  2030. //dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  2031. //dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  2032. //dt.Columns.Add("Error", typeof(string));//整理的到达日期
  2033. //dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  2034. dt.Rows.Add(Info[0],
  2035. Info[1],
  2036. Info[2],
  2037. Info[3],
  2038. Info[4],
  2039. Info[5],
  2040. Info[6],
  2041. Info[7],
  2042. Info[8],
  2043. time.ToString("yyyy-MM-dd"),
  2044. time.ToString("yyyy-MM-dd"),
  2045. "",
  2046. "0",
  2047. isExist
  2048. );
  2049. }
  2050. catch (Exception ex)
  2051. {
  2052. string exstr = ex.Message.ToString();
  2053. }
  2054. }
  2055. }
  2056. //排序
  2057. dt.DefaultView.Sort = "Day asc";
  2058. dt = dt.DefaultView.ToTable();
  2059. }
  2060. }
  2061. return dt;
  2062. }
  2063. /// <summary>
  2064. ///根据黑屏代码整理DataTable
  2065. /// </summary>
  2066. /// <param name="blackCode"></param>
  2067. /// <returns></returns>
  2068. public static DataTable GetTableByBlackCodeBySingle(Air_TicketBlackCode blackCode)
  2069. {
  2070. DataTable dt = new DataTable();
  2071. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  2072. dt.Columns.Add("Date", typeof(string));//起飞日期
  2073. dt.Columns.Add("Three", typeof(string));//三字码
  2074. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  2075. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  2076. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  2077. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  2078. dt.Columns.Add("AirModel", typeof(string)); //机型
  2079. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  2080. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  2081. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  2082. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  2083. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  2084. //添加转机标识
  2085. dt.Columns.Add("isTransitShipment", typeof(bool));
  2086. //添加国内段标识
  2087. dt.Columns.Add("isDomesticSection", typeof(bool));
  2088. //判断是否录入黑屏代码
  2089. if (blackCode == null)
  2090. {
  2091. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null, false, false);
  2092. }
  2093. else
  2094. {
  2095. var listcode = new List<Air_TicketBlackCode> { blackCode };
  2096. //读取单段黑屏代码
  2097. for (int i = 0; i < listcode.Count; i++)
  2098. {
  2099. //去除序号
  2100. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  2101. //去除多余空格,方法一Linq扩展方法
  2102. CodeList = CodeList.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  2103. //读取单条黑屏代码
  2104. for (int j = 0; j < CodeList.Length; j++)
  2105. {
  2106. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  2107. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  2108. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2109. //去除多余空格
  2110. Info = Info.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  2111. //判断黑屏代码是否正确拆分; 理应拆成9段
  2112. if (Info.TakeWhile((x) =>
  2113. {
  2114. return !excludeArr.Contains(x);
  2115. }).Count() != 9)
  2116. {
  2117. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null, false, false);
  2118. //MessageBoxEx.Show("第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误, 请联系机票同事核对");
  2119. return dt;
  2120. }
  2121. else
  2122. {
  2123. try
  2124. {
  2125. var monthEn = Info[1].Substring(4, 3);
  2126. //月
  2127. int month = Convert.ToInt32(GetLonger(monthEn));
  2128. //日
  2129. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  2130. var time = new DateTime(DateTime.Now.Year, month, day); //
  2131. var isExist = Info.Contains("[中转]");
  2132. if (!isExist)
  2133. {
  2134. isExist = Info.Contains("[转机]");
  2135. }
  2136. var isDomesticSection = Info.Contains("[国内]");
  2137. if (isDomesticSection)
  2138. {
  2139. continue;
  2140. }
  2141. dt.Rows.Add(Info[0],
  2142. Info[1],
  2143. Info[2],
  2144. Info[3],
  2145. Info[4],
  2146. Info[5],
  2147. Info[6],
  2148. Info[7],
  2149. Info[8],
  2150. time.ToString("yyyy-MM-dd"),
  2151. time.ToString("yyyy-MM-dd"),
  2152. "",
  2153. ExtractNumberAfterPlus(Info[4]),
  2154. isExist,
  2155. isDomesticSection
  2156. );
  2157. }
  2158. catch (Exception ex)
  2159. {
  2160. string exstr = ex.Message.ToString();
  2161. }
  2162. }
  2163. }
  2164. //排序
  2165. dt.DefaultView.Sort = "Day asc";
  2166. dt = dt.DefaultView.ToTable();
  2167. }
  2168. }
  2169. return dt;
  2170. }
  2171. private static int ExtractNumberAfterPlus(string input)
  2172. {
  2173. int value = 0;
  2174. if (string.IsNullOrEmpty(input))
  2175. {
  2176. return value;
  2177. }
  2178. string pattern = @"\+\d+"; // 匹配“+”及其后的数字
  2179. Match match = Regex.Match(input, pattern);
  2180. if (match.Success)
  2181. {
  2182. int.TryParse(match.Value.Substring(1), out value); // 去掉“+”符号,只保留数字部分
  2183. }
  2184. return value;
  2185. }
  2186. /// <summary>
  2187. /// 根据星期,月份的缩写,转换成数字或者全称
  2188. /// 根据币种中文名称返回币种代码
  2189. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  2190. /// 20210903贾文滔
  2191. /// </summary>
  2192. /// <param name="temp"></param>
  2193. /// <returns></returns>
  2194. public static string GetLonger(string temp)
  2195. {
  2196. string str = "";
  2197. switch (temp.ToUpper())
  2198. {
  2199. case "美元":
  2200. str = "USD";
  2201. break;
  2202. case "日元":
  2203. str = "JPY";
  2204. break;
  2205. case "英镑":
  2206. str = "GBP";
  2207. break;
  2208. case "欧元":
  2209. str = "EUR";
  2210. break;
  2211. case "港币":
  2212. str = "HKD";
  2213. break;
  2214. case "MO":
  2215. str = "星期一";
  2216. break;
  2217. case "TU":
  2218. str = "星期二";
  2219. break;
  2220. case "WE":
  2221. str = "星期三";
  2222. break;
  2223. case "TH":
  2224. str = "星期四";
  2225. break;
  2226. case "FR":
  2227. str = "星期五";
  2228. break;
  2229. case "SA":
  2230. str = "星期六";
  2231. break;
  2232. case "SU":
  2233. str = "星期天";
  2234. break;
  2235. case "JAN":
  2236. str = "01";
  2237. break;
  2238. case "FEB":
  2239. str = "02";
  2240. break;
  2241. case "MAR":
  2242. str = "03";
  2243. break;
  2244. case "APR":
  2245. str = "04";
  2246. break;
  2247. case "MAY":
  2248. str = "05";
  2249. break;
  2250. case "JUN":
  2251. str = "06";
  2252. break;
  2253. case "JUL":
  2254. str = "07";
  2255. break;
  2256. case "AUG":
  2257. str = "08";
  2258. break;
  2259. case "SEP":
  2260. str = "09";
  2261. break;
  2262. case "OCT":
  2263. str = "10";
  2264. break;
  2265. case "NOV":
  2266. str = "11";
  2267. break;
  2268. case "DEC":
  2269. str = "12";
  2270. break;
  2271. case "MONDAY":
  2272. str = "星期一";
  2273. break;
  2274. case "TUESDAY":
  2275. str = "星期二";
  2276. break;
  2277. case "WEDNESDAY":
  2278. str = "星期三";
  2279. break;
  2280. case "THURSDAY":
  2281. str = "星期四";
  2282. break;
  2283. case "FRIDAY":
  2284. str = "星期五";
  2285. break;
  2286. case "SATURDAY":
  2287. str = "星期六";
  2288. break;
  2289. case "SUNDAY":
  2290. str = "星期日";
  2291. break;
  2292. case "01":
  2293. str = "JAN";
  2294. break;
  2295. case "02":
  2296. str = "FEB";
  2297. break;
  2298. case "03":
  2299. str = "MAR";
  2300. break;
  2301. case "04":
  2302. str = "APR";
  2303. break;
  2304. case "05":
  2305. str = "MAY";
  2306. break;
  2307. case "06":
  2308. str = "JUN";
  2309. break;
  2310. case "07":
  2311. str = "JUL";
  2312. break;
  2313. case "08":
  2314. str = "AUG";
  2315. break;
  2316. case "09":
  2317. str = "SEP";
  2318. break;
  2319. case "10":
  2320. str = "OCT";
  2321. break;
  2322. case "11":
  2323. str = "NOV";
  2324. break;
  2325. case "12":
  2326. str = "DEC";
  2327. break;
  2328. case "2":
  2329. str = "空客A";
  2330. break;
  2331. case "3":
  2332. str = "空客A";
  2333. break;
  2334. case "7":
  2335. str = "波音";
  2336. break;
  2337. }
  2338. return str;
  2339. }
  2340. /// <summary>
  2341. /// 根据月份返回天数
  2342. /// </summary>
  2343. /// <param name="Month"></param>
  2344. /// <param name="year"></param>
  2345. /// <returns></returns>
  2346. public static string GetDaysByMonth(string Month, int year)
  2347. {
  2348. string str = "";
  2349. //判断是否是闰年
  2350. if (DateTime.IsLeapYear(year) == false)
  2351. {
  2352. switch (Month.ToUpper())
  2353. {
  2354. case "JAN":
  2355. str = "31";
  2356. break;
  2357. case "FEB":
  2358. str = "28";
  2359. break;
  2360. case "MAR":
  2361. str = "31";
  2362. break;
  2363. case "APR":
  2364. str = "30";
  2365. break;
  2366. case "MAY":
  2367. str = "31";
  2368. break;
  2369. case "JUN":
  2370. str = "30";
  2371. break;
  2372. case "JUL":
  2373. str = "31";
  2374. break;
  2375. case "AUG":
  2376. str = "31";
  2377. break;
  2378. case "SEP":
  2379. str = "30";
  2380. break;
  2381. case "OCT":
  2382. str = "31";
  2383. break;
  2384. case "NOV":
  2385. str = "30";
  2386. break;
  2387. case "DEC":
  2388. str = "31";
  2389. break;
  2390. case "01":
  2391. str = "31";
  2392. break;
  2393. case "02":
  2394. str = "28";
  2395. break;
  2396. case "03":
  2397. str = "31";
  2398. break;
  2399. case "04":
  2400. str = "30";
  2401. break;
  2402. case "05":
  2403. str = "31";
  2404. break;
  2405. case "06":
  2406. str = "30";
  2407. break;
  2408. case "07":
  2409. str = "31";
  2410. break;
  2411. case "08":
  2412. str = "31";
  2413. break;
  2414. case "09":
  2415. str = "30";
  2416. break;
  2417. case "10":
  2418. str = "31";
  2419. break;
  2420. case "11":
  2421. str = "30";
  2422. break;
  2423. case "12":
  2424. str = "31";
  2425. break;
  2426. }
  2427. }
  2428. else
  2429. {
  2430. switch (Month.ToUpper())
  2431. {
  2432. case "JAN":
  2433. str = "31";
  2434. break;
  2435. case "FEB":
  2436. str = "29";
  2437. break;
  2438. case "MAR":
  2439. str = "31";
  2440. break;
  2441. case "APR":
  2442. str = "30";
  2443. break;
  2444. case "MAY":
  2445. str = "31";
  2446. break;
  2447. case "JUN":
  2448. str = "30";
  2449. break;
  2450. case "JUL":
  2451. str = "31";
  2452. break;
  2453. case "AUG":
  2454. str = "31";
  2455. break;
  2456. case "SEP":
  2457. str = "30";
  2458. break;
  2459. case "OCT":
  2460. str = "31";
  2461. break;
  2462. case "NOV":
  2463. str = "30";
  2464. break;
  2465. case "DEC":
  2466. str = "31";
  2467. break;
  2468. case "01":
  2469. str = "31";
  2470. break;
  2471. case "02":
  2472. str = "29";
  2473. break;
  2474. case "03":
  2475. str = "31";
  2476. break;
  2477. case "04":
  2478. str = "30";
  2479. break;
  2480. case "05":
  2481. str = "31";
  2482. break;
  2483. case "06":
  2484. str = "30";
  2485. break;
  2486. case "07":
  2487. str = "31";
  2488. break;
  2489. case "08":
  2490. str = "31";
  2491. break;
  2492. case "09":
  2493. str = "30";
  2494. break;
  2495. case "10":
  2496. str = "31";
  2497. break;
  2498. case "11":
  2499. str = "30";
  2500. break;
  2501. case "12":
  2502. str = "31";
  2503. break;
  2504. }
  2505. }
  2506. return str;
  2507. }
  2508. /// <summary>
  2509. /// op行程单 团组 城市路径
  2510. /// </summary>
  2511. /// <param name="diid">团组Id</param>
  2512. /// <param name="separator">分隔符</param>
  2513. /// <returns></returns>
  2514. public static string GetGroupCityLine(int diid, string separator)
  2515. {
  2516. string city = string.Empty;
  2517. var blackCode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  2518. if (blackCode.Count > 0)
  2519. {
  2520. var black = blackCode.First();
  2521. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2522. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2523. if (blackSp.Length > 0)
  2524. {
  2525. try
  2526. {
  2527. var cityArrCode = new List<string>(20);
  2528. foreach (var item in blackSp)
  2529. {
  2530. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2531. var IndexSelect = itemSp[2];
  2532. var cityArrCodeLength = cityArrCode.Count - 1;
  2533. var startCity = IndexSelect.Substring(0, 3);
  2534. if (cityArrCodeLength > 0)
  2535. {
  2536. var arrEndCity = cityArrCode[cityArrCodeLength];
  2537. if (arrEndCity != startCity)
  2538. {
  2539. cityArrCode.Add(startCity.ToUpper());
  2540. }
  2541. }
  2542. else
  2543. {
  2544. cityArrCode.Add(startCity.ToUpper());
  2545. }
  2546. var endCity = IndexSelect.Substring(3, 3);
  2547. cityArrCode.Add(endCity.ToUpper());
  2548. }
  2549. var cityThree = string.Empty;
  2550. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2551. cityThree = cityThree.TrimEnd(',');
  2552. if (string.IsNullOrWhiteSpace(cityThree))
  2553. {
  2554. throw new Exception("error");
  2555. }
  2556. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  2557. var cityArr = _dirRep._sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  2558. foreach (var item in cityArrCode)
  2559. {
  2560. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2561. if (find != null)
  2562. {
  2563. city += find.City + separator;
  2564. }
  2565. else
  2566. {
  2567. city += item + "[三字码未收录]" + separator;
  2568. }
  2569. }
  2570. city = city.TrimEnd(char.Parse(separator));
  2571. }
  2572. catch (Exception e)
  2573. {
  2574. city = "[黑屏代码格式不正确!]";
  2575. }
  2576. }
  2577. }
  2578. else city = "[未录入黑屏代码]";
  2579. return city;
  2580. }
  2581. /// <summary>
  2582. /// op行程单 团组 城市路径
  2583. /// </summary>
  2584. /// <param name="black">黑屏代码实例</param>
  2585. /// <param name="separator">分隔符</param>
  2586. /// <returns></returns>
  2587. public static string GetGroupCityLine(Air_TicketBlackCode black, string separator)
  2588. {
  2589. string city = string.Empty;
  2590. if (black != null)
  2591. {
  2592. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2593. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2594. if (blackSp.Length > 0)
  2595. {
  2596. try
  2597. {
  2598. var cityArrCode = new List<string>(20);
  2599. foreach (var item in blackSp)
  2600. {
  2601. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2602. var IndexSelect = itemSp[2];
  2603. var cityArrCodeLength = cityArrCode.Count - 1;
  2604. var startCity = IndexSelect.Substring(0, 3);
  2605. if (cityArrCodeLength > 0)
  2606. {
  2607. var arrEndCity = cityArrCode[cityArrCodeLength];
  2608. if (arrEndCity != startCity)
  2609. {
  2610. cityArrCode.Add(startCity.ToUpper());
  2611. }
  2612. }
  2613. else
  2614. {
  2615. cityArrCode.Add(startCity.ToUpper());
  2616. }
  2617. var endCity = IndexSelect.Substring(3, 3);
  2618. cityArrCode.Add(endCity.ToUpper());
  2619. }
  2620. var cityThree = string.Empty;
  2621. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2622. cityThree = cityThree.TrimEnd(',');
  2623. if (string.IsNullOrWhiteSpace(cityThree))
  2624. {
  2625. throw new Exception("error");
  2626. }
  2627. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  2628. var cityArr = _dirRep._sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  2629. foreach (var item in cityArrCode)
  2630. {
  2631. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2632. if (find != null)
  2633. {
  2634. city += find.City + separator;
  2635. }
  2636. else
  2637. {
  2638. city += item + "[三字码未收录]" + separator;
  2639. }
  2640. }
  2641. city = city.TrimEnd(char.Parse(separator));
  2642. }
  2643. catch (Exception e)
  2644. {
  2645. city = "[黑屏代码格式不正确!]";
  2646. }
  2647. }
  2648. }
  2649. else city = "[黑屏代码有误!]";
  2650. return city;
  2651. }
  2652. /// <summary>
  2653. /// op行程单 团组 城市路径
  2654. /// </summary>
  2655. /// <param name="diids">团组Id</param>
  2656. /// <param name="separator">分隔符</param>
  2657. /// <returns></returns>
  2658. public static Dictionary<int, string> GetGroupCityLineItem(List<int> diids, string separator)
  2659. {
  2660. Dictionary<int, string> dicCitys = new Dictionary<int, string>();
  2661. var cityCodes = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  2662. var blackCodes = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && diids.Contains(x.DiId)).ToList();
  2663. foreach (var diid in diids)
  2664. {
  2665. string city = string.Empty;
  2666. var blackCode = blackCodes.Where(it => it.DiId == diid).ToList();
  2667. if (blackCode.Count > 0)
  2668. {
  2669. var black = blackCode.First();
  2670. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2671. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2672. if (blackSp.Length > 0)
  2673. {
  2674. try
  2675. {
  2676. var cityArrCode = new List<string>(20);
  2677. foreach (var item in blackSp)
  2678. {
  2679. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2680. var IndexSelect = itemSp[2];
  2681. var cityArrCodeLength = cityArrCode.Count - 1;
  2682. var startCity = IndexSelect.Substring(0, 3);
  2683. if (cityArrCodeLength > 0)
  2684. {
  2685. var arrEndCity = cityArrCode[cityArrCodeLength];
  2686. if (arrEndCity != startCity)
  2687. {
  2688. cityArrCode.Add(startCity.ToUpper());
  2689. }
  2690. }
  2691. else
  2692. {
  2693. cityArrCode.Add(startCity.ToUpper());
  2694. }
  2695. var endCity = IndexSelect.Substring(3, 3);
  2696. cityArrCode.Add(endCity.ToUpper());
  2697. }
  2698. var cityThree = string.Empty;
  2699. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2700. cityThree = cityThree.TrimEnd(',');
  2701. if (string.IsNullOrWhiteSpace(cityThree))
  2702. {
  2703. throw new Exception("error");
  2704. }
  2705. var cityArr = cityCodes.Where(it => cityThree.Contains(it.Three.ToUpper())).ToList();
  2706. foreach (var item in cityArrCode)
  2707. {
  2708. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2709. if (find != null)
  2710. {
  2711. city += find.City + separator;
  2712. }
  2713. else
  2714. {
  2715. city += item + "[三字码未收录]" + separator;
  2716. }
  2717. }
  2718. city = city.TrimEnd(char.Parse(separator));
  2719. }
  2720. catch (Exception e)
  2721. {
  2722. city = "[黑屏代码格式不正确!]";
  2723. }
  2724. }
  2725. }
  2726. else city = "[未录入黑屏代码]";
  2727. dicCitys.Add(diid, city);
  2728. }
  2729. return dicCitys;
  2730. }
  2731. /// <summary>
  2732. /// op行程单相关团组信息 含途径城市
  2733. /// </summary>
  2734. /// <returns></returns>
  2735. public static async Task<List<MateOpGroupPageListView>> MateOpGroupPageListRedis()
  2736. {
  2737. List<MateOpGroupPageListView> _views = new List<MateOpGroupPageListView>();
  2738. string viewStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("MateOpGroupPageList");//string 取
  2739. if (!string.IsNullOrEmpty(viewStr))
  2740. {
  2741. _views = JsonConvert.DeserializeObject<List<MateOpGroupPageListView>>(viewStr);
  2742. }
  2743. else
  2744. {
  2745. string sql = string.Format($@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2746. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  2747. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  2748. JietuanOperator,IsSure,CreateTime,VisitCountry
  2749. From (
  2750. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  2751. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  2752. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  2753. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  2754. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.VisitCountry
  2755. From Grp_DelegationInfo gdi
  2756. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2757. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2758. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2759. Where gdi.IsDel = 0
  2760. ) temp");
  2761. _views = _dirRep._sqlSugar.SqlQueryable<MateOpGroupPageListView>(sql).ToList();
  2762. #region 处理所属部门
  2763. /*
  2764. * 1.sq 和 gyy 等显示 市场部
  2765. * 2.王鸽和主管及张总还有管理员号统一国交部
  2766. * 2-1. 4 管理员 ,21 张海麟
  2767. */
  2768. List<int> userIds = _views.Select(it => it.JietuanOperatorId).ToList();
  2769. List<int> userIds1 = new List<int>() { 4, 21 };
  2770. var UserDepDatas = _dirRep._sqlSugar.Queryable<Sys_Users>()
  2771. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  2772. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  2773. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  2774. .ToList();
  2775. #endregion
  2776. _views.ForEach(it =>
  2777. {
  2778. it.RouteCity = GetGroupCityLine(it.Id, @"/");
  2779. it.Department = UserDepDatas.Find(it1 => it.JietuanOperatorId == it1.UserId)?.DepName ?? "Unknown";
  2780. });
  2781. TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay;
  2782. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("MateOpGroupPageList", JsonConvert.SerializeObject(_views), ts);//string 存
  2783. }
  2784. return _views;
  2785. }
  2786. /// <summary>
  2787. /// 获取黑屏代码日期列表
  2788. /// </summary>
  2789. /// <param name="dt"></param>
  2790. /// <returns></returns>
  2791. public static List<string> GetTimeListByDataTable(DataTable dt)
  2792. {
  2793. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  2794. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  2795. List<string> timeList = new List<string>();
  2796. while (datestart <= dateend)
  2797. {
  2798. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  2799. datestart = datestart.AddDays(1);
  2800. }
  2801. return timeList;
  2802. }
  2803. const decimal conversion = 1.61M;
  2804. /// <summary>
  2805. /// 简要行程
  2806. /// </summary>
  2807. /// <param name="diid"></param>
  2808. /// <returns></returns>
  2809. public static Result GetBriefStroke(int diid)
  2810. {
  2811. DataTable resultTable = GetTableByBlackCode(diid);
  2812. if (resultTable == null)
  2813. {
  2814. return new Result { Code = -1, Msg = "黑屏代码有误或黑屏代码未录入" };
  2815. }
  2816. if (resultTable.Rows.Count == 0 || string.IsNullOrWhiteSpace(resultTable.Rows[0][1].ToString()))
  2817. {
  2818. string msg = string.Empty;
  2819. if (resultTable.Rows.Count > 0)
  2820. {
  2821. msg = resultTable.Rows[0]["Error"].ToString();
  2822. }
  2823. return new Result { Code = -1, Msg = $"黑屏代码有误;{msg}" };
  2824. }
  2825. var timeArr = GetTimeListByDataTable(resultTable);
  2826. var threeCodes = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList(); //三字码
  2827. var airCompanys = _dirRep._sqlSugar.Queryable<Res_AirCompany>().Where(it => it.IsDel == 0).ToList(); //航司公司
  2828. var obDatas = _dirRep._sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == diid).ToList(); //公务信息
  2829. var NewListTravel = new List<Grp_TravelList>();
  2830. var index = 0;
  2831. var stopCity = string.Empty;
  2832. foreach (var item in timeArr)
  2833. {
  2834. string trip = string.Empty;
  2835. string weekDay = string.Empty;
  2836. DateTime time = DateTime.Now;
  2837. if (DateTime.TryParse(item, out time))
  2838. {
  2839. weekDay = weekdays[(int)time.DayOfWeek];
  2840. }
  2841. else
  2842. {
  2843. weekDay = "日期格式不正确!";
  2844. }
  2845. var empty = "【未收入该三字码!请机票同事录入】";
  2846. var tabSelect = resultTable.Select(string.Format("Day = '{0}'", item));
  2847. var isMoreTraffic = false;
  2848. if (tabSelect.Length > 0)
  2849. {
  2850. isMoreTraffic = true;
  2851. var takeOffTime = DateTime.Parse(item);
  2852. var fallToTime = DateTime.Parse(item);
  2853. Res_ThreeCode start_Object = null;
  2854. Res_ThreeCode end_Object = null;
  2855. //bool isTrade = false;
  2856. //air 处理
  2857. foreach (var tabRow in tabSelect)
  2858. {
  2859. takeOffTime = DateTime.Parse(item);
  2860. fallToTime = DateTime.Parse(item);
  2861. var takeOff = tabRow["StartTime"].ToString();
  2862. var fallTo = tabRow["EndTime"].ToString();
  2863. takeOffTime = takeOffTime.AddHours(int.Parse(takeOff.Substring(0, 2)));
  2864. takeOffTime = takeOffTime.AddMinutes(int.Parse(takeOff.Substring(2, 2)));
  2865. fallToTime = fallToTime.AddHours(int.Parse(fallTo.Substring(0, 2)));
  2866. fallToTime = fallToTime.AddMinutes(int.Parse(fallTo.Substring(2, 2)));
  2867. var threeCode = tabRow["Three"].ToString();
  2868. var start = threeCode.Substring(0, 3);
  2869. var end = threeCode.Substring(3, 3);
  2870. stopCity = end;
  2871. start_Object = threeCodes.Find(x => x.Three.ToUpper() == start.ToUpper());
  2872. end_Object = threeCodes.Find(x => x.Three.ToUpper() == end.ToUpper());
  2873. if (start_Object == null)
  2874. {
  2875. start_Object = new Res_ThreeCode()
  2876. {
  2877. AirPort = empty,
  2878. AirPort_En = empty,
  2879. City = empty,
  2880. Country = empty,
  2881. Four = empty,
  2882. Three = empty,
  2883. };
  2884. }
  2885. if (end_Object == null)
  2886. {
  2887. end_Object = new Res_ThreeCode()
  2888. {
  2889. AirPort = empty,
  2890. AirPort_En = empty,
  2891. City = empty,
  2892. Country = empty,
  2893. Four = empty,
  2894. Three = empty,
  2895. };
  2896. }
  2897. //航班号
  2898. string flightcode = tabRow["Fliagtcode"].ToString();
  2899. trip += $"{takeOffTime.ToString("HH:mm")}—{fallToTime.ToString("HH:mm")} {start_Object.City}—{end_Object.City} 航班号:{flightcode}\r\n";
  2900. }
  2901. //var airArrive = fallToTime; //航班落地时间
  2902. time = fallToTime.AddHours(1.5); //出机场一个半小时
  2903. string Time = string.Empty;
  2904. string Distance = string.Empty;
  2905. int GetGoogleResult = 0;
  2906. int GetDistResult = 0;
  2907. JObject Result = null;
  2908. try
  2909. {
  2910. Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace(" ", "").Trim();
  2911. Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString().Replace(" ", "").Trim();
  2912. if (Time.Contains("hours"))
  2913. {
  2914. Time = Time.Replace("hours", "小时");
  2915. }
  2916. if (Time.Contains("hour"))
  2917. {
  2918. Time = Time.Replace("hour", "小时");
  2919. }
  2920. Time = Time.Replace("mins", "分钟");
  2921. if (Distance.Contains("mi"))
  2922. {
  2923. var distSp = Regex.Split(Distance, "mi");
  2924. if (distSp.Length > 0)
  2925. {
  2926. Distance = (decimal.Parse(distSp[0]) * conversion).ToString("#0.00") + " 公里";
  2927. }
  2928. }
  2929. if (Distance.Contains("km"))
  2930. {
  2931. Distance = Distance.Replace("km", "公里");
  2932. }
  2933. if (Time.Contains("小时"))
  2934. {
  2935. var xs = Regex.Split(Time, "小时");
  2936. var xsValue = int.Parse(xs[0]);
  2937. var fz = Regex.Split(xs[1], "分钟");
  2938. var fzValue = int.Parse(fz[0]);
  2939. GetGoogleResult = xsValue * 60;
  2940. GetGoogleResult += fzValue;
  2941. }
  2942. else if (Time.Contains("分钟"))
  2943. {
  2944. GetGoogleResult = int.Parse(Regex.Split(Time, "分钟")[0]);
  2945. }
  2946. if (Distance.Contains("公里"))
  2947. {
  2948. GetDistResult = (int)decimal.Parse(Regex.Split(Distance, "公里")[0]);
  2949. }
  2950. if (GetGoogleResult > 0 && GetGoogleResult % 5 != 0)
  2951. {
  2952. while (GetGoogleResult % 5 != 0)
  2953. {
  2954. GetGoogleResult++;
  2955. }
  2956. }
  2957. if (GetDistResult % 5 != 0 && GetDistResult > 0)
  2958. {
  2959. while (GetDistResult % 5 != 0)
  2960. {
  2961. GetDistResult++;
  2962. }
  2963. }
  2964. int H = (GetGoogleResult / 60);
  2965. int m = (GetGoogleResult % 60);
  2966. string TimeStr = string.Empty;
  2967. if (H != 0)
  2968. {
  2969. if (H < 10)
  2970. {
  2971. TimeStr += "0" + H + "小时";
  2972. }
  2973. else
  2974. {
  2975. TimeStr += H + "小时";
  2976. }
  2977. }
  2978. if (m < 10)
  2979. {
  2980. TimeStr += "0" + m + "分钟";
  2981. }
  2982. else
  2983. {
  2984. TimeStr += m + "分钟";
  2985. }
  2986. Time = TimeStr;
  2987. Distance = GetDistResult.ToString() + "公里";
  2988. }
  2989. catch (Exception ex)
  2990. {
  2991. Time = "未知!";
  2992. Distance = "未知!";
  2993. }
  2994. //trip += $"{time.ToString("HH:mm")} 搭乘专车前往市区({end_Object.AirPort} - {end_Object.City}市区 路程{Distance},耗时{Time})";
  2995. //trip += $"{time.ToString("HH:mm")} 搭乘专车前往市区({end_Object.AirPort} - {end_Object.City}市区)";
  2996. time = time.AddMinutes(GetGoogleResult); //到达市区时间
  2997. string tripDate = Convert.ToDateTime(item).ToString("M月d日");
  2998. if (index == timeArr.Count - 1)
  2999. {
  3000. NewListTravel.Add(new Grp_TravelList
  3001. {
  3002. CreateTime = DateTime.Now,
  3003. CreateUserId = 0,
  3004. Diid = diid,
  3005. Date = tripDate,
  3006. Trip = trip,
  3007. WeekDay = weekDay,
  3008. Days = index + 1,
  3009. Traffic_First = "飞机",
  3010. Traffic_Second = "汽车",
  3011. Diffgroup = 1,
  3012. Issel = 1,
  3013. IsDel = 0,
  3014. });
  3015. continue;
  3016. }
  3017. if (time.Day != fallToTime.Day) //超出一天
  3018. {
  3019. NewListTravel.Add(new Grp_TravelList
  3020. {
  3021. CreateTime = DateTime.Now,
  3022. CreateUserId = 0,
  3023. Diid = diid,
  3024. Date = tripDate,
  3025. Trip = trip,
  3026. WeekDay = weekDay,
  3027. Days = index + 1,
  3028. Traffic_First = "飞机",
  3029. Traffic_Second = "汽车",
  3030. Diffgroup = 1,
  3031. Issel = 1,
  3032. IsDel = 0,
  3033. });
  3034. continue;
  3035. }
  3036. var obInfo = obDatas.Find(it => Convert.ToDateTime(it.Date).ToString("M月d日").Equals(tripDate));
  3037. string obtime = "";
  3038. string obcontent = "";
  3039. if (obInfo != null)
  3040. {
  3041. obtime = obInfo.Time;
  3042. obcontent = $"拜访{obInfo.Client ?? "公务出访单位未录入"}{obInfo.Job ?? "公务出访联系人职务未录入"}{obInfo.Contact ?? "公务出访联系人职务未录入"}";
  3043. }
  3044. bool obTime_bool = DateTime.TryParse(obtime, out DateTime obTimeDt);
  3045. if (time.Hour < 9) // && (airArrive < new DateTime(airArrive.Year,airArrive.Month,airArrive.Day,6, 30, 0))
  3046. {
  3047. if (obTime_bool)
  3048. {
  3049. if (obTimeDt.Hour < 9)
  3050. {
  3051. trip += $"{obTimeDt.ToString("HH:mm")}—10:30 {obcontent};\r\n";
  3052. }
  3053. }
  3054. else
  3055. {
  3056. trip += "09:00—10:30 公务活动;\r\n";
  3057. }
  3058. }
  3059. else if (time.Hour < 10)
  3060. {
  3061. if (obTime_bool)
  3062. {
  3063. if (obTimeDt.Hour < 10)
  3064. {
  3065. trip += $"{obTimeDt.ToString("HH:mm")}—12:00 {obcontent};\r\n";
  3066. }
  3067. }
  3068. else
  3069. {
  3070. trip += "10:30—12:00 公务活动;\r\n";
  3071. }
  3072. }
  3073. if (time.Hour < 13)
  3074. {
  3075. //trip += $"\r\n{time.ToString("HH:mm")} 午餐于当地餐厅;";
  3076. }
  3077. if (time < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
  3078. {
  3079. if (obTime_bool)
  3080. {
  3081. if (obTimeDt < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
  3082. {
  3083. trip += $"{obTimeDt.ToString("HH:mm")}—16:00 {obcontent};\r\n";
  3084. }
  3085. }
  3086. else
  3087. {
  3088. trip += "14:00—16:00 公务活动;\r\n";
  3089. }
  3090. }
  3091. else if (time.Hour < 16)
  3092. {
  3093. if (obTime_bool)
  3094. {
  3095. if (obTimeDt.Hour < 16)
  3096. {
  3097. trip += $"{obTimeDt.ToString("HH:mm")}—17:30 {obcontent};\r\n";
  3098. }
  3099. }
  3100. else
  3101. {
  3102. trip += "16:00—17:30 公务活动;\r\n";
  3103. }
  3104. }
  3105. //if (time.Hour < 18)
  3106. //{
  3107. // trip += $"\r\n18:00 晚餐于当地餐厅;";
  3108. //}
  3109. //time = time.AddHours(1);
  3110. //trip += $"\r\n{time.ToString("HH:mm")} 搭乘专车前往酒店,抵达后办理入住;";
  3111. }
  3112. else
  3113. {
  3114. var end_Object = threeCodes.Find(x => x.Three.ToUpper() == stopCity.ToUpper());
  3115. if (end_Object == null)
  3116. {
  3117. end_Object = new Res_ThreeCode()
  3118. {
  3119. AirPort = empty,
  3120. AirPort_En = empty,
  3121. City = empty,
  3122. Country = empty,
  3123. Four = empty,
  3124. Three = empty,
  3125. };
  3126. }
  3127. //trip += $"{end_Object.City}\r\n";
  3128. // trip += @"08:00 早餐于酒店;
  3129. //09:00—10:30 公务活动;
  3130. //12:00 午餐于当地餐厅;
  3131. //14:00—16:00 公务活动;
  3132. //18:00 晚餐于当地餐厅;
  3133. //19:00 入住酒店休息;";
  3134. trip += "09:00—10:30 公务活动;\r\n14:00—16:00 公务活动;\r\n";
  3135. }
  3136. string[] traffic = new string[] { "飞机", "汽车" };
  3137. if (!isMoreTraffic)
  3138. {
  3139. traffic = new string[] { "汽车", "" };
  3140. }
  3141. NewListTravel.Add(new Grp_TravelList
  3142. {
  3143. CreateTime = DateTime.Now,
  3144. CreateUserId = 0,
  3145. Diid = diid,
  3146. Date = Convert.ToDateTime(item).ToString("M月d日"),
  3147. Trip = trip,
  3148. WeekDay = weekDay,
  3149. Days = index + 1,
  3150. Traffic_First = traffic[0],
  3151. Traffic_Second = traffic[1],
  3152. Diffgroup = 1,
  3153. Issel = 1,
  3154. IsDel = 0,
  3155. });
  3156. index++;
  3157. }
  3158. return new Result() { Code = 0, Msg = "获取成功!", Data = NewListTravel };
  3159. }
  3160. /// <summary>
  3161. /// 根据日期获取星期
  3162. /// </summary>
  3163. /// <param name="dtStr"></param>
  3164. /// <returns></returns>
  3165. public static string GetWeek(this string dtStr)
  3166. {
  3167. string week = "";
  3168. bool isDt = DateTime.TryParse(dtStr, out DateTime dt);
  3169. if (isDt)
  3170. {
  3171. week = weekdays[(int)dt.DayOfWeek];
  3172. }
  3173. return week;
  3174. }
  3175. #endregion
  3176. #region 计算国家城市当时时间
  3177. /// <summary>
  3178. /// 中文城市名称映射
  3179. /// </summary>
  3180. private static readonly Dictionary<string, string> _timeZoneCityMappings = new Dictionary<string, string>
  3181. {
  3182. {"Africa/Abidjan","非洲/阿比让"} ,
  3183. {"Africa/Accra","非洲/阿克拉"} ,
  3184. {"Africa/Addis_Ababa","非洲/亚的斯亚贝巴"} ,
  3185. {"Africa/Algiers","非洲/阿尔及尔"} ,
  3186. {"Africa/Asmara","非洲/阿斯马拉"} ,
  3187. {"Africa/Asmera","非洲/阿斯梅拉"} ,
  3188. {"Africa/Bamako","非洲/巴马科"} ,
  3189. {"Africa/Bangui","非洲/班吉"} ,
  3190. {"Africa/Banjul","非洲/班珠尔"} ,
  3191. {"Africa/Bissau","非洲/比绍"} ,
  3192. {"Africa/Blantyre","非洲/布兰太尔"} ,
  3193. {"Africa/Brazzaville","非洲/布拉柴维尔"} ,
  3194. {"Africa/Bujumbura","非洲/布琼布拉"} ,
  3195. {"Africa/Cairo","非洲/开罗"} ,
  3196. {"Africa/Casablanca","非洲/卡萨布兰卡"} ,
  3197. {"Africa/Ceuta","非洲/休达"} ,
  3198. {"Africa/Conakry","非洲/科纳克里"} ,
  3199. {"Africa/Dakar","非洲/达喀尔"} ,
  3200. {"Africa/Dar_es_Salaam","非洲/达累斯萨拉姆"} ,
  3201. {"Africa/Djibouti","非洲/吉布提"} ,
  3202. {"Africa/Douala","非洲/杜阿拉"} ,
  3203. {"Africa/El_Aaiun","非洲/阿尤恩"} ,
  3204. {"Africa/Freetown","非洲/弗里敦"} ,
  3205. {"Africa/Gaborone","非洲/哈博罗内"} ,
  3206. {"Africa/Harare","非洲/哈拉雷"} ,
  3207. {"Africa/Johannesburg","非洲/约翰内斯堡"} ,
  3208. {"Africa/Juba","非洲/朱巴"} ,
  3209. {"Africa/Kampala","非洲/坎帕拉"} ,
  3210. {"Africa/Khartoum","非洲/喀土穆"} ,
  3211. {"Africa/Kigali","非洲/基加利"} ,
  3212. {"Africa/Kinshasa","非洲/金沙萨"} ,
  3213. {"Africa/Lagos","非洲/拉各斯"} ,
  3214. {"Africa/Libreville","非洲/利伯维尔"} ,
  3215. {"Africa/Lome","非洲/洛美"} ,
  3216. {"Africa/Luanda","非洲/罗安达"} ,
  3217. {"Africa/Lubumbashi","非洲/卢本巴希"} ,
  3218. {"Africa/Lusaka","非洲/卢萨卡"} ,
  3219. {"Africa/Malabo","非洲/马拉博"} ,
  3220. {"Africa/Maputo","非洲/马普托"} ,
  3221. {"Africa/Maseru","非洲/马塞卢"} ,
  3222. {"Africa/Mbabane","非洲/姆巴巴内"} ,
  3223. {"Africa/Mogadishu","非洲/摩加迪沙"} ,
  3224. {"Africa/Monrovia","非洲/蒙罗维亚"} ,
  3225. {"Africa/Nairobi","非洲/内罗毕"} ,
  3226. {"Africa/Ndjamena","非洲/恩贾梅纳"} ,
  3227. {"Africa/Niamey","非洲/尼亚美"} ,
  3228. {"Africa/Nouakchott","非洲/努瓦克肖特"} ,
  3229. {"Africa/Ouagadougou","非洲/瓦加杜古"} ,
  3230. {"Africa/Porto-Novo","非洲/波多诺伏"} ,
  3231. {"Africa/Sao_Tome","非洲/圣多美"} ,
  3232. {"Africa/Timbuktu","非洲/廷巴克图"} ,
  3233. {"Africa/Tripoli","非洲/的黎波里"} ,
  3234. {"Africa/Tunis","非洲/突尼斯"} ,
  3235. {"Africa/Windhoek","非洲/温得和克"} ,
  3236. {"America/Adak","美洲/埃达克"} ,
  3237. {"America/Anchorage","美洲/安克雷奇"} ,
  3238. {"America/Anguilla","美洲/安圭拉"} ,
  3239. {"America/Antigua","美洲/安提瓜岛"} ,
  3240. {"America/Araguaina","美洲/阿拉瓜纳"} ,
  3241. {"America/Argentina/Buenos_Aires","美洲/阿根廷/布宜诺斯艾利斯"} ,
  3242. {"America/Argentina/Catamarca","美洲/阿根廷/卡塔马卡"} ,
  3243. {"America/Argentina/ComodRivadavia","美洲/阿根廷/科莫德里瓦达维亚"} ,
  3244. {"America/Argentina/Cordoba","美洲/阿根廷/科尔多瓦"} ,
  3245. {"America/Argentina/Jujuy","美洲/阿根廷/胡胡伊省"} ,
  3246. {"America/Argentina/La_Rioja","美洲/阿根廷/拉里奥哈"} ,
  3247. {"America/Argentina/Mendoza","美洲/阿根廷/门多萨"} ,
  3248. {"America/Argentina/Rio_Gallegos","美洲/阿根廷/里奥加耶戈斯"} ,
  3249. {"America/Argentina/Salta","美洲/阿根廷/萨尔塔"} ,
  3250. {"America/Argentina/San_Juan","美洲/阿根廷/San_Juan"} ,
  3251. {"America/Argentina/San_Luis","美洲/阿根廷/圣路易斯"} ,
  3252. {"America/Argentina/Tucuman","美洲/阿根廷/图库曼"} ,
  3253. {"America/Argentina/Ushuaia","美洲/阿根廷/乌斯怀亚"} ,
  3254. {"America/Aruba","美洲/阿鲁巴岛"} ,
  3255. {"America/Asuncion","美洲/亚松森"} ,
  3256. {"America/Atikokan","美洲/阿蒂科坎"} ,
  3257. {"America/Atka","美洲/阿特卡"} ,
  3258. {"America/Bahia","美洲/巴伊亚"} ,
  3259. {"America/Bahia_Banderas","美洲/巴伊亚_班德拉斯"} ,
  3260. {"America/Barbados","美洲/巴巴多斯"} ,
  3261. {"America/Belem","美洲/贝伦"} ,
  3262. {"America/Belize","美洲/伯利兹"} ,
  3263. {"America/Blanc-Sablon","America/Blanc-Sablon"} ,
  3264. {"America/Boa_Vista","美洲/博阿维斯塔"} ,
  3265. {"America/Bogota","美洲/波哥大"} ,
  3266. {"America/Boise","美洲/博伊西"} ,
  3267. {"America/Buenos_Aires","美洲/布宜诺斯艾利斯"} ,
  3268. {"America/Cambridge_Bay","美洲/剑桥湾"} ,
  3269. {"America/Campo_Grande","美洲/大坎普"} ,
  3270. {"America/Cancun","美洲/坎昆"} ,
  3271. {"America/Caracas","美洲/加拉加斯"} ,
  3272. {"America/Catamarca","美洲/卡塔马卡"} ,
  3273. {"America/Cayenne","美洲/卡宴"} ,
  3274. {"America/Cayman","美洲/开曼"} ,
  3275. {"America/Chicago","美洲/芝加哥"} ,
  3276. {"America/Chihuahua","美洲/奇瓦瓦州"} ,
  3277. {"America/Ciudad_Juarez","美洲/华雷斯城"} ,
  3278. {"America/Coral_Harbour","美洲/珊瑚港"} ,
  3279. {"America/Cordoba","美洲/科尔多瓦"} ,
  3280. {"America/Costa_Rica","美洲/哥斯达黎加"} ,
  3281. {"America/Creston","美洲/克雷斯顿"} ,
  3282. {"America/Cuiaba","美洲/库艾巴"} ,
  3283. {"America/Curacao","美洲/库拉索岛"} ,
  3284. {"America/Danmarkshavn","美洲/丹麦港"} ,
  3285. {"America/Dawson","美洲/道森"} ,
  3286. {"America/Dawson_Creek","美洲/道森克里克"} ,
  3287. {"America/Denver","美洲/丹佛"} ,
  3288. {"America/Detroit","美洲/底特律"} ,
  3289. {"America/Dominica","美洲/多米尼克"} ,
  3290. {"America/Edmonton","美洲/埃德蒙顿"} ,
  3291. {"America/Eirunepe","美洲/埃鲁内佩"} ,
  3292. {"America/El_Salvador","美洲/萨尔瓦多"} ,
  3293. {"America/Ensenada","美洲/恩塞纳达"} ,
  3294. {"America/Fort_Nelson","美洲/纳尔逊堡"} ,
  3295. {"America/Fort_Wayne","美洲/韦恩堡"} ,
  3296. {"America/Fortaleza","美洲/福塔莱萨"} ,
  3297. {"America/Glace_Bay","America/Glace_Bay"} ,
  3298. {"America/Godthab","美洲/戈德哈布"} ,
  3299. {"America/Goose_Bay","America/Goose_Bay"} ,
  3300. {"America/Grand_Turk","美洲/大特克岛"} ,
  3301. {"America/Grenada","美洲/格林纳达"} ,
  3302. {"America/Guadeloupe","美洲/瓜德罗普岛"} ,
  3303. {"America/Guatemala","美洲/危地马拉"} ,
  3304. {"America/Guayaquil","美洲/瓜亚基尔"} ,
  3305. {"America/Guyana","美洲/圭亚那"} ,
  3306. {"America/Halifax","美洲/哈利法克斯"} ,
  3307. {"America/Havana","美洲/哈瓦那"} ,
  3308. {"America/Hermosillo","美洲/埃莫西约"} ,
  3309. {"America/Indiana/Indianapolis","美洲/印第安纳州/印第安纳波利斯"} ,
  3310. {"America/Indiana/Knox","美洲/印第安纳州/诺克斯"} ,
  3311. {"America/Indiana/Marengo","美洲/印第安纳州/马伦戈"} ,
  3312. {"America/Indiana/Petersburg","美洲/印第安纳州/彼得斯堡"} ,
  3313. {"America/Indiana/Tell_City","美洲/印第安纳州/Tell_City"} ,
  3314. {"America/Indiana/Vevay","美洲/印第安纳州/沃韦"} ,
  3315. {"America/Indiana/Vincennes","美洲/印第安纳州/文森斯"} ,
  3316. {"America/Indiana/Winamac","美洲/印第安纳州/威纳马克"} ,
  3317. {"America/Indianapolis","美洲/印第安纳波利斯"} ,
  3318. {"America/Inuvik","美洲/伊努维克人"} ,
  3319. {"America/Iqaluit","美洲/伊魁特"} ,
  3320. {"America/Jamaica","美洲/牙买加"} ,
  3321. {"America/Jujuy","美洲/胡胡伊省"} ,
  3322. {"America/Juneau","美洲/朱诺"} ,
  3323. {"America/Kentucky/Louisville","美洲/肯塔基州/路易斯维尔"} ,
  3324. {"America/Kentucky/Monticello","美洲/肯塔基州/蒙蒂塞洛"} ,
  3325. {"America/Knox_IN","美洲/Knox_IN"} ,
  3326. {"America/Kralendijk","美洲/克拉伦代克"} ,
  3327. {"America/La_Paz","美洲/拉巴斯"} ,
  3328. {"America/Lima","美洲/利马"} ,
  3329. {"America/Los_Angeles","美洲/洛杉矶"} ,
  3330. {"America/Louisville","美洲/路易斯维尔"} ,
  3331. {"America/Lower_Princes","美洲/下王子郡"} ,
  3332. {"America/Maceio","美洲/马塞约"} ,
  3333. {"America/Managua","美洲/马那瓜"} ,
  3334. {"America/Manaus","美洲/马瑙斯"} ,
  3335. {"America/Marigot","美洲/马里戈特"} ,
  3336. {"America/Martinique","美洲/马提尼克岛"} ,
  3337. {"America/Matamoros","美洲/马塔莫罗斯"} ,
  3338. {"America/Mazatlan","美洲/马萨特兰"} ,
  3339. {"America/Mendoza","美洲/门多萨"} ,
  3340. {"America/Menominee","美国/梅诺米尼"} ,
  3341. {"America/Merida","美洲/梅里达"} ,
  3342. {"America/Metlakatla","美洲/梅特拉卡特拉"} ,
  3343. {"America/Mexico_City","美洲/墨西哥_城市"} ,
  3344. {"America/Miquelon","美洲/密克隆群岛"} ,
  3345. {"America/Moncton","美洲/蒙克顿"} ,
  3346. {"America/Monterrey","美洲/蒙特雷"} ,
  3347. {"America/Montevideo","美洲/蒙得维的亚"} ,
  3348. {"America/Montreal","美洲/蒙特利尔"} ,
  3349. {"America/Montserrat","美洲/蒙特塞拉特"} ,
  3350. {"America/Nassau","美洲/拿骚"} ,
  3351. {"America/New_York","美洲/纽约"} ,
  3352. {"America/Nipigon","美洲/尼皮贡"} ,
  3353. {"America/Nome","美国/名称"} ,
  3354. {"America/Noronha","美国/某地"} ,
  3355. {"America/North_Dakota/Beulah","美洲/北达科他州/比尤拉"} ,
  3356. {"America/North_Dakota/Center","美洲/北达科他州/中部"} ,
  3357. {"America/North_Dakota/New_Salem","美洲/北达科他州/新塞勒姆"} ,
  3358. {"America/Nuuk","美洲/努克"} ,
  3359. {"America/Ojinaga","美洲/奥吉纳加"} ,
  3360. {"America/Panama","美洲/巴拿马"} ,
  3361. {"America/Pangnirtung","美洲/庞纳通"} ,
  3362. {"America/Paramaribo","美洲/帕拉马里博"} ,
  3363. {"America/Phoenix","美洲/菲尼克斯"} ,
  3364. {"America/Port-au-Prince","美洲/太子港"} ,
  3365. {"America/Port_of_Spain","美洲/西班牙港"} ,
  3366. {"America/Porto_Acre","美洲/阿卡港"} ,
  3367. {"America/Porto_Velho","美洲/旧波尔图"} ,
  3368. {"America/Puerto_Rico","美洲/波多黎各"} ,
  3369. {"America/Punta_Arenas","美洲/蓬塔阿雷纳斯"} ,
  3370. {"America/Rainy_River","美洲/雷尼河"} ,
  3371. {"America/Rankin_Inlet","兰金因莱特"} ,
  3372. {"America/Recife","美洲/累西腓"} ,
  3373. {"America/Regina","美洲/里贾纳"} ,
  3374. {"America/Resolute","美国/坚决"} ,
  3375. {"America/Rio_Branco","美洲/里奥布兰科"} ,
  3376. {"America/Rosario","美洲/罗萨里奥"} ,
  3377. {"America/Santa_Isabel","美洲/圣伊莎贝尔"} ,
  3378. {"America/Santarem","美洲/圣塔伦"} ,
  3379. {"America/Santiago","美洲/圣地亚哥"} ,
  3380. {"America/Santo_Domingo","美洲/圣多明各"} ,
  3381. {"America/Sao_Paulo","美洲/圣保罗"} ,
  3382. {"America/Scoresbysund","美洲/斯科斯比松"} ,
  3383. {"America/Shiprock","美洲/希普洛克"} ,
  3384. {"America/Sitka","美洲/锡特卡"} ,
  3385. {"America/St_Barthelemy","美洲/圣巴泰勒米"} ,
  3386. {"America/St_Johns","美洲/圣约翰斯"} ,
  3387. {"America/St_Kitts","美洲/圣基茨"} ,
  3388. {"America/St_Lucia","美洲/圣卢西亚"} ,
  3389. {"America/St_Thomas","美洲/圣托马斯"} ,
  3390. {"America/St_Vincent","美洲/圣文森特"} ,
  3391. {"America/Swift_Current","America/Swift_Current"} ,
  3392. {"America/Tegucigalpa","美洲/特古西加尔巴"} ,
  3393. {"America/Thule","美洲/图勒"} ,
  3394. {"America/Thunder_Bay","美洲/雷湾"} ,
  3395. {"America/Tijuana","美洲/蒂华纳"} ,
  3396. {"America/Toronto","美洲/多伦多"} ,
  3397. {"America/Tortola","美洲/托尔托拉岛"} ,
  3398. {"America/Vancouver","美洲/温哥华"} ,
  3399. {"America/Virgin","美国/维珍"} ,
  3400. {"America/Whitehorse","美洲/怀特霍斯"} ,
  3401. {"America/Winnipeg","美洲/温尼伯"} ,
  3402. {"America/Yakutat","美洲/雅库塔特"} ,
  3403. {"America/Yellowknife","美洲/黄刀镇"} ,
  3404. {"Antarctica/Casey","南极洲/凯西"} ,
  3405. {"Antarctica/Davis","南极洲/戴维斯"} ,
  3406. {"Antarctica/DumontDUrville","南极洲/杜蒙杜维尔"} ,
  3407. {"Antarctica/Macquarie","南极洲/麦格理"} ,
  3408. {"Antarctica/Mawson","南极洲/莫森"} ,
  3409. {"Antarctica/McMurdo","南极洲/麦克默多"} ,
  3410. {"Antarctica/Palmer","南极洲/帕尔默"} ,
  3411. {"Antarctica/Rothera","南极洲/罗塞拉岛"} ,
  3412. {"Antarctica/South_Pole","南极洲/南极点"} ,
  3413. {"Antarctica/Syowa","南极洲/昭和"} ,
  3414. {"Antarctica/Troll","南极洲/巨魔"} ,
  3415. {"Antarctica/Vostok","南极洲/东方"} ,
  3416. {"Arctic/Longyearbyen","北极/朗伊尔城"} ,
  3417. {"Asia/Aden","亚洲/亚丁"} ,
  3418. {"Asia/Almaty","亚洲/阿拉木图"} ,
  3419. {"Asia/Amman","亚洲/安曼"} ,
  3420. {"Asia/Anadyr","亚洲/阿纳德尔"} ,
  3421. {"Asia/Aqtau","亚洲/阿克套"} ,
  3422. {"Asia/Aqtobe","亚洲/阿克托比"} ,
  3423. {"Asia/Ashgabat","亚洲/阿什哈巴德"} ,
  3424. {"Asia/Ashkhabad","亚洲/阿什哈巴德"} ,
  3425. {"Asia/Atyrau","亚洲/阿特劳"} ,
  3426. {"Asia/Baghdad","亚洲/巴格达"} ,
  3427. {"Asia/Bahrain","亚洲/巴林"} ,
  3428. {"Asia/Baku","亚洲/巴库"} ,
  3429. {"Asia/Bangkok","亚洲/曼谷"} ,
  3430. {"Asia/Barnaul","亚洲/巴尔瑙尔"} ,
  3431. {"Asia/Beirut","亚洲/贝鲁特"} ,
  3432. {"Asia/Bishkek","亚洲/比什凯克"} ,
  3433. {"Asia/Brunei","亚洲/文莱"} ,
  3434. {"Asia/Calcutta","亚洲/加尔各答"} ,
  3435. {"Asia/Chita","亚洲/赤塔"} ,
  3436. {"Asia/Choibalsan","亚洲/乔巴山"} ,
  3437. {"Asia/Chongqing","亚洲/重庆"} ,
  3438. {"Asia/Chungking","亚洲/重庆"} ,
  3439. {"Asia/Colombo","亚洲/科伦坡"} ,
  3440. {"Asia/Dacca","亚洲/达卡"} ,
  3441. {"Asia/Damascus","亚洲/大马士革"} ,
  3442. {"Asia/Dhaka","亚洲/达卡"} ,
  3443. {"Asia/Dili","亚洲/帝力"} ,
  3444. {"Asia/Dubai","亚洲/迪拜"} ,
  3445. {"Asia/Dushanbe","亚洲/杜尚别"} ,
  3446. {"Asia/Famagusta","亚洲/法马古斯塔"} ,
  3447. {"Asia/Gaza","亚洲/加沙"} ,
  3448. {"Asia/Harbin","亚洲/哈尔滨"} ,
  3449. {"Asia/Hebron","亚洲/希伯伦"} ,
  3450. {"Asia/Ho_Chi_Minh","亚洲/胡志明市"} ,
  3451. {"Asia/Hong_Kong","亚洲/香港"} ,
  3452. {"Asia/Hovd","亚洲/霍布德"} ,
  3453. {"Asia/Irkutsk","亚洲/伊尔库茨克"} ,
  3454. {"Asia/Istanbul","亚洲/伊斯坦布尔"} ,
  3455. {"Asia/Jakarta","亚洲/雅加达"} ,
  3456. {"Asia/Jayapura","亚洲/查亚普拉"} ,
  3457. {"Asia/Jerusalem","亚洲/耶路撒冷"} ,
  3458. {"Asia/Kabul","亚洲/喀布尔"} ,
  3459. {"Asia/Kamchatka","亚洲/堪察加半岛"} ,
  3460. {"Asia/Karachi","亚洲/卡拉奇"} ,
  3461. {"Asia/Kashgar","亚洲/喀什"} ,
  3462. {"Asia/Kathmandu","亚洲/加德满都"} ,
  3463. {"Asia/Katmandu","亚洲/加德满都"} ,
  3464. {"Asia/Khandyga","亚洲/坎迪加"} ,
  3465. {"Asia/Kolkata","亚洲/加尔各答"} ,
  3466. {"Asia/Krasnoyarsk","亚洲/克拉斯诺亚尔斯克"} ,
  3467. {"Asia/Kuala_Lumpur","亚洲/吉隆坡_吉隆坡"} ,
  3468. {"Asia/Kuching","亚洲/古晋"} ,
  3469. {"Asia/Kuwait","亚洲/科威特"} ,
  3470. {"Asia/Macao","亚洲/澳门"} ,
  3471. {"Asia/Macau","亚洲/澳门"} ,
  3472. {"Asia/Magadan","亚洲/马加丹"} ,
  3473. {"Asia/Makassar","亚洲/望加锡"} ,
  3474. {"Asia/Manila","亚洲/马尼拉"} ,
  3475. {"Asia/Muscat","亚洲/马斯喀特"} ,
  3476. {"Asia/Nicosia","亚洲/尼科西亚"} ,
  3477. {"Asia/Novokuznetsk","亚洲/新库兹涅茨克"} ,
  3478. {"Asia/Novosibirsk","亚洲/新西伯利亚"} ,
  3479. {"Asia/Omsk","亚洲/鄂木斯克"} ,
  3480. {"Asia/Oral","亚洲/口头"} ,
  3481. {"Asia/Phnom_Penh","亚洲/金边"} ,
  3482. {"Asia/Pontianak","亚洲/笨珍"} ,
  3483. {"Asia/Pyongyang","亚洲/平壤"} ,
  3484. {"Asia/Qatar","亚洲/卡塔尔"} ,
  3485. {"Asia/Qostanay","亚洲/库斯塔奈"} ,
  3486. {"Asia/Qyzylorda","亚洲/克孜勒奥尔达"} ,
  3487. {"Asia/Rangoon","亚洲/仰光"} ,
  3488. {"Asia/Riyadh","亚洲/利雅得"} ,
  3489. {"Asia/Saigon","亚洲/西贡"} ,
  3490. {"Asia/Sakhalin","亚洲/萨哈林岛"} ,
  3491. {"Asia/Samarkand","亚洲/撒马尔罕"} ,
  3492. {"Asia/Seoul","亚洲/首尔"} ,
  3493. {"Asia/Shanghai","亚洲/上海"} ,
  3494. {"Asia/Singapore","亚洲/新加坡"} ,
  3495. {"Asia/Srednekolymsk","亚洲/中科雷姆斯克"} ,
  3496. {"Asia/Taipei","亚洲/台北"} ,
  3497. {"Asia/Tashkent","亚洲/塔什干"} ,
  3498. {"Asia/Tbilisi","亚洲/第比利斯"} ,
  3499. {"Asia/Tehran","亚洲/德黑兰"} ,
  3500. {"Asia/Tel_Aviv","亚洲/特拉维夫"} ,
  3501. {"Asia/Thimbu","亚洲/廷布"} ,
  3502. {"Asia/Thimphu","亚洲/廷布"} ,
  3503. {"Asia/Tokyo","亚洲/东京"} ,
  3504. {"Asia/Tomsk","亚洲/托木斯克"} ,
  3505. {"Asia/Ujung_Pandang","亚洲/乌戎_潘当"} ,
  3506. {"Asia/Ulaanbaatar","亚洲/乌兰巴托"} ,
  3507. {"Asia/Ulan_Bator","亚洲/乌兰巴托"} ,
  3508. {"Asia/Urumqi","亚洲/乌鲁木齐"} ,
  3509. {"Asia/Ust-Nera","亚洲/乌斯季-内拉"} ,
  3510. {"Asia/Vientiane","亚洲/万象"} ,
  3511. {"Asia/Vladivostok","亚洲/符拉迪沃斯托克"} ,
  3512. {"Asia/Yakutsk","亚洲/雅库茨克"} ,
  3513. {"Asia/Yangon","亚洲/仰光"} ,
  3514. {"Asia/Yekaterinburg","亚洲/叶卡捷琳堡"} ,
  3515. {"Asia/Yerevan","亚洲/埃里温"} ,
  3516. {"Atlantic/Azores","大西洋/亚速尔群岛"} ,
  3517. {"Atlantic/Bermuda","大西洋/百慕大"} ,
  3518. {"Atlantic/Canary","大西洋/加那利"} ,
  3519. {"Atlantic/Cape_Verde","大西洋/佛得角"} ,
  3520. {"Atlantic/Faeroe","大西洋/法罗"} ,
  3521. {"Atlantic/Faroe","大西洋/法罗"} ,
  3522. {"Atlantic/Jan_Mayen","大西洋/扬马延"} ,
  3523. {"Atlantic/Madeira","大西洋/马德拉"} ,
  3524. {"Atlantic/Reykjavik","大西洋/雷克雅未克"} ,
  3525. {"Atlantic/South_Georgia","大西洋/南乔治亚州"} ,
  3526. {"Atlantic/St_Helena","大西洋/圣赫勒拿岛"} ,
  3527. {"Atlantic/Stanley","大西洋/斯坦利"} ,
  3528. {"Australia/ACT","澳大利亚/澳大利亚首都地区"} ,
  3529. {"Australia/Adelaide","澳大利亚/阿德莱德"} ,
  3530. {"Australia/Brisbane","澳大利亚/布里斯班"} ,
  3531. {"Australia/Broken_Hill","澳大利亚/布罗肯希尔"} ,
  3532. {"Australia/Canberra","澳大利亚/堪培拉"} ,
  3533. {"Australia/Currie","澳大利亚/柯里"} ,
  3534. {"Australia/Darwin","澳大利亚/达尔文"} ,
  3535. {"Australia/Eucla","澳大利亚/尤克拉拉"} ,
  3536. {"Australia/Hobart","澳大利亚/霍巴特"} ,
  3537. {"Australia/LHI","澳大利亚/LHI"} ,
  3538. {"Australia/Lindeman","澳大利亚/林德曼"} ,
  3539. {"Australia/Lord_Howe","澳大利亚/豪勋爵"} ,
  3540. {"Australia/Melbourne","澳大利亚/墨尔本"} ,
  3541. {"Australia/NSW","澳大利亚/新南威尔士州"} ,
  3542. {"Australia/North","澳大利亚/北部"} ,
  3543. {"Australia/Perth","澳大利亚/珀斯"} ,
  3544. {"Australia/Queensland","澳大利亚/昆士兰"} ,
  3545. {"Australia/South","澳大利亚/南部"} ,
  3546. {"Australia/Sydney","澳大利亚/悉尼"} ,
  3547. {"Australia/Tasmania","澳大利亚/塔斯马尼亚"} ,
  3548. {"Australia/Victoria","澳大利亚/维多利亚"} ,
  3549. {"Australia/West","澳大利亚/西部"} ,
  3550. {"Australia/Yancowinna","澳大利亚/扬科温纳"} ,
  3551. {"Brazil/Acre","巴西/阿卡"} ,
  3552. {"Brazil/DeNoronha","巴西/迪诺罗尼亚群岛"} ,
  3553. {"Brazil/East","巴西/东部"} ,
  3554. {"Brazil/West","巴西/西部"} ,
  3555. {"CET","CET"} ,
  3556. {"CST6CDT","CST6CDT"} ,
  3557. {"Canada/Atlantic","加拿大/大西洋"} ,
  3558. {"Canada/Central","加拿大/中部"} ,
  3559. {"Canada/Eastern","加拿大/东部"} ,
  3560. {"Canada/Mountain","加拿大/山区"} ,
  3561. {"Canada/Newfoundland","加拿大/纽芬兰"} ,
  3562. {"Canada/Pacific","加拿大/太平洋地区"} ,
  3563. {"Canada/Saskatchewan","加拿大/萨斯喀彻温省"} ,
  3564. {"Canada/Yukon","加拿大/育空地区"} ,
  3565. {"Chile/Continental","智利/大陆航空"} ,
  3566. {"Chile/EasterIsland","智利/复活节岛"} ,
  3567. {"Cuba","古巴"} ,
  3568. {"EET","欧洲东部时间"} ,
  3569. {"EST","东部时间"} ,
  3570. {"EST5EDT","EST5EDT"} ,
  3571. {"Egypt","埃及"} ,
  3572. {"Eire","爱尔兰"} ,
  3573. {"Etc/GMT","Etc/GMT"} ,
  3574. {"Etc/GMT+0","Etc/GMT+0"} ,
  3575. {"Etc/GMT+1","Etc/GMT+1"} ,
  3576. {"Etc/GMT+10","Etc/GMT+10"} ,
  3577. {"Etc/GMT+11","Etc/GMT+11"} ,
  3578. {"Etc/GMT+12","Etc/GMT+12"} ,
  3579. {"Etc/GMT+2","Etc/GMT+2"} ,
  3580. {"Etc/GMT+3","Etc/GMT+3"} ,
  3581. {"Etc/GMT+4","Etc/GMT+4"} ,
  3582. {"Etc/GMT+5","Etc/GMT+5"} ,
  3583. {"Etc/GMT+6","Etc/GMT+6"} ,
  3584. {"Etc/GMT+7","Etc/GMT+7"} ,
  3585. {"Etc/GMT+8","Etc/GMT+8"} ,
  3586. {"Etc/GMT+9","Etc/GMT+9"} ,
  3587. {"Etc/GMT-0","Etc/GMT-0"} ,
  3588. {"Etc/GMT-1","Etc/GMT-1"} ,
  3589. {"Etc/GMT-10","Etc/GMT-10"} ,
  3590. {"Etc/GMT-11","Etc/GMT-11"} ,
  3591. {"Etc/GMT-12","Etc/GMT-12"} ,
  3592. {"Etc/GMT-13","Etc/GMT-13"} ,
  3593. {"Etc/GMT-14","Etc/GMT-14"} ,
  3594. {"Etc/GMT-2","Etc/GMT-2"} ,
  3595. {"Etc/GMT-3","Etc/GMT-3"} ,
  3596. {"Etc/GMT-4","Etc/GMT-4"} ,
  3597. {"Etc/GMT-5","Etc/GMT-5"} ,
  3598. {"Etc/GMT-6","Etc/GMT-6"} ,
  3599. {"Etc/GMT-7","Etc/GMT-7"} ,
  3600. {"Etc/GMT-8","Etc/GMT-8"} ,
  3601. {"Etc/GMT-9","Etc/GMT-9"} ,
  3602. {"Etc/GMT0","Etc/GMT0"} ,
  3603. {"Etc/Greenwich","Etc/格林威治"} ,
  3604. {"Etc/UCT","Etc/UCT"} ,
  3605. {"Etc/UTC","Etc/UTC"} ,
  3606. {"Etc/Universal","Etc/通用"} ,
  3607. {"Etc/Zulu","Etc/祖鲁语"} ,
  3608. {"Europe/Amsterdam","欧洲/阿姆斯特丹"} ,
  3609. {"Europe/Andorra","欧洲/安道尔"} ,
  3610. {"Europe/Astrakhan","欧洲/阿斯特拉罕"} ,
  3611. {"Europe/Athens","欧洲/雅典"} ,
  3612. {"Europe/Belfast","欧洲/贝尔法斯特"} ,
  3613. {"Europe/Belgrade","欧洲/贝尔格莱德"} ,
  3614. {"Europe/Berlin","欧洲/柏林"} ,
  3615. {"Europe/Bratislava","欧洲/布拉迪斯拉发"} ,
  3616. {"Europe/Brussels","欧洲/布鲁塞尔"} ,
  3617. {"Europe/Bucharest","欧洲/布加勒斯特"} ,
  3618. {"Europe/Budapest","欧洲/布达佩斯"} ,
  3619. {"Europe/Busingen","欧洲/布辛根"} ,
  3620. {"Europe/Chisinau","欧洲/基希讷乌"} ,
  3621. {"Europe/Copenhagen","欧洲/哥本哈根"} ,
  3622. {"Europe/Dublin","欧洲/都柏林"} ,
  3623. {"Europe/Gibraltar","欧洲/直布罗陀"} ,
  3624. {"Europe/Guernsey","欧洲/根西岛"} ,
  3625. {"Europe/Helsinki","欧洲/赫尔辛基"} ,
  3626. {"Europe/Isle_of_Man","欧洲/马恩岛"} ,
  3627. {"Europe/Istanbul","欧洲/伊斯坦布尔"} ,
  3628. {"Europe/Jersey","欧洲/泽西岛"} ,
  3629. {"Europe/Kaliningrad","欧洲/加里宁格勒"} ,
  3630. {"Europe/Kiev","欧洲/基辅"} ,
  3631. {"Europe/Kirov","欧洲/基洛夫"} ,
  3632. {"Europe/Kyiv","欧洲/基辅"} ,
  3633. {"Europe/Lisbon","欧洲/里斯本"} ,
  3634. {"Europe/Ljubljana","欧洲/卢布尔雅那"} ,
  3635. {"Europe/London","欧洲/伦敦"} ,
  3636. {"Europe/Luxembourg","欧洲/卢森堡"} ,
  3637. {"Europe/Madrid","欧洲/马德里"} ,
  3638. {"Europe/Malta","欧洲/马耳他"} ,
  3639. {"Europe/Mariehamn","欧洲/玛丽港"} ,
  3640. {"Europe/Minsk","欧洲/明斯克"} ,
  3641. {"Europe/Monaco","欧洲/摩纳哥"} ,
  3642. {"Europe/Moscow","欧洲/莫斯科"} ,
  3643. {"Europe/Nicosia","欧洲/尼科西亚"} ,
  3644. {"Europe/Oslo","欧洲/奥斯陆"} ,
  3645. {"Europe/Paris","欧洲/巴黎"} ,
  3646. {"Europe/Podgorica","欧洲/波德戈里察"} ,
  3647. {"Europe/Prague","欧洲/布拉格"} ,
  3648. {"Europe/Riga","欧洲/里加"} ,
  3649. {"Europe/Rome","欧洲/罗马"} ,
  3650. {"Europe/Samara","欧洲/萨马拉"} ,
  3651. {"Europe/San_Marino","欧洲/圣马力诺"} ,
  3652. {"Europe/Sarajevo","欧洲/萨拉热窝"} ,
  3653. {"Europe/Saratov","欧洲/萨拉托夫"} ,
  3654. {"Europe/Simferopol","欧洲/辛菲罗波尔"} ,
  3655. {"Europe/Skopje","欧洲/斯科普里"} ,
  3656. {"Europe/Sofia","欧洲/索非亚"} ,
  3657. {"Europe/Stockholm","欧洲/斯德哥尔摩"} ,
  3658. {"Europe/Tallinn","欧洲/塔林"} ,
  3659. {"Europe/Tirane","欧洲/地拉那"} ,
  3660. {"Europe/Tiraspol","欧洲/蒂拉斯波尔"} ,
  3661. {"Europe/Ulyanovsk","欧洲/乌里扬诺夫斯克"} ,
  3662. {"Europe/Uzhgorod","欧洲/乌日哥罗德"} ,
  3663. {"Europe/Vaduz","欧洲/瓦杜兹"} ,
  3664. {"Europe/Vatican","欧洲/梵蒂冈"} ,
  3665. {"Europe/Vienna","欧洲/维也纳"} ,
  3666. {"Europe/Vilnius","欧洲/维尔纽斯"} ,
  3667. {"Europe/Volgograd","欧洲/伏尔加格勒"} ,
  3668. {"Europe/Warsaw","欧洲/华沙"} ,
  3669. {"Europe/Zagreb","欧洲/萨格勒布"} ,
  3670. {"Europe/Zaporozhye","欧洲/扎波罗热"} ,
  3671. {"Europe/Zurich","欧洲/苏黎世"} ,
  3672. {"GB","国标"} ,
  3673. {"GB-Eire","英国-爱尔兰"} ,
  3674. {"GMT","格林威治标准时间"} ,
  3675. {"GMT+0","格林威治标准时间+0"} ,
  3676. {"GMT-0","GMT-0"} ,
  3677. {"GMT0","格林威治标准时间0"} ,
  3678. {"Greenwich","格林威治"} ,
  3679. {"HST","高温试验"} ,
  3680. {"Hongkong","香港"} ,
  3681. {"Iceland","冰岛"} ,
  3682. {"Indian/Antananarivo","印度/塔那那利佛"} ,
  3683. {"Indian/Chagos","印第安人/查戈斯人"} ,
  3684. {"Indian/Christmas","印度/圣诞节"} ,
  3685. {"Indian/Cocos","印度/科科斯"} ,
  3686. {"Indian/Comoro","印度/科摩罗"} ,
  3687. {"Indian/Kerguelen","印度/凯尔盖朗"} ,
  3688. {"Indian/Mahe","印度/马埃岛"} ,
  3689. {"Indian/Maldives","印度/马尔代夫"} ,
  3690. {"Indian/Mauritius","印度/毛里求斯"} ,
  3691. {"Indian/Mayotte","印度/马约特岛"} ,
  3692. {"Indian/Reunion","印度/留尼汪岛"} ,
  3693. {"Iran","伊朗"} ,
  3694. {"Israel","以色列"} ,
  3695. {"Jamaica","牙买加"} ,
  3696. {"Japan","日本"} ,
  3697. {"Kwajalein","夸贾林环礁"} ,
  3698. {"Libya","利比亚"} ,
  3699. {"MET","梅特"} ,
  3700. {"MST","MST"} ,
  3701. {"MST7MDT","MST7MDT"} ,
  3702. {"Mexico/BajaNorte","墨西哥/北下巴"} ,
  3703. {"Mexico/BajaSur","墨西哥/巴哈苏尔"} ,
  3704. {"Mexico/General","墨西哥/一般"} ,
  3705. {"NZ","新西兰"} ,
  3706. {"NZ-CHAT","新西兰聊天室"} ,
  3707. {"Navajo","纳瓦霍语"} ,
  3708. {"PRC","中国"} ,
  3709. {"PST8PDT","PST8PDT"} ,
  3710. {"Pacific/Apia","太平洋/阿皮亚"} ,
  3711. {"Pacific/Auckland","太平洋/奥克兰"} ,
  3712. {"Pacific/Bougainville","太平洋/布干维尔岛"} ,
  3713. {"Pacific/Chatham","太平洋/查塔姆"} ,
  3714. {"Pacific/Chuuk","太平洋/楚克"} ,
  3715. {"Pacific/Easter","太平洋/复活节"} ,
  3716. {"Pacific/Efate","太平洋/埃法特"} ,
  3717. {"Pacific/Enderbury","太平洋/恩德伯里"} ,
  3718. {"Pacific/Fakaofo","太平洋/法考福"} ,
  3719. {"Pacific/Fiji","太平洋/斐济"} ,
  3720. {"Pacific/Funafuti","太平洋/富纳富提"} ,
  3721. {"Pacific/Galapagos","太平洋/加拉帕戈斯群岛"} ,
  3722. {"Pacific/Gambier","太平洋/甘比尔"} ,
  3723. {"Pacific/Guadalcanal","太平洋/瓜达尔卡纳尔岛"} ,
  3724. {"Pacific/Guam","太平洋/关岛"} ,
  3725. {"Pacific/Honolulu","太平洋/檀香山"} ,
  3726. {"Pacific/Johnston","太平洋/约翰斯顿"} ,
  3727. {"Pacific/Kanton","太平洋/关东"} ,
  3728. {"Pacific/Kiritimati","太平洋/基里蒂马蒂"} ,
  3729. {"Pacific/Kosrae","太平洋/科斯雷"} ,
  3730. {"Pacific/Kwajalein","太平洋/夸贾林环礁"} ,
  3731. {"Pacific/Majuro","太平洋/马朱罗"} ,
  3732. {"Pacific/Marquesas","太平洋/马克萨斯"} ,
  3733. {"Pacific/Midway","太平洋/中途岛"} ,
  3734. {"Pacific/Nauru","太平洋/瑙鲁"} ,
  3735. {"Pacific/Niue","太平洋/纽埃"} ,
  3736. {"Pacific/Norfolk","太平洋/诺福克"} ,
  3737. {"Pacific/Noumea","太平洋/努美阿"} ,
  3738. {"Pacific/Pago_Pago","太平洋/帕果"} ,
  3739. {"Pacific/Palau","太平洋/帕劳"} ,
  3740. {"Pacific/Pitcairn","太平洋/皮特凯恩"} ,
  3741. {"Pacific/Pohnpei","太平洋/波纳佩"} ,
  3742. {"Pacific/Ponape","太平洋/波纳佩"} ,
  3743. {"Pacific/Port_Moresby","太平洋/莫尔兹比港"} ,
  3744. {"Pacific/Rarotonga","太平洋/拉罗汤加"} ,
  3745. {"Pacific/Saipan","太平洋/塞班岛"} ,
  3746. {"Pacific/Samoa","太平洋/萨摩亚"} ,
  3747. {"Pacific/Tahiti","太平洋/大溪地"} ,
  3748. {"Pacific/Tarawa","太平洋/塔拉瓦"} ,
  3749. {"Pacific/Tongatapu","太平洋/汤加塔布岛"} ,
  3750. {"Pacific/Truk","太平洋/特鲁克"} ,
  3751. {"Pacific/Wake","太平洋/威克"} ,
  3752. {"Pacific/Wallis","太平洋/沃利斯"} ,
  3753. {"Pacific/Yap","太平洋/雅浦岛"} ,
  3754. {"Poland","波兰"} ,
  3755. {"Portugal","葡萄牙"} ,
  3756. {"ROC","ROC"} ,
  3757. {"ROK","韩国"} ,
  3758. {"Singapore","新加坡"} ,
  3759. {"Turkey","Turkey"} ,
  3760. {"UCT","世界标准时间"} ,
  3761. {"US/Alaska","美国/阿拉斯加"} ,
  3762. {"US/Aleutian","美国/阿留申群岛"} ,
  3763. {"US/Arizona","美国/亚利桑那州"} ,
  3764. {"US/Central","美国/中部"} ,
  3765. {"US/East-Indiana","美国/东印第安纳州"} ,
  3766. {"US/Eastern","美国/东部"} ,
  3767. {"US/Hawaii","美国/夏威夷"} ,
  3768. {"US/Indiana-Starke","美国/印第安纳州斯塔克"} ,
  3769. {"US/Michigan","美国/密歇根州"} ,
  3770. {"US/Mountain","美国/山地"} ,
  3771. {"US/Pacific","美国/太平洋地区"} ,
  3772. {"US/Samoa","美国/萨摩亚"} ,
  3773. {"UTC","世界标准时间"} ,
  3774. {"Universal","Universal"} ,
  3775. {"W-SU","W-SU"} ,
  3776. {"WET","WET"} ,
  3777. {"Zulu","Zulu"}
  3778. };
  3779. /// <summary>
  3780. /// 获取国家或城市当地时间
  3781. /// </summary>
  3782. /// <param name="country"></param>
  3783. /// <param name="city"></param>
  3784. /// <returns></returns>
  3785. public static DateTime? GetCountryOrCityCurrentDateTime(string country, string city)
  3786. {
  3787. DateTime? currDt = null;
  3788. var currTimezones = _timeZoneCityMappings.Where(x => x.Value.Contains(city)).ToList();
  3789. if (!currTimezones.Any())
  3790. {
  3791. currTimezones = _timeZoneCityMappings.Where(x => x.Value.Contains(country)).ToList();
  3792. }
  3793. ;
  3794. string timeZoneId = string.Empty;
  3795. if (currTimezones.Count > 1)
  3796. {
  3797. currTimezones = currTimezones.Where(x => x.Value.Contains(country)).ToList();
  3798. timeZoneId = currTimezones.FirstOrDefault().Key ?? string.Empty;
  3799. }
  3800. else timeZoneId = currTimezones.FirstOrDefault().Key ?? string.Empty;
  3801. if (string.IsNullOrEmpty(timeZoneId)) return currDt;
  3802. // Step 1: 获取当前 UTC 时间
  3803. Instant now = SystemClock.Instance.GetCurrentInstant();
  3804. // Step 2: 加载目标时区(以 "Asia/Shanghai" 为例)
  3805. var timeZone = DateTimeZoneProviders.Tzdb[timeZoneId];
  3806. if (timeZone == null) return currDt;
  3807. // Step 3: 将 UTC 时间转换为目标时区的本地时间
  3808. currDt = now.InZone(timeZone).ToDateTimeUnspecified();
  3809. return currDt;
  3810. }
  3811. #endregion
  3812. #region aspose
  3813. /// <summary>
  3814. /// aspose word 设置页脚
  3815. /// </summary>
  3816. /// <param name="builder"></param>
  3817. /// <param name="footerLabel">页脚内容</param>
  3818. /// <param name="font">字体名称</param>
  3819. /// <param name="fontSize"><字体大小/param>
  3820. public static void AsposeWordSetFooter(DocumentBuilder builder, string footerLabel, string font, int fontSize)
  3821. {
  3822. Section currentSection = builder.CurrentSection;
  3823. var pageSetup = currentSection.PageSetup;
  3824. pageSetup.DifferentFirstPageHeaderFooter = true;
  3825. //第一页页脚
  3826. builder.MoveToHeaderFooter(HeaderFooterType.FooterFirst);
  3827. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  3828. builder.Font.Name = font;
  3829. builder.Font.Bold = true;
  3830. builder.Font.Size = fontSize;
  3831. builder.Write(footerLabel);
  3832. //非第一页页脚
  3833. builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
  3834. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  3835. builder.Font.Name = font;
  3836. builder.Font.Bold = true;
  3837. builder.Font.Size = fontSize;
  3838. builder.Write(footerLabel);
  3839. }
  3840. #endregion
  3841. #region 出入境费用
  3842. #region 汇率
  3843. /// <summary>
  3844. /// 出入境费用 初始化汇率
  3845. /// </summary>
  3846. /// <returns></returns>
  3847. public static async Task<List<CurrencyInfo>> EnterExitCostInitRate()
  3848. {
  3849. //默认币种显示
  3850. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>()
  3851. {
  3852. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3853. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3854. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3855. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3856. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3857. };
  3858. var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  3859. if (currencyRate.Count > 0)
  3860. {
  3861. foreach (var item in currencyInfos)
  3862. {
  3863. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3864. if (rateInfo != null)
  3865. {
  3866. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3867. //if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M; //rate1 = rate1 * 1;
  3868. //else rate1 *= 1.035M;
  3869. rate1 *= 1.035M;
  3870. item.Rate = rate1.TruncDecimals(4) + 0.01M;
  3871. }
  3872. }
  3873. }
  3874. return currencyInfos;
  3875. }
  3876. /// <summary>
  3877. /// 出入境费用 实时汇率
  3878. /// </summary>
  3879. /// <returns></returns>
  3880. public static async Task<List<dynamic>> EnterExitCostLiveRate()
  3881. {
  3882. List<dynamic> reteInfos = new List<dynamic>();
  3883. //默认币种显示
  3884. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>()
  3885. {
  3886. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3887. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3888. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3889. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3890. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3891. };
  3892. var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  3893. if (currencyRate.Count > 0)
  3894. {
  3895. foreach (var item in currencyInfos)
  3896. {
  3897. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3898. if (rateInfo != null)
  3899. {
  3900. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3901. decimal rate1 = item.Rate * 1.0350M;
  3902. //rate1 += 0.01M;
  3903. reteInfos.Add(new
  3904. {
  3905. currCode = item.CurrencyCode,
  3906. currName = item.CurrencyName,
  3907. rate = rate1.TruncDecimals(4),
  3908. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3909. });
  3910. }
  3911. }
  3912. }
  3913. return reteInfos;
  3914. }
  3915. /// <summary>
  3916. /// 出入境费用 汇率验证
  3917. /// </summary>
  3918. /// <param name="groupId"></param>
  3919. /// <param name="checkCurrencys">已使用币种</param>
  3920. /// <returns></returns>
  3921. public static async Task<(bool, string, List<CurrencyInfo>)> EnterExitCostCheckRate(int groupId, List<CurrencyInfo> checkCurrencys)
  3922. {
  3923. if (checkCurrencys == null || checkCurrencys.Count < 1) return (false, string.Empty, new List<CurrencyInfo>());
  3924. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == groupId);
  3925. if (info == null) return (false, string.Empty, new List<CurrencyInfo>());
  3926. List<CurrencyInfo> liveRates;
  3927. var cacheRateInfo = await _sqlSugar.Queryable<Sys_ExchangeRateRecord>()
  3928. .OrderByDescending(x => x.CreateTime)
  3929. .FirstAsync(x => x.IsDel == 0 && x.DiId == info.Id);
  3930. if (cacheRateInfo == null)
  3931. {
  3932. var _currencyRate = await _juHeApi.PostItemRateAsync(Array.Empty<string>());
  3933. if (_currencyRate.Count < 1) return (false, "获取汇率失败,请稍后再试!", new List<CurrencyInfo>());
  3934. liveRates = _currencyRate.Select(it => new CurrencyInfo
  3935. {
  3936. CurrencyCode = it.Name,
  3937. CurrencyName = it.Name,
  3938. Rate = Convert.ToDecimal((Convert.ToDecimal(it.FSellPri == null ? 0.00M : it.FSellPri) / 100.00M).ToString("#0.0000"))
  3939. }).ToList();
  3940. }
  3941. else
  3942. {
  3943. liveRates = CommonFun.GetCurrencyChinaToList(cacheRateInfo.RateInfo);
  3944. foreach (var x in liveRates)
  3945. x.Rate = (x.Rate / 100.00M).TruncDecimals(4);
  3946. }
  3947. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  3948. var isSendMsg = false;
  3949. var msgContent = new StringBuilder();
  3950. //去掉费用未使用得币种
  3951. if (checkCurrencys != null && checkCurrencys.Count > 0)
  3952. {
  3953. cacheRateInfos = cacheRateInfos.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  3954. }
  3955. if (cacheRateInfos.Any())
  3956. {
  3957. decimal rowthRate = 1.0350M;
  3958. foreach (var cacheRate in cacheRateInfos)
  3959. {
  3960. var liveRate = liveRates.Find(x => x.CurrencyName.Equals(cacheRate.CurrencyName));
  3961. if (liveRate == null) continue;
  3962. var currRate = (rowthRate * liveRate.Rate).TruncDecimals(4);
  3963. if (cacheRate.Rate != currRate)
  3964. {
  3965. isSendMsg = true;
  3966. //>团组归属:<font color='info'>{groupName}</font>
  3967. msgContent.AppendLine($">- {cacheRate.CurrencyName}汇率(页面保存):{cacheRate.Rate:#0.0000} / 实时汇率(接口保存,已上浮1.0350):{currRate:#0.0000}【原接口输出汇率为:{liveRate.Rate:#0.0000}】");
  3968. }
  3969. }
  3970. return (isSendMsg, msgContent.ToString(), liveRates);
  3971. }
  3972. return (false, string.Empty, new List<CurrencyInfo>());
  3973. }
  3974. #endregion
  3975. #region 三公费用明细 文件下载
  3976. /// <summary>
  3977. /// 获取三公费用标准city
  3978. /// </summary>
  3979. /// <param name="placeData"></param>
  3980. /// <param name="nationalTravelFeeId"></param>
  3981. /// <returns></returns>
  3982. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  3983. {
  3984. string _city = string.Empty;
  3985. if (placeData.Count < 1) return _city;
  3986. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  3987. if (data == null) return _city;
  3988. string country = data.Country;
  3989. string city = data.City;
  3990. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  3991. else _city = city;
  3992. return _city;
  3993. }
  3994. /// <summary>
  3995. /// 三公费用明细 文件下载
  3996. /// </summary>
  3997. /// <param name="dto"></param>
  3998. /// <param name="fileFormat"></param>
  3999. /// <returns></returns>
  4000. public static async Task<JsonView> EnterExitCostDownload(EnterExitCostDownloadDto dto, string fileFormat = "pdf")
  4001. {
  4002. var _view = new JsonView() { Code = StatusCodes.Status204NoContent };
  4003. if (dto.DiId < 1)
  4004. {
  4005. _view.Msg = "请传入有效的DiId参数;";
  4006. return _view;
  4007. }
  4008. if (dto.ExportType < 1)
  4009. {
  4010. _view.Msg = MsgTips.Port;
  4011. return _view;
  4012. }
  4013. if (dto.SubTypeId < 1)
  4014. {
  4015. _view.Msg = @"请传入有效的SubTypeId参数;
  4016. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4017. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4018. 3 团组成员名单 1 团组成员名单";
  4019. return _view;
  4020. }
  4021. try
  4022. {
  4023. var enterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4024. var dayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4025. if (enterExitCosts == null)
  4026. {
  4027. _view.Msg = @"该团组未填写出入境费用;";
  4028. return _view;
  4029. }
  4030. //数据源
  4031. List<Grp_DayAndCost> dac1 = dayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4032. List<Grp_DayAndCost> dac2 = dayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4033. List<Grp_DayAndCost> dac3 = dayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4034. List<Grp_DayAndCost> dac4 = dayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4035. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4036. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4037. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4038. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4039. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4040. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4041. .Select((tcl, dc, cc) => new
  4042. {
  4043. Name = dc.LastName + dc.FirstName,
  4044. Sex = dc.Sex,
  4045. Birthday = dc.BirthDay,
  4046. Company = cc.CompanyFullName,
  4047. Job = dc.Job
  4048. })
  4049. .ToList();
  4050. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4051. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4052. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4053. var rateDatas = await enterExitCosts.CurrencyRemark.SplitExchangeRate();
  4054. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4055. if (dto.ExportType == 1) //明细表
  4056. {
  4057. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4058. {
  4059. if (!fileFormat.Equals("pdf")) fileFormat = "docx";
  4060. //获取模板
  4061. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4062. //载入模板
  4063. Document doc = new Document(tempPath);
  4064. DocumentBuilder builder = new DocumentBuilder(doc);
  4065. //利用键值对存放数据
  4066. Dictionary<string, string> dic = new Dictionary<string, string>();
  4067. decimal stayFeeTotal = dayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4068. decimal mealsFeeTotal = dayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4069. decimal miscellaneousFeeTotal = dayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4070. decimal tainFeeTotal = dayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4071. decimal insidePayTotal = enterExitCosts.InsidePay;
  4072. string row1_1 = "";
  4073. if (enterExitCosts.Visa > 0)
  4074. {
  4075. //insidePayTotal += enterExitCosts.Visa;
  4076. row1_1 = $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4077. //if (!string.IsNullOrEmpty(enterExitCosts.VisaRemark))
  4078. //{
  4079. // row1_1 += $"\t签证费用描述: {enterExitCosts.VisaRemark}";
  4080. //}
  4081. }
  4082. string row1_2 = "";
  4083. if (enterExitCosts.YiMiao > 0)
  4084. {
  4085. //insidePayTotal += enterExitCosts.YiMiao;
  4086. row1_2 += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4087. }
  4088. if (enterExitCosts.HeSuan > 0)
  4089. {
  4090. //insidePayTotal += enterExitCosts.HeSuan;
  4091. row1_2 += $"核酸检测费:{enterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4092. }
  4093. if (enterExitCosts.Service > 0)
  4094. {
  4095. //insidePayTotal += enterExitCosts.Service;
  4096. row1_2 += $"服务费:{enterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4097. }
  4098. string row1_3 = "";
  4099. if (enterExitCosts.Safe > 0)
  4100. {
  4101. //insidePayTotal += enterExitCosts.Safe;
  4102. row1_3 += $"保险费:{enterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4103. }
  4104. if (enterExitCosts.Ticket > 0)
  4105. {
  4106. //insidePayTotal += enterExitCosts.Ticket;
  4107. row1_3 += $"参展门票:{enterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4108. }
  4109. string row1 = "";
  4110. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4111. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4112. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4113. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4114. dic.Add("Row1Str", row1);
  4115. dic.Add("OutsideJJ", enterExitCosts.OutsideJJPay.ToString("#0.00"));
  4116. dic.Add("OutsaideGW", enterExitCosts.OutsideGWPay.ToString("#0.00"));
  4117. dic.Add("AirJJ", enterExitCosts.AirJJ.ToString("#0.00"));
  4118. dic.Add("AirGW", enterExitCosts.AirGW.ToString("#0.00"));
  4119. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  4120. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4121. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4122. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  4123. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  4124. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  4125. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideJJPay;
  4126. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideGWPay;
  4127. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4128. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4129. #region 填充word模板书签内容
  4130. foreach (var key in dic.Keys)
  4131. {
  4132. builder.MoveToBookmark(key);
  4133. builder.Write(dic[key]);
  4134. }
  4135. #endregion
  4136. #region 填充word表格内容
  4137. ////获读取指定表格方法二
  4138. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4139. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4140. for (int i = 0; i < dac1.Count; i++)
  4141. {
  4142. Grp_DayAndCost dac = dac1[i];
  4143. if (dac == null) continue;
  4144. builder.MoveToCell(0, i, 0, 0);
  4145. builder.Write("第" + dac.Days.ToString() + "晚:");
  4146. builder.MoveToCell(0, i, 1, 0);
  4147. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4148. //builder.Write(dac.Place == null ? "" : dac.Place);
  4149. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4150. builder.MoveToCell(0, i, 2, 0);
  4151. builder.Write("费用标准:");
  4152. string curr = "";
  4153. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4154. if (currData != null)
  4155. {
  4156. curr = currData.Name;
  4157. }
  4158. builder.MoveToCell(0, i, 3, 0);
  4159. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4160. builder.MoveToCell(0, i, 4, 0);
  4161. builder.Write("费用小计:");
  4162. builder.MoveToCell(0, i, 5, 0);
  4163. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4164. }
  4165. //删除多余行
  4166. while (table1.Rows.Count > dac1.Count)
  4167. {
  4168. table1.Rows.RemoveAt(dac1.Count);
  4169. }
  4170. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4171. for (int i = 0; i < dac2.Count; i++)
  4172. {
  4173. Grp_DayAndCost dac = dac2[i];
  4174. if (dac == null) continue;
  4175. builder.MoveToCell(1, i, 0, 0);
  4176. builder.Write("第" + dac.Days.ToString() + "天:");
  4177. builder.MoveToCell(1, i, 1, 0);
  4178. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4179. builder.MoveToCell(1, i, 2, 0);
  4180. builder.Write("费用标准:");
  4181. string curr = "";
  4182. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4183. if (currData != null)
  4184. {
  4185. curr = currData.Name;
  4186. }
  4187. builder.MoveToCell(1, i, 3, 0);
  4188. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4189. builder.MoveToCell(1, i, 4, 0);
  4190. builder.Write("费用小计:");
  4191. builder.MoveToCell(1, i, 5, 0);
  4192. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4193. }
  4194. //删除多余行
  4195. while (table2.Rows.Count > dac2.Count)
  4196. {
  4197. table2.Rows.RemoveAt(dac2.Count);
  4198. }
  4199. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4200. for (int i = 0; i < dac3.Count; i++)
  4201. {
  4202. Grp_DayAndCost dac = dac3[i];
  4203. if (dac == null) continue;
  4204. builder.MoveToCell(2, i, 0, 0);
  4205. builder.Write("第" + dac.Days.ToString() + "天:");
  4206. builder.MoveToCell(2, i, 1, 0);
  4207. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4208. builder.MoveToCell(2, i, 2, 0);
  4209. builder.Write("费用标准:");
  4210. string curr = "";
  4211. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4212. if (currData != null)
  4213. {
  4214. curr = currData.Name;
  4215. }
  4216. builder.MoveToCell(2, i, 3, 0);
  4217. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4218. builder.MoveToCell(2, i, 4, 0);
  4219. builder.Write("费用小计:");
  4220. builder.MoveToCell(2, i, 5, 0);
  4221. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4222. }
  4223. //删除多余行
  4224. while (table3.Rows.Count > dac3.Count)
  4225. {
  4226. table3.Rows.RemoveAt(dac3.Count);
  4227. }
  4228. #endregion
  4229. //文件名
  4230. //string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
  4231. //string strFileName = $"{_DelegationInfo.TeamName}-出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
  4232. string strFileName = $"{_DelegationInfo.TeamName}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileFormat}";
  4233. AsposeHelper.removewatermark_v2180();
  4234. //doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4235. var saveFormat = Aspose.Words.SaveFormat.Docx;
  4236. if (fileFormat.Equals("pdf"))
  4237. {
  4238. //doc.LayoutOptions.IsShowComments = false;
  4239. doc.LayoutOptions.IsShowHiddenText = false;
  4240. doc.LayoutOptions.IsShowParagraphMarks = false;
  4241. doc.LayoutOptions.RevisionOptions.DeletedTextEffect = RevisionTextEffect.None;
  4242. doc.AcceptAllRevisions();
  4243. Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
  4244. options.Compliance = PdfCompliance.PdfA1a;
  4245. options.CreateNoteHyperlinks = true;
  4246. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, options);
  4247. //_view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
  4248. _view.Data = new { Url = strFileName };
  4249. _view.Msg = "成功";
  4250. return _view;
  4251. }
  4252. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, saveFormat);
  4253. _view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
  4254. _view.Msg = "成功";
  4255. return _view;
  4256. }
  4257. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4258. {
  4259. //获取模板
  4260. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4261. //载入模板
  4262. Document doc = new Document(tempPath);
  4263. DocumentBuilder builder = new DocumentBuilder(doc);
  4264. Dictionary<string, string> dic = new Dictionary<string, string>();
  4265. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4266. {
  4267. List<string> list = new List<string>();
  4268. try
  4269. {
  4270. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4271. foreach (var item in spilitArr)
  4272. {
  4273. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4274. var depCode = spDotandEmpty[2].Substring(0, 3);
  4275. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4276. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4277. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4278. list.Add(depName);
  4279. list.Add(arrName);
  4280. }
  4281. list = list.Distinct().ToList();
  4282. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4283. }
  4284. catch (Exception)
  4285. {
  4286. dic.Add("ReturnCode", "行程录入不正确!");
  4287. }
  4288. }
  4289. else
  4290. {
  4291. dic.Add("ReturnCode", "未录入行程!");
  4292. }
  4293. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4294. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4295. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4296. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4297. {
  4298. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4299. dic.Add("Day", sp.Days.ToString());
  4300. }
  4301. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4302. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4303. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4304. //dic.Add("Names", Names);
  4305. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4306. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4307. decimal dac1totalPrice = 0.00M;
  4308. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4309. foreach (var dac in dac1)
  4310. {
  4311. if (dac.SubTotal == 0.00M)
  4312. {
  4313. continue;
  4314. }
  4315. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4316. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4317. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4318. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4319. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4320. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4321. builder.Write(currency);//币种
  4322. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4323. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4324. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4325. builder.Write("");//人数
  4326. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4327. builder.Write("");//天数
  4328. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4329. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4330. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4331. decimal rate = 0.00M;
  4332. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4333. builder.Write(rate.ToString("#0.0000"));//汇率
  4334. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4335. decimal rbmPrice = dac.SubTotal;
  4336. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4337. accommodationStartIndex++;
  4338. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4339. }
  4340. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4341. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4342. {
  4343. table1.Rows.RemoveAt(i - 1);
  4344. foodandotherStartIndex--;
  4345. }
  4346. if (dac2.Count == dac3.Count)//国家 币种 金额
  4347. {
  4348. for (int i = 0; i < dac2.Count; i++)
  4349. {
  4350. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4351. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4352. }
  4353. }
  4354. decimal dac2totalPrice = 0.00M;
  4355. foreach (var dac in dac2)
  4356. {
  4357. if (dac.SubTotal == 0)
  4358. {
  4359. continue;
  4360. }
  4361. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4362. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4363. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4364. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4365. builder.Write(currency);//币种
  4366. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4367. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4368. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4369. builder.Write("");//人数
  4370. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4371. builder.Write("");//天数
  4372. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4373. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4374. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4375. decimal rate = 0.00M;
  4376. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4377. builder.Write(rate.ToString("#0.0000"));//汇率
  4378. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4379. decimal rbmPrice = dac.SubTotal;
  4380. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4381. foodandotherStartIndex++;
  4382. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4383. }
  4384. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4385. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4386. {
  4387. table1.Rows.RemoveAt(i - 1);
  4388. }
  4389. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  4390. string otherFeeStr = "";
  4391. if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
  4392. if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
  4393. if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
  4394. if (otherFeeStr.Length > 0)
  4395. {
  4396. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4397. otherFeeStr = $"({otherFeeStr})";
  4398. dic.Add("OtherFeeStr", otherFeeStr);
  4399. }
  4400. //总计
  4401. decimal allPrice = dac1totalPrice + dac2totalPrice + enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket;
  4402. //国际旅费
  4403. string outsideJJ = "";
  4404. string allPriceJJ = "";
  4405. if (enterExitCosts.SumJJC == 1)
  4406. {
  4407. outsideJJ = string.Format(@"经济舱:{0} 元/人", enterExitCosts.AirJJ.ToString("#0.00"));
  4408. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + enterExitCosts.OutsideJJPay).ToString("#0.00"));
  4409. }
  4410. string outsideGW = "";
  4411. string allPriceGW = "";
  4412. if (enterExitCosts.SumGWC == 1)
  4413. {
  4414. outsideGW = string.Format(@"公务舱:{0} 元/人", enterExitCosts.AirGW.ToString("#0.00"));
  4415. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + enterExitCosts.OutsideGWPay).ToString("#0.00"));
  4416. }
  4417. if (enterExitCosts.SumJJC == 1 || enterExitCosts.SumGWC == 1)
  4418. {
  4419. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  4420. dic.Add("InTravelPrice", InTravelPriceStr);
  4421. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  4422. dic.Add("FinalSumPrice", FinalSumPriceStr);
  4423. }
  4424. //dic.Add("VisaPay", enterExitCosts.Visa.ToString("#0.00"));
  4425. //dic.Add("SafePay", enterExitCosts.Safe.ToString("#0.00"));
  4426. //dic.Add("YiMiao", enterExitCosts.YiMiao.ToString("#0.00"));
  4427. foreach (var key in dic.Keys)
  4428. {
  4429. builder.MoveToBookmark(key);
  4430. builder.Write(dic[key]);
  4431. }
  4432. //模板文件名
  4433. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  4434. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4435. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4436. _view.Data = new { Url = url };
  4437. _view.Msg = "成功";
  4438. return _view;
  4439. }
  4440. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4441. {
  4442. //获取模板
  4443. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4444. //载入模板
  4445. WorkbookDesigner designer = new WorkbookDesigner();
  4446. designer.Workbook = new Workbook(tempPath);
  4447. Dictionary<string, string> dic = new Dictionary<string, string>();
  4448. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4449. {
  4450. List<string> list = new List<string>();
  4451. try
  4452. {
  4453. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4454. foreach (var item in spilitArr)
  4455. {
  4456. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4457. var depCode = spDotandEmpty[2].Substring(0, 3);
  4458. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4459. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4460. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4461. list.Add(depName);
  4462. list.Add(arrName);
  4463. }
  4464. list = list.Distinct().ToList();
  4465. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4466. }
  4467. catch (Exception)
  4468. {
  4469. dic.Add("ReturnCode", "行程录入不正确!");
  4470. }
  4471. }
  4472. else
  4473. {
  4474. dic.Add("ReturnCode", "未录入行程!");
  4475. }
  4476. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4477. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4478. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4479. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4480. {
  4481. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4482. dic.Add("Day", sp.Days.ToString());
  4483. }
  4484. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4485. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4486. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4487. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4488. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4489. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4490. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4491. designer.SetDataSource("Name", Names);
  4492. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4493. designer.SetDataSource("Day", dic["Day"] + "天");
  4494. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4495. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4496. int startIndex = 10;
  4497. const int startIndexcopy = 10;
  4498. if (dac2.Count == dac3.Count)//国家 币种 金额
  4499. {
  4500. for (int i = 0; i < dac2.Count; i++)
  4501. {
  4502. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4503. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4504. }
  4505. }
  4506. DataTable dtdac1 = new DataTable();
  4507. List<string> place = new List<string>();
  4508. dtdac1.Columns.AddRange(new DataColumn[] {
  4509. new DataColumn(){ ColumnName = "city"},
  4510. new DataColumn(){ ColumnName = "curr"},
  4511. new DataColumn(){ ColumnName = "criterion"},
  4512. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4513. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4514. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4515. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4516. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4517. });
  4518. DataTable dtdac2 = new DataTable();
  4519. dtdac2.Columns.AddRange(new DataColumn[] {
  4520. new DataColumn(){ ColumnName = "city"},
  4521. new DataColumn(){ ColumnName = "curr"},
  4522. new DataColumn(){ ColumnName = "criterion"},
  4523. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4524. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4525. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4526. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4527. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4528. });
  4529. dtdac1.TableName = "tb1";
  4530. dtdac2.TableName = "tb2";
  4531. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4532. foreach (var item in dac1)
  4533. {
  4534. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4535. if (place.Contains(item.Place))
  4536. {
  4537. continue;
  4538. }
  4539. DataRow row = dtdac1.NewRow();
  4540. row["city"] = item.Place;
  4541. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4542. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4543. row["curr"] = currency;
  4544. row["rate"] = rate.ToString("#0.0000");
  4545. row["criterion"] = item.Cost.ToString("#0.00");
  4546. row["number"] = 1;
  4547. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4548. //row["costRMB"] = rbmPrice;
  4549. dtdac1.Rows.Add(row);
  4550. place.Add(item.Place);
  4551. }
  4552. place = new List<string>();
  4553. foreach (var item in dac2)
  4554. {
  4555. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4556. if (place.Contains(item.Place))
  4557. {
  4558. continue;
  4559. }
  4560. DataRow row = dtdac2.NewRow();
  4561. row["city"] = item.Place;
  4562. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4563. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4564. row["curr"] = currency;
  4565. row["rate"] = rate.ToString("#0.0000");
  4566. row["criterion"] = item.Cost.ToString("#0.00");
  4567. row["number"] = 1;
  4568. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4569. //row["cost"] = item.SubTotal;
  4570. //row["costRMB"] = rbmPrice;
  4571. dtdac2.Rows.Add(row);
  4572. place.Add(item.Place);
  4573. //dac2totalPrice += rbmPrice;
  4574. }
  4575. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4576. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4577. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4578. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4579. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {enterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4580. designer.SetDataSource("sumCityTranffic", @$"{enterExitCosts.CityTranffic.ToString("#0.00")} ");
  4581. string cell4Str = $" 4.国际旅费:经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{enterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4582. string cellStr = $" 5.其他费用(";
  4583. if (enterExitCosts.Visa > 0) cellStr += $"签证费:{enterExitCosts.Visa.ToString("#0.00")}元,";
  4584. if (enterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")}元,";
  4585. if (enterExitCosts.HeSuan > 0) cellStr += $"核酸费:{enterExitCosts.HeSuan.ToString("#0.00")}元,";
  4586. if (enterExitCosts.Safe > 0) cellStr += $"保险费:{enterExitCosts.Safe.ToString("#0.00")}元,";
  4587. if (enterExitCosts.Ticket > 0) cellStr += $"参展门票费:{enterExitCosts.Ticket.ToString("#0.00")}元,";
  4588. if (enterExitCosts.Service > 0) cellStr += $"服务费:{enterExitCosts.Service.ToString("#0.00")}元,";
  4589. if (cellStr.Length > 8)
  4590. {
  4591. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4592. }
  4593. cellStr += ")";
  4594. decimal otherFee = enterExitCosts.Visa + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.Service;
  4595. decimal s = dac1totalPrice + dac2totalPrice + enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay + otherFee;
  4596. decimal pxFee = dac4.Sum(it => it.Cost);
  4597. decimal glvFee = enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay;
  4598. string celllastStr1 = "";
  4599. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4600. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4601. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4602. celllastStr1 += $",国际旅费 元";
  4603. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4604. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4605. designer.SetDataSource("cell4Str", cell4Str);
  4606. designer.SetDataSource("cellStr", cellStr);
  4607. designer.SetDataSource("cellSum", (enterExitCosts.Visa + enterExitCosts.Safe).ToString("#0.00"));
  4608. designer.SetDataSource("cellSum4", (enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay).ToString("#0.00"));
  4609. designer.SetDataSource("celllastStr", celllastStr);
  4610. Workbook wb = designer.Workbook;
  4611. var sheet = wb.Worksheets[0];
  4612. //绑定datatable数据集
  4613. designer.SetDataSource(dtdac1);
  4614. designer.SetDataSource(dtdac2);
  4615. designer.Process();
  4616. var rowStart = dtdac1.Rows.Count;
  4617. while (rowStart > 0)
  4618. {
  4619. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4620. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4621. startIndex++;
  4622. rowStart--;
  4623. }
  4624. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4625. startIndex += 1; //总计行
  4626. rowStart = dtdac2.Rows.Count;
  4627. while (rowStart > 0)
  4628. {
  4629. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4630. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4631. startIndex++;
  4632. rowStart--;
  4633. }
  4634. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4635. wb.CalculateFormula(true);
  4636. //模板文件名
  4637. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"; ;//$".xls";
  4638. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4639. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4640. _view.Data = new { Url = url };
  4641. _view.Msg = "成功";
  4642. return _view;
  4643. }
  4644. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4645. {
  4646. //获取模板
  4647. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4648. //载入模板
  4649. Document doc = new Document(tempPath);
  4650. DocumentBuilder builder = new DocumentBuilder(doc);
  4651. Dictionary<string, string> dic = new Dictionary<string, string>();
  4652. dic.Add("GroupName", _DelegationInfo.TeamName);
  4653. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4654. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4655. string missionLeaderJob = "";//负责人job
  4656. //int groupNumber = 0; //团人数
  4657. if (DeleClientList.Count > 0)
  4658. {
  4659. missionLeader = DeleClientList[0]?.Name ?? "";
  4660. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4661. }
  4662. dic.Add("MissionLeader", missionLeader); //团负责人
  4663. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4664. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4665. #region MyRegion
  4666. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4667. //{
  4668. // List<string> list = new List<string>();
  4669. // try
  4670. // {
  4671. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4672. // foreach (var item in spilitArr)
  4673. // {
  4674. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4675. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4676. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4677. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4678. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4679. // list.Add(depName);
  4680. // list.Add(arrName);
  4681. // }
  4682. // list = list.Distinct().ToList();
  4683. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4684. // }
  4685. // catch (Exception)
  4686. // {
  4687. // dic.Add("ReturnCode", "行程录入不正确!");
  4688. // }
  4689. //}
  4690. //else
  4691. //{
  4692. // dic.Add("ReturnCode", "未录入行程!");
  4693. //}
  4694. List<string> countrys = _dirRep.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4695. dic.Add("ReturnCode", string.Join("、", countrys));
  4696. #endregion
  4697. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4698. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4699. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4700. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4701. //{
  4702. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4703. // dic.Add("Day", sp.Days.ToString());
  4704. //}
  4705. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4706. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4707. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4708. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4709. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4710. //培训人员名单
  4711. int cultivateRowIndex = 7;
  4712. foreach (var item in DeleClientList)
  4713. {
  4714. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4715. builder.Write(item.Name);
  4716. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4717. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4718. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4719. string birthDay = "";
  4720. if (item.Birthday != null)
  4721. {
  4722. DateTime dt = Convert.ToDateTime(item.Birthday);
  4723. birthDay = $"{dt.Year}.{dt.Month}";
  4724. }
  4725. builder.Write(birthDay);
  4726. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4727. builder.Write(item.Company);
  4728. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4729. builder.Write(item.Job);
  4730. cultivateRowIndex++;
  4731. }
  4732. //删除多余行
  4733. //cultivateRowIndex -= 2;
  4734. int delRows = 10 + 7 - cultivateRowIndex;
  4735. if (delRows > 0)
  4736. {
  4737. for (int i = 0; i < delRows; i++)
  4738. {
  4739. table1.Rows.RemoveAt(cultivateRowIndex);
  4740. //cultivateRowIndex++;
  4741. }
  4742. }
  4743. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4744. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4745. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4746. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4747. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4748. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4749. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4750. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4751. decimal cityTranfficFeeToatal = enterExitCosts.CityTranffic; //城市区间交通费
  4752. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4753. //其他费用
  4754. decimal otherFeeTotal = enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Service;
  4755. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4756. //其他费用合计
  4757. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4758. decimal _jjcFeeToatal = enterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4759. decimal _gwcFeeToatal = enterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4760. //公务舱合计
  4761. //国际旅费
  4762. //string outsideJJ = "";
  4763. //string allPriceJJ = "";
  4764. if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 0)
  4765. {
  4766. dic.Add("AirFeeTotal", enterExitCosts.AirJJ.ToString("#0.00"));
  4767. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4768. }
  4769. if (enterExitCosts.SumGWC == 1 && enterExitCosts.SumJJC == 0)
  4770. {
  4771. dic.Add("AirFeeTotal", enterExitCosts.AirGW.ToString("#0.00"));
  4772. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4773. }
  4774. if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 1)
  4775. {
  4776. string airFeeTotalStr = string.Format(@$"经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{enterExitCosts.AirGW.ToString("#0.00")}");
  4777. dic.Add("AirFeeTotal", airFeeTotalStr);
  4778. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4779. dic.Add("FeeTotal", feeTotalStr);
  4780. }
  4781. foreach (var key in dic.Keys)
  4782. {
  4783. builder.MoveToBookmark(key);
  4784. builder.Write(dic[key]);
  4785. }
  4786. //模板文件名
  4787. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4788. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4789. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4790. _view.Data = new { Url = url };
  4791. _view.Msg = "成功";
  4792. return _view;
  4793. }
  4794. }
  4795. else if (dto.ExportType == 2) //表格
  4796. {
  4797. //利用键值对存放数据
  4798. Dictionary<string, string> dic = new Dictionary<string, string>();
  4799. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4800. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4801. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4802. dic.Add("Day", sp.Days.ToString());
  4803. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4804. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4805. {
  4806. //获取模板
  4807. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4808. //载入模板
  4809. Document doc = new Document(tempPath);
  4810. DocumentBuilder builder = new DocumentBuilder(doc);
  4811. dic.Add("TeamName", _DelegationInfo.TeamName);
  4812. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4813. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4814. string missionLeaderName = "",
  4815. missionLeaderJob = "";
  4816. if (DeleClientList.Count > 0)
  4817. {
  4818. missionLeaderName = DeleClientList[0].Name;
  4819. missionLeaderJob = DeleClientList[0].Job;
  4820. }
  4821. dic.Add("MissionLeaderName", missionLeaderName);
  4822. dic.Add("MissionLeaderJob", missionLeaderJob);
  4823. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4824. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4825. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4826. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4827. int rowCount = 10;//总人数行
  4828. int startRowIndex = 7; //起始行
  4829. for (int i = 0; i < DeleClientList.Count; i++)
  4830. {
  4831. builder.MoveToCell(0, startRowIndex, 0, 0);
  4832. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4833. builder.MoveToCell(0, startRowIndex, 1, 0);
  4834. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4835. builder.Write(sex);//性别
  4836. builder.MoveToCell(0, startRowIndex, 2, 0);
  4837. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4838. builder.MoveToCell(0, startRowIndex, 3, 0);
  4839. builder.Write(DeleClientList[i].Company);//工作单位
  4840. builder.MoveToCell(0, startRowIndex, 4, 0);
  4841. builder.Write(DeleClientList[i].Job);//职务及级别
  4842. builder.MoveToCell(0, startRowIndex, 5, 0);
  4843. builder.Write("");//人员属性
  4844. builder.MoveToCell(0, startRowIndex, 6, 0);
  4845. builder.Write("");//上次出国时间
  4846. startRowIndex++;
  4847. }
  4848. int nullRow = rowCount - DeleClientList.Count;//空行
  4849. for (int i = 0; i < nullRow; i++)
  4850. {
  4851. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4852. }
  4853. foreach (var key in dic.Keys)
  4854. {
  4855. builder.MoveToBookmark(key);
  4856. builder.Write(dic[key]);
  4857. }
  4858. //模板文件名
  4859. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4860. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4861. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4862. _view.Data = new { Url = url };
  4863. _view.Msg = "成功";
  4864. return _view;
  4865. }
  4866. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4867. {
  4868. //获取模板
  4869. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4870. //载入模板
  4871. Document doc = new Document(tempPath);
  4872. DocumentBuilder builder = new DocumentBuilder(doc);
  4873. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4874. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4875. dic.Add("Names", Names);
  4876. int accommodationRows = 12, foodandotherRows = 12;
  4877. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4878. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4879. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4880. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4881. int accommodationStartIndex = 6;
  4882. decimal dac1totalPrice = 0.00M;
  4883. foreach (var dac in dac1)
  4884. {
  4885. if (dac.SubTotal == 0)
  4886. {
  4887. continue;
  4888. }
  4889. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4890. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4891. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4892. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4893. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4894. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4895. builder.Write(currency);//币种
  4896. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4897. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4898. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4899. builder.Write("");//人数
  4900. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4901. builder.Write("");//天数
  4902. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4903. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4904. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4905. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4906. builder.Write(rate.ToString("#0.0000"));//汇率
  4907. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4908. decimal rbmPrice = rate * dac.SubTotal;
  4909. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4910. accommodationStartIndex++;
  4911. dac1totalPrice += rbmPrice;
  4912. }
  4913. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4914. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4915. builder.Write("小计");
  4916. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4917. builder.Write(dac1totalPrice.ToString("#0.00"));
  4918. accommodationStartIndex++;
  4919. int nullRow = accommodationRows - dac1.Count;
  4920. //删除空行
  4921. //if (nullRow > 0)
  4922. //{
  4923. // int rowIndex = accommodationStartIndex;
  4924. // for (int i = 0; i < nullRow; i++)
  4925. // {
  4926. // Row row = table1.Rows[rowIndex];
  4927. // row.Remove();
  4928. // rowIndex++;
  4929. // }
  4930. //}
  4931. if (dac2.Count == dac3.Count)//国家 币种 金额
  4932. {
  4933. for (int i = 0; i < dac2.Count; i++)
  4934. {
  4935. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4936. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4937. }
  4938. }
  4939. int foodandotherStartIndex = 19;//
  4940. decimal dac2totalPrice = 0.00M;
  4941. foreach (var dac in dac2)
  4942. {
  4943. if (dac.SubTotal == 0)
  4944. {
  4945. continue;
  4946. }
  4947. //foodandotherStartIndex = 12;
  4948. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4949. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4950. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4951. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4952. builder.Write(currency);//币种
  4953. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4954. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4955. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4956. builder.Write("");//人数
  4957. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4958. builder.Write("");//天数
  4959. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4960. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4961. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4962. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4963. builder.Write(rate.ToString("#0.0000"));//汇率
  4964. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4965. decimal rbmPrice = rate * dac.SubTotal;
  4966. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4967. foodandotherStartIndex++;
  4968. dac2totalPrice += rbmPrice;
  4969. }
  4970. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4971. //删除空行
  4972. if (dac2.Count < foodandotherRows)
  4973. {
  4974. //int nullRow = accommodationRows - dac2.Count;
  4975. //while (table2.Rows.Count > dac2.Count)
  4976. //{
  4977. // table2.Rows.RemoveAt(dac2.Count);
  4978. //}
  4979. }
  4980. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  4981. string otherFeeStr = "";
  4982. if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
  4983. if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
  4984. if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
  4985. if (otherFeeStr.Length > 0)
  4986. {
  4987. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4988. otherFeeStr = $"({otherFeeStr})";
  4989. dic.Add("OtherFeeStr", otherFeeStr);
  4990. }
  4991. foreach (var key in dic.Keys)
  4992. {
  4993. builder.MoveToBookmark(key);
  4994. builder.Write(dic[key]);
  4995. }
  4996. //模板文件名
  4997. string strFileName = $"省级单位出(境)经费报销单.docx";
  4998. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4999. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5000. _view.Data = new { Url = url };
  5001. _view.Msg = "成功";
  5002. return _view;
  5003. }
  5004. }
  5005. else if (dto.ExportType == 3)
  5006. {
  5007. if (dto.SubTypeId == 1) //团组成员名单
  5008. {
  5009. if (DeleClientList.Count < 1)
  5010. {
  5011. _view.Msg = "团组成员暂未录入!!!";
  5012. return _view;
  5013. }
  5014. //获取模板
  5015. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5016. //载入模板
  5017. Document doc = new Document(tempPath);
  5018. DocumentBuilder builder = new DocumentBuilder(doc);
  5019. //获取word里所有表格
  5020. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5021. //获取所填表格的序数
  5022. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5023. var rowStart = tableOne.Rows[0]; //获取第1行
  5024. //循环赋值
  5025. for (int i = 0; i < DeleClientList.Count; i++)
  5026. {
  5027. builder.MoveToCell(0, i + 1, 0, 0);
  5028. builder.Write(DeleClientList[i].Name);
  5029. builder.MoveToCell(0, i + 1, 1, 0);
  5030. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5031. builder.Write(sex);
  5032. builder.MoveToCell(0, i + 1, 2, 0);
  5033. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5034. builder.MoveToCell(0, i + 1, 3, 0);
  5035. builder.Write(DeleClientList[i].Company);
  5036. builder.MoveToCell(0, i + 1, 4, 0);
  5037. builder.Write(DeleClientList[i].Job);
  5038. }
  5039. //删除多余行
  5040. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5041. {
  5042. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5043. }
  5044. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5045. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5046. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5047. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5048. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5049. _view.Data = new { Url = url };
  5050. _view.Msg = "成功";
  5051. return _view;
  5052. }
  5053. }
  5054. }
  5055. catch (Exception ex)
  5056. {
  5057. _view.Code = StatusCodes.Status500InternalServerError;
  5058. _view.Msg = ex.Message;
  5059. return _view;
  5060. }
  5061. return _view;
  5062. }
  5063. #endregion
  5064. #region 机票费用提示
  5065. /// <summary>
  5066. /// 三公机票费用提示
  5067. /// </summary>
  5068. /// <param name="diId"></param>
  5069. /// <returns></returns>
  5070. public static async Task<EntryAndExitTipsView[]> EntryAndExitTips(int diId)
  5071. {
  5072. if (diId < 1) return Array.Empty<EntryAndExitTipsView>();
  5073. var airFees = await _sqlSugar.Queryable<Air_TicketBlackCode>().Where(a => a.IsDel == 0 && a.DiId == diId).ToListAsync();
  5074. if (airFees.Any())
  5075. {
  5076. var result = new List<EntryAndExitTipsView>();
  5077. foreach (var x in airFees)
  5078. {
  5079. string tripDesc = "";
  5080. if (!string.IsNullOrEmpty(x.BlackCode))
  5081. {
  5082. var redisKeyName = string.Format("AirTripDesc_{0}_{1}", x.DiId, x.Id);
  5083. tripDesc = await KIMIAirTripCodeRec(redisKeyName, x.BlackCode);
  5084. }
  5085. result.Add(new EntryAndExitTipsView
  5086. {
  5087. jjcCurrentRate = x.ECPrice,
  5088. gwcCurrentRate = x.BCPrice,
  5089. tdcCurrentRate = x.FCPrice,
  5090. remark = $"经济舱全价:{x.ECPrice.ToString("#0.00")} 元/人 公务舱全价:{x.BCPrice.ToString("#0.00")} 元/人 头等舱全价:{x.FCPrice.ToString("#0.00")} 元/人",
  5091. TripDesc = tripDesc
  5092. });
  5093. }
  5094. return result.OrderByDescending(x => x.jjcCurrentRate + x.gwcCurrentRate + x.tdcCurrentRate).ToArray();
  5095. }
  5096. return Array.Empty<EntryAndExitTipsView>();
  5097. }
  5098. /// <summary>
  5099. /// 机票行程代码识别
  5100. /// </summary>
  5101. /// <param name="redisKeyName">redis缓存名称(名称定义格式:AirTripDesc_Diid_Id)</param>
  5102. /// <param name="msg"></param>
  5103. /// <returns></returns>
  5104. public static async Task<string> KIMIAirTripCodeRec(string redisKeyName, string msg)
  5105. {
  5106. string result = string.Empty;
  5107. if (!string.IsNullOrEmpty(redisKeyName))
  5108. {
  5109. result = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>(redisKeyName);//string 取
  5110. if (!string.IsNullOrEmpty(result)) return result;
  5111. }
  5112. if (string.IsNullOrEmpty(msg)) return result;
  5113. KiMiApiClient KiMiApi = new KiMiApiClient();
  5114. var kimiMsgs = new List<SeedMessages>() {
  5115. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  5116. new SeedMessages { Role = KimiRole.user, Content = "请将提供的三字码行程信息翻译成中文,每条信息独立一行,并在次日到达的时间后加上“+1”以表示次日。日期(星期)格式请按照“04月14日(星期一)”标注。航站楼信息请按照“T1”、“T2”、“ ”等格式标注。只输出正文数据,不要除正文数据外的任何文字以及符号。格式示例如下:\r\n1. CA445 05月17日(星期六) 成都天府 T1 - 米兰马尔彭萨 T1 01:50 06:55" },
  5117. new SeedMessages { Role = KimiRole.user, Content = msg }
  5118. };
  5119. var kimiApiResult = await KiMiApi.SeedMessage(kimiMsgs);
  5120. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  5121. result = kimiApiResult_JObject["content"].ToString();
  5122. if (!string.IsNullOrEmpty(result))
  5123. {
  5124. TimeSpan ts = TimeSpan.FromHours(2); //过期时间 2 小时
  5125. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>(redisKeyName, result, ts);//string 存
  5126. }
  5127. return result;
  5128. }
  5129. #endregion
  5130. #endregion
  5131. #region Excel导出服务
  5132. #region 类
  5133. public class FileExportSettings
  5134. {
  5135. public string ExportBasePath { get; set; } = "wwwroot/exports";
  5136. public string DownloadBaseUrl { get; set; } = "/exports";
  5137. public int RetentionDays { get; set; } = 7;
  5138. public int MaxFileSizeMB { get; set; } = 50;
  5139. public string ExcelTemplatesPath { get; set; } = "Templates/Excel";
  5140. }
  5141. public class ExportResult
  5142. {
  5143. public bool Success { get; set; }
  5144. public string FilePath { get; set; }
  5145. public string DownloadUrl { get; set; }
  5146. public string FileName { get; set; }
  5147. public long FileSize { get; set; }
  5148. public string MimeType { get; set; } = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
  5149. public string ErrorMessage { get; set; }
  5150. public DateTime GeneratedAt { get; set; } = DateTime.Now;
  5151. }
  5152. public class ExportRequest
  5153. {
  5154. public IEnumerable<object> Data { get; set; }
  5155. public string FileName { get; set; }
  5156. public string SheetName { get; set; } = "Sheet1";
  5157. public string TemplateType { get; set; } = "default";
  5158. public Dictionary<string, string> CustomHeaders { get; set; }
  5159. }
  5160. public class ExportResponse
  5161. {
  5162. public string FilePath { get; set; }
  5163. public string DownloadUrl { get; set; }
  5164. public string FileName { get; set; }
  5165. public long FileSize { get; set; }
  5166. public DateTime GeneratedAt { get; set; }
  5167. public string Message { get; set; }
  5168. }
  5169. #endregion
  5170. public static async Task<ExportResult> ExportToExcel<T>(IEnumerable<T> data, string fileName, string sheetName = "Sheet1", string templateType = "default")
  5171. {
  5172. try
  5173. {
  5174. byte[] excelBytes = templateType.ToLower() switch
  5175. {
  5176. "styled" => GenerateStyledExcel(data, sheetName),
  5177. "with_formulas" => GenerateExcelWithFormulas(data, sheetName),
  5178. //"with_charts" => GenerateExcelWithCharts(data, sheetName),
  5179. _ => GenerateDefaultExcel(data, sheetName)
  5180. };
  5181. var filePath = await SaveFileAsync(excelBytes, fileName, "excel");
  5182. var downloadUrl = $"wwwroot/exports/{filePath}";
  5183. return new ExportResult
  5184. {
  5185. Success = true,
  5186. FilePath = filePath,
  5187. DownloadUrl = downloadUrl,
  5188. FileName = Path.GetFileName(filePath),
  5189. FileSize = excelBytes.Length,
  5190. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5191. };
  5192. }
  5193. catch (Exception ex)
  5194. {
  5195. return new ExportResult
  5196. {
  5197. Success = false,
  5198. ErrorMessage = ex.Message
  5199. };
  5200. }
  5201. }
  5202. public static async Task<ExportResult> ExportWithTemplate<T>(IEnumerable<T> data, byte[] templateBytes, string fileName, string sheetName = "Sheet1")
  5203. {
  5204. try
  5205. {
  5206. using var templateStream = new MemoryStream(templateBytes);
  5207. using var workbook = new Workbook(templateStream);
  5208. var worksheet = workbook.Worksheets[sheetName] ?? workbook.Worksheets[0];
  5209. // 查找数据起始行(可以根据模板中的标记来定位)
  5210. int startRow = FindDataStartRow(worksheet);
  5211. // 填充数据
  5212. FillWorksheetWithData(worksheet, data, startRow);
  5213. using var outputStream = new MemoryStream();
  5214. workbook.Save(outputStream, Aspose.Cells.SaveFormat.Xlsx);
  5215. var excelBytes = outputStream.ToArray();
  5216. var filePath = await SaveFileAsync(excelBytes, fileName, "excel/templates");
  5217. var downloadUrl = $"wwwroot/exports/exports/{filePath}";
  5218. return new ExportResult
  5219. {
  5220. Success = true,
  5221. FilePath = filePath,
  5222. DownloadUrl = downloadUrl,
  5223. FileName = Path.GetFileName(filePath),
  5224. FileSize = excelBytes.Length,
  5225. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5226. };
  5227. }
  5228. catch (Exception ex)
  5229. {
  5230. return new ExportResult
  5231. {
  5232. Success = false,
  5233. ErrorMessage = ex.Message
  5234. };
  5235. }
  5236. }
  5237. public static async Task<ExportResult> ExportMultipleSheets<T>(Dictionary<string, IEnumerable<T>> sheetsData, string fileName)
  5238. {
  5239. try
  5240. {
  5241. using var workbook = new Workbook();
  5242. workbook.Worksheets.Clear(); // 清除默认工作表
  5243. foreach (var sheet in sheetsData)
  5244. {
  5245. var worksheet = workbook.Worksheets.Add(sheet.Key);
  5246. var data = sheet.Value;
  5247. if (data != null && data.Any())
  5248. {
  5249. FillWorksheetWithData(worksheet, data, 0);
  5250. worksheet.AutoFitColumns();
  5251. }
  5252. }
  5253. using var stream = new MemoryStream();
  5254. workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5255. var excelBytes = stream.ToArray();
  5256. var filePath = await SaveFileAsync(excelBytes, fileName, "excel/multi-sheets");
  5257. var downloadUrl = $"wwwroot/exports/exports/{filePath}";
  5258. return new ExportResult
  5259. {
  5260. Success = true,
  5261. FilePath = filePath,
  5262. DownloadUrl = downloadUrl,
  5263. FileName = Path.GetFileName(filePath),
  5264. FileSize = excelBytes.Length,
  5265. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5266. };
  5267. }
  5268. catch (Exception ex)
  5269. {
  5270. return new ExportResult
  5271. {
  5272. Success = false,
  5273. ErrorMessage = ex.Message
  5274. };
  5275. }
  5276. }
  5277. public static async Task<ExportResult> ExportWithCustomHeaders<T>(IEnumerable<T> data, Dictionary<string, string> headers, string fileName, string sheetName = "Sheet1")
  5278. {
  5279. try
  5280. {
  5281. using var workbook = new Workbook();
  5282. var worksheet = workbook.Worksheets[0];
  5283. worksheet.Name = sheetName;
  5284. // 设置自定义表头
  5285. int colIndex = 0;
  5286. foreach (var header in headers)
  5287. {
  5288. worksheet.Cells[0, colIndex].PutValue(header.Value);
  5289. colIndex++;
  5290. }
  5291. // 填充数据
  5292. if (data != null && data.Any())
  5293. {
  5294. int rowIndex = 1;
  5295. var properties = typeof(T).GetProperties();
  5296. foreach (var item in data)
  5297. {
  5298. colIndex = 0;
  5299. foreach (var header in headers)
  5300. {
  5301. var property = properties.FirstOrDefault(p => p.Name == header.Key);
  5302. if (property != null)
  5303. {
  5304. var value = property.GetValue(item);
  5305. worksheet.Cells[rowIndex, colIndex].PutValue(value);
  5306. }
  5307. colIndex++;
  5308. }
  5309. rowIndex++;
  5310. }
  5311. }
  5312. worksheet.AutoFitColumns();
  5313. using var stream = new MemoryStream();
  5314. workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5315. var excelBytes = stream.ToArray();
  5316. var filePath = await SaveFileAsync(excelBytes, fileName, "excel/custom-headers");
  5317. var downloadUrl = $"filePath";
  5318. return new ExportResult
  5319. {
  5320. Success = true,
  5321. FilePath = filePath,
  5322. DownloadUrl = downloadUrl,
  5323. FileName = Path.GetFileName(filePath),
  5324. FileSize = excelBytes.Length,
  5325. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5326. };
  5327. }
  5328. catch (Exception ex)
  5329. {
  5330. return new ExportResult
  5331. {
  5332. Success = false,
  5333. ErrorMessage = ex.Message
  5334. };
  5335. }
  5336. }
  5337. private static byte[] GenerateDefaultExcel<T>(IEnumerable<T> data, string sheetName)
  5338. {
  5339. using var workbook = new Workbook();
  5340. var worksheet = workbook.Worksheets[0];
  5341. worksheet.Name = sheetName;
  5342. if (data != null && data.Any())
  5343. {
  5344. FillWorksheetWithData(worksheet, data, 0);
  5345. worksheet.AutoFitColumns();
  5346. }
  5347. return SaveWorkbookToBytes(workbook);
  5348. }
  5349. private static byte[] GenerateStyledExcel<T>(IEnumerable<T> data, string sheetName)
  5350. {
  5351. using var workbook = new Workbook();
  5352. var worksheet = workbook.Worksheets[0];
  5353. worksheet.Name = sheetName;
  5354. if (data != null && data.Any())
  5355. {
  5356. FillWorksheetWithData(worksheet, data, 0);
  5357. // 设置样式
  5358. var headerStyle = workbook.CreateStyle();
  5359. headerStyle.Pattern = BackgroundType.Solid;
  5360. headerStyle.ForegroundColor = System.Drawing.Color.LightGray;
  5361. headerStyle.Font.IsBold = true;
  5362. headerStyle.HorizontalAlignment = TextAlignmentType.Center;
  5363. var properties = typeof(T).GetProperties();
  5364. Aspose.Cells.Range headerRange = worksheet.Cells.CreateRange(0, 0, 1, properties.Length);
  5365. headerRange.ApplyStyle(headerStyle, new StyleFlag { All = true });
  5366. worksheet.AutoFitColumns();
  5367. }
  5368. return SaveWorkbookToBytes(workbook);
  5369. }
  5370. private static byte[] GenerateExcelWithFormulas<T>(IEnumerable<T> data, string sheetName)
  5371. {
  5372. using var workbook = new Workbook();
  5373. var worksheet = workbook.Worksheets[0];
  5374. worksheet.Name = sheetName;
  5375. if (data != null && data.Any())
  5376. {
  5377. FillWorksheetWithData(worksheet, data, 0);
  5378. // 添加公式(例如:求和公式)
  5379. var properties = typeof(T).GetProperties();
  5380. int lastRow = data.Count() + 1;
  5381. for (int i = 0; i < properties.Length; i++)
  5382. {
  5383. if (IsNumericType(properties[i].PropertyType))
  5384. {
  5385. worksheet.Cells[lastRow, i].Formula = $"=SUM({worksheet.Cells[1, i].Name}:{worksheet.Cells[lastRow - 1, i].Name})";
  5386. }
  5387. }
  5388. worksheet.AutoFitColumns();
  5389. }
  5390. return SaveWorkbookToBytes(workbook);
  5391. }
  5392. private static void FillWorksheetWithData<T>(Worksheet worksheet, IEnumerable<T> data, int startRow)
  5393. {
  5394. var properties = typeof(T).GetProperties();
  5395. // 设置表头
  5396. for (int i = 0; i < properties.Length; i++)
  5397. {
  5398. worksheet.Cells[startRow, i].PutValue(properties[i].Name);
  5399. }
  5400. // 填充数据
  5401. int rowIndex = startRow + 1;
  5402. foreach (var item in data)
  5403. {
  5404. for (int colIndex = 0; colIndex < properties.Length; colIndex++)
  5405. {
  5406. var value = properties[colIndex].GetValue(item);
  5407. worksheet.Cells[rowIndex, colIndex].PutValue(value);
  5408. }
  5409. rowIndex++;
  5410. }
  5411. }
  5412. private static int FindDataStartRow(Worksheet worksheet)
  5413. {
  5414. // 在实际项目中,可以根据模板中的特定标记来定位数据起始行
  5415. // 例如查找 "{{DATA_START}}" 这样的标记
  5416. for (int row = 0; row < 50; row++)
  5417. {
  5418. for (int col = 0; col < 10; col++)
  5419. {
  5420. var value = worksheet.Cells[row, col].StringValue;
  5421. if (value == "{{DATA_START}}")
  5422. {
  5423. worksheet.Cells[row, col].PutValue(""); // 清空标记
  5424. return row + 1;
  5425. }
  5426. }
  5427. }
  5428. return 1; // 默认从第2行开始
  5429. }
  5430. private static byte[] SaveWorkbookToBytes(Workbook workbook)
  5431. {
  5432. using var stream = new MemoryStream();
  5433. workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5434. return stream.ToArray();
  5435. }
  5436. private static bool IsNumericType(Type type)
  5437. {
  5438. return Type.GetTypeCode(type) switch
  5439. {
  5440. TypeCode.Byte or TypeCode.SByte or TypeCode.UInt16 or TypeCode.UInt32 or
  5441. TypeCode.UInt64 or TypeCode.Int16 or TypeCode.Int32 or TypeCode.Int64 or
  5442. TypeCode.Decimal or TypeCode.Double or TypeCode.Single => true,
  5443. _ => false
  5444. };
  5445. }
  5446. public static async Task<string> SaveFileAsync(byte[] fileData, string fileName, string subFolder = "")
  5447. {
  5448. try
  5449. {
  5450. var basePath = "wwwroot/exports/exports";
  5451. var folderPath = Path.Combine(basePath, subFolder);
  5452. Directory.CreateDirectory(folderPath);
  5453. var uniqueFileName = $"{Path.GetFileNameWithoutExtension(fileName)}_{Guid.NewGuid():N}{Path.GetExtension(fileName)}.xlsx";
  5454. var filePath = Path.Combine(folderPath, uniqueFileName);
  5455. await System.IO.File.WriteAllBytesAsync(filePath, fileData);
  5456. var relativePath = Path.Combine(basePath, subFolder, uniqueFileName).Replace("\\", "/");
  5457. return relativePath;
  5458. }
  5459. catch (Exception ex)
  5460. {
  5461. throw;
  5462. }
  5463. }
  5464. #endregion
  5465. }
  5466. }