GeneralMethod.cs 304 KB

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