GeneralMethod.cs 267 KB

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