GeneralMethod.cs 248 KB

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