GeneralMethod.cs 275 KB

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