GeneralMethod.cs 263 KB

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