GeneralMethod.cs 197 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450
  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 OASystem.API.OAMethodLib.APNs;
  9. using OASystem.API.OAMethodLib.File;
  10. using OASystem.API.OAMethodLib.Hub.HubClients;
  11. using OASystem.API.OAMethodLib.Hub.Hubs;
  12. using OASystem.API.OAMethodLib.JuHeAPI;
  13. using OASystem.API.OAMethodLib.SignalR.Hubs;
  14. using OASystem.Domain.Dtos.Groups;
  15. using OASystem.Domain.Entities.Customer;
  16. using OASystem.Domain.Entities.Financial;
  17. using OASystem.Domain.Entities.Groups;
  18. using OASystem.Domain.ViewModels.Financial;
  19. using OASystem.Domain.ViewModels.Groups;
  20. using OASystem.Domain.ViewModels.JuHeExchangeRate;
  21. using OASystem.Infrastructure.Repositories.CRM;
  22. using OASystem.Infrastructure.Repositories.Groups;
  23. using OASystem.Infrastructure.Repositories.Login;
  24. using OfficeOpenXml;
  25. using System.Data;
  26. using System.IdentityModel.Tokens.Jwt;
  27. using System.Security.Claims;
  28. namespace OASystem.API.OAMethodLib
  29. {
  30. public static class GeneralMethod
  31. {
  32. //团组信息
  33. private static readonly SqlSugarClient _sqlSugar = AutofacIocManager.Instance.GetService<SqlSugarClient>();
  34. private static readonly DelegationInfoRepository _dirRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
  35. private static readonly TeamRateRepository _teamRateRep = AutofacIocManager.Instance.GetService<TeamRateRepository>();
  36. private static readonly IJuHeApiService _juHeApi = AutofacIocManager.Instance.GetService<IJuHeApiService>();
  37. private static readonly SetDataRepository _setDataRep = AutofacIocManager.Instance.GetService<SetDataRepository>();
  38. private static readonly TableOperationRecordRepository _tableOperationRecordRep = AutofacIocManager.Instance.GetService<TableOperationRecordRepository>();
  39. private static readonly MessageRepository _messageRep = AutofacIocManager.Instance.GetService<MessageRepository>();
  40. private static readonly IHubContext<ChatHub, IChatClient> _hubContext = AutofacIocManager.Instance.GetService<IHubContext<ChatHub, IChatClient>>();
  41. private readonly static string[] weekdays = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  42. #region 员工注册默认添加基础页面
  43. /// <summary>
  44. /// 默认职位权限
  45. /// </summary>
  46. public static bool DefaultPostAuth(int depId, int postId, int userId, int createUserId)
  47. {
  48. if (depId < 1) return false;
  49. if (postId < 1) return false;
  50. if (userId < 1) return false;
  51. if (userId < 1) return false;
  52. List<DefaultPostPageAuthView> _defaultData = AppSettingsHelper.Get<DefaultPostPageAuthView>("DefaultPostPageData");
  53. if (_defaultData.Count < 1) return false;
  54. var postJobDatas = _dirRep._sqlSugar.Queryable<Sys_JobPost>().Where(it => it.IsDel == 0).ToList();
  55. List<int> pageData = new List<int>();
  56. //添加公司公共页面
  57. pageData.AddRange(_defaultData.Find(it => it.DepId == -1)?.PostPageAuths[0].PageIds ?? new List<int>());
  58. //添加部门页面
  59. var depPublicPageData = _defaultData.Find(it => it.DepId == depId);
  60. var jobPublicPageData = postJobDatas.Find(it => it.DepId == depId && it.Id == postId);
  61. if (depPublicPageData != null) //特殊部门
  62. {
  63. //公共页面
  64. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == -1)?.PageIds ?? new List<int>());
  65. if (depId == 7) //国交部特殊处理
  66. {
  67. List<string> postNames = new List<string>() { "主管", "经理" };
  68. //岗位页面
  69. if (jobPublicPageData != null)
  70. {
  71. if (postNames.Contains(jobPublicPageData.JobName))
  72. {
  73. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == 0)?.PageIds ?? new List<int>());
  74. }
  75. else
  76. {
  77. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == postId)?.PageIds ?? new List<int>());
  78. }
  79. }
  80. }
  81. }
  82. else //通用部门
  83. {
  84. pageData.AddRange(_defaultData.Find(it => it.DepId == 0)?.PostPageAuths[0].PageIds ?? new List<int>());
  85. }
  86. if (pageData.Count > 0)
  87. {
  88. //页面操作权限数据(添加修改等...)
  89. var pageFunctionData = _dirRep._sqlSugar.Queryable<Sys_SystemMenuAndFunction>().Where(it => pageData.Contains(it.SmId) && it.IsDel == 0).ToList();
  90. var defaultPageData = pageFunctionData.Select(it => new Sys_UserAuthority()
  91. {
  92. UId = userId,
  93. SmId = it.SmId,
  94. FId = it.FId,
  95. CreateUserId = createUserId, //管理员
  96. CreateTime = DateTime.Now,
  97. IsDel = 0,
  98. IsTemp = 1
  99. }).ToList();
  100. if (defaultPageData.Count > 0)
  101. {
  102. //移除每个页面的审核权限,审核权限需要单独开启
  103. defaultPageData = defaultPageData.Where(it => it.FId != 12).ToList();
  104. //添加页面操作权限
  105. var s = _dirRep._sqlSugar.Fastest<Sys_UserAuthority>().PageSize(100000).BulkCopy(defaultPageData);
  106. if (s > 0)
  107. {
  108. return true;
  109. }
  110. }
  111. }
  112. return false;
  113. }
  114. #endregion
  115. #region 消息
  116. /// <summary>
  117. /// 消息 发布And 通知
  118. /// </summary>
  119. /// <param name="msgTypeEnum">
  120. /// 消息类型
  121. /// 1 公告通知
  122. /// 2 团组流程管控通知
  123. /// 3 团组业务操作通知
  124. /// 4 团组费用审核消息
  125. /// 5 团组签证进度通知
  126. /// 6 团组任务进度通知
  127. /// 7 日付申请通知
  128. /// </param>
  129. /// <param name="title">消息标题</param>
  130. /// <param name="content">消息内容</param>
  131. /// <param name="userIds"></param>
  132. /// <param name="diId">团组id</param>
  133. /// <param name="param">团组id</param>
  134. /// <returns></returns>
  135. public static async Task<bool> MessageIssueAndNotification(MessageTypeEnum msgTypeEnum, string title, string content, List<int> userIds, int diId = 0, string param = "")
  136. {
  137. MessageDto messageDto = new()
  138. {
  139. Type = msgTypeEnum,
  140. IssuerId = 4,//管理员
  141. DiId = diId,
  142. Title = title,
  143. Content = content,
  144. ReleaseTime = DateTime.Now,
  145. UIdList = userIds,
  146. Param = param
  147. };
  148. var status = await _messageRep.AddMsg(messageDto);//添加消息
  149. if (status)
  150. {
  151. //给在线在用户发送消息
  152. var connIds = UserStore.OnlineUser.Where(it => userIds.Contains(it.UserId)).Select(it => it.ConnectionId).ToList();
  153. var notificationTypeStr1 = GetMsgNotificationType(msgTypeEnum);
  154. var notificationTypeStr = JsonConvert.SerializeObject(
  155. new
  156. {
  157. UserIds = userIds,
  158. Msg = $"您有一条{notificationTypeStr1}相关的消息!"
  159. }
  160. );
  161. await _hubContext.Clients.Clients(connIds).ReceiveMessage($"您有一条{notificationTypeStr1}相关的消息!");
  162. return true;
  163. }
  164. return false;
  165. }
  166. /// <summary>
  167. /// 根据消息类型 获取 消息通知类型
  168. /// </summary>
  169. /// <returns></returns>
  170. public static string GetMsgNotificationType(MessageTypeEnum msgTypeEnum)
  171. {
  172. int notificationType = 0;
  173. string notificationStr = "";
  174. List<NotificationTypeView> notificationTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
  175. notificationType = notificationTypeViews.Where(it => it.MsgTypeIds.Contains((int)msgTypeEnum)).Select(it => it.TypeId).FirstOrDefault();
  176. if (notificationType == 1021) notificationStr = "操作";
  177. else if (notificationType == 1020) notificationStr = "任务";
  178. return notificationStr;
  179. }
  180. #endregion
  181. #region md5 加密
  182. /// <summary>
  183. /// MD5加密,和动网上的16/32位MD5加密结果相同,
  184. /// 使用的UTF8编码
  185. /// </summary>
  186. /// <param name="source">待加密字串</param>
  187. /// <param name="length">16或32值之一,其它则采用.net默认MD5加密算法</param>
  188. /// <returns>加密后的字串</returns>
  189. public static string Encrypt(string source, int length = 32)
  190. {
  191. if (string.IsNullOrWhiteSpace(source))
  192. return string.Empty;
  193. HashAlgorithm hashAlgorithm = CryptoConfig.CreateFromName("MD5") as HashAlgorithm;
  194. byte[] bytes = Encoding.UTF8.GetBytes(source);
  195. byte[] hashValue = hashAlgorithm.ComputeHash(bytes);
  196. StringBuilder sb = new StringBuilder();
  197. switch (length)
  198. {
  199. case 16://16位密文是32位密文的9到24位字符
  200. for (int i = 4; i < 12; i++)
  201. {
  202. sb.Append(hashValue[i].ToString("x2"));
  203. }
  204. break;
  205. case 32:
  206. for (int i = 0; i < 16; i++)
  207. {
  208. sb.Append(hashValue[i].ToString("x2"));
  209. }
  210. break;
  211. default:
  212. for (int i = 0; i < hashValue.Length; i++)
  213. {
  214. sb.Append(hashValue[i].ToString("x2"));
  215. }
  216. break;
  217. }
  218. return sb.ToString();
  219. }
  220. #endregion
  221. #region jwt
  222. /// <summary>
  223. /// 获取token
  224. /// </summary>
  225. /// <param name="_config"></param>
  226. /// <param name="Number"></param>
  227. /// <param name="exp"></param>
  228. /// <returns></returns>
  229. public static async Task<string> GetToken(IConfiguration _config, string Number, int uId, string uName, DateTime exp)
  230. {
  231. string userId = Guid.NewGuid().ToString().Replace("-", "");
  232. var claims = new[] {
  233. new Claim(ClaimTypes.NameIdentifier, uName),
  234. new Claim(ClaimTypes.NameIdentifier, uId.ToString()),
  235. new Claim(ClaimTypes.NameIdentifier, userId),
  236. new Claim("Number",Number)
  237. };
  238. var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["JwtSecurityKey"]));
  239. var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
  240. var token = new JwtSecurityToken(
  241. issuer: "OASystem.com",
  242. audience: "OASystem.com",
  243. claims: claims,
  244. expires: exp,
  245. signingCredentials: creds);
  246. var identity = new ClaimsIdentity(claims, "login");
  247. var principal = new ClaimsPrincipal(identity);
  248. // await _httpContext.SignInAsync (CookieAuthenticationDefaults.AuthenticationScheme, principal);
  249. return new JwtSecurityTokenHandler().WriteToken(token);
  250. }
  251. #endregion
  252. #region 数据类型转换
  253. /// <summary>
  254. /// object 转 Int
  255. /// </summary>
  256. /// <param name="obj"></param>
  257. /// <returns></returns>
  258. public static int GetInt(this object obj)
  259. {
  260. if (obj == null)
  261. return 0;
  262. var number = 0;
  263. var reslut = Int32.TryParse(obj.ToString(), out number);
  264. return number;
  265. }
  266. private static DateTime _dateStart = new DateTime(1970, 1, 1, 8, 0, 0);
  267. private static long _longTime = 621355968000000000;
  268. private static int _samllTime = 10000000;
  269. /// <summary>
  270. /// 时间戳 转 datetime
  271. /// </summary>
  272. /// <param name="timeStamp"></param>
  273. /// <returns></returns>
  274. public static DateTime GetTimeSpmpToDate(this object timeStamp)
  275. {
  276. if (timeStamp == null) return _dateStart;
  277. DateTime dateTime = new DateTime(_longTime + Convert.ToInt64(timeStamp) * _samllTime, DateTimeKind.Utc).ToLocalTime();
  278. return dateTime;
  279. }
  280. #endregion
  281. #region 用户页面操作功能 权限
  282. /// <summary>
  283. /// 用户页面操作功能(可使用)
  284. /// </summary>
  285. /// <param name="userId">用户Id</param>
  286. /// <param name="PageId">页面Id</param>
  287. /// <returns></returns>
  288. public static async Task<PageFunAuthViewBase> PostUserPageFuncDatas(int userId, int PageId)
  289. {
  290. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  291. List<UserPageFuncView> userPageFuncDatas = new List<UserPageFuncView>();
  292. string sql = string.Format(@"Select ua.UId As UserId, u.CnName As UserName, pa.ModuleId,pa.ModuleName,pa.PageId,pa.PageName,pa.PageIsEnable,
  293. pa.PagePhoneIsEnable,pa.FuncId,pa.FuncName,pa.FuncIsEnable
  294. From Sys_UserAuthority ua
  295. Left Join Sys_Users u On ua.UId = u.Id
  296. Left Join (
  297. Select sd.Id As ModuleId,sd.Name As ModuleName, smp.Id As PageId,smp.Name As PageName,smp.IsEnable As PageIsEnable,
  298. smp.phoneIsEnable As PagePhoneIsEnable,pfp.Id As FuncId,pfp.FunctionName As FuncName,pfp.IsEnable As FuncIsEnable
  299. From Sys_SystemMenuAndFunction smaf
  300. Left Join Sys_SystemMenuPermission smp On smaf.SmId = smp.Id
  301. Left Join Sys_SetData sd On sd.STid = 5 And smp.Mid = sd.Id
  302. Left Join Sys_PageFunctionPermission pfp On smaf.FId = pfp.Id
  303. Where smaf.IsDel = 0 And smp.IsDel = 0 And pfp.IsDel = 0 And sd.IsDel = 0 And smp.IsEnable = 1
  304. ) As pa On ua.SmId = pa.PageId And ua.FId = pa.FuncId
  305. Where ua.IsDel = 0 And ua.UId = {0} And pa.PageId = {1}
  306. Order By ModuleId,PageId,FuncId Asc", userId, PageId);
  307. userPageFuncDatas = await _dirRep._sqlSugar.SqlQueryable<UserPageFuncView>(sql).ToListAsync();
  308. if (userPageFuncDatas.Count <= 0)
  309. {
  310. return pageFunAuth;
  311. }
  312. UserPageFuncView userPageFunc = new UserPageFuncView();
  313. //查询 1
  314. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 1).FirstOrDefault();
  315. if (userPageFunc != null) pageFunAuth.CheckAuth = 1;
  316. //删除 2
  317. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 2).FirstOrDefault();
  318. if (userPageFunc != null) pageFunAuth.DeleteAuth = 1;
  319. //编辑 3
  320. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 3).FirstOrDefault();
  321. if (userPageFunc != null) pageFunAuth.EditAuth = 1;
  322. //下载 4
  323. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 4).FirstOrDefault();
  324. if (userPageFunc != null) pageFunAuth.FilesDownloadAuth = 1;
  325. //上传 5
  326. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 5).FirstOrDefault();
  327. if (userPageFunc != null) pageFunAuth.FilesUploadAuth = 1;
  328. //添加 11
  329. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 11).FirstOrDefault();
  330. if (userPageFunc != null) pageFunAuth.AddAuth = 1;
  331. //审核 12
  332. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 12).FirstOrDefault();
  333. if (userPageFunc != null) pageFunAuth.AuditAuth = 1;
  334. return pageFunAuth;
  335. }
  336. #endregion
  337. #region 业务模块 团组权限
  338. /// <summary>
  339. /// 业务模块 团组操作权限
  340. /// 验证 并返回可操作的团
  341. /// </summary>
  342. /// <param name="diId">团组Id</param>
  343. /// <param name="userId">用户Id</param>
  344. /// <param name="CTable">业务模块Id</param>
  345. /// <returns></returns>
  346. public static async Task<Result> PostGroupOperationAuth(int diId, int userId, int CTable)
  347. {
  348. Result _result = new Result { Code = -1, Msg = "No Operation Authorty!" };
  349. if (CTable < 1)
  350. {
  351. _result.Msg = "请填写正确的用户Id!";
  352. return _result;
  353. }
  354. var data = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.DIId == diId && it.UId == userId && it.CTId == CTable && it.IsDel == 0).First();
  355. if (data == null)
  356. {
  357. _result.Msg = "你没有本团下的该业务模块操作,请联系主管分配操作权限!";
  358. }
  359. else
  360. {
  361. _result.Code = 0;
  362. }
  363. return _result;
  364. }
  365. /// <summary>
  366. /// 业务模块 团组操作权限
  367. /// 返回可操作的团
  368. /// </summary>
  369. /// <param name="diId">团组Id</param>
  370. /// <param name="userId">用户Id</param>
  371. /// <param name="CTable">业务模块Id</param>
  372. /// <returns></returns>
  373. public static async Task<List<Web_ShareGroupInfoView>> PostOperationAuthReturnGroupInfosAsync(int userId, int CTable)
  374. {
  375. var shareGroupInfoViews = new List<Web_ShareGroupInfoView>();
  376. var taskData = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.UId == userId && it.CTId == CTable && it.IsDel == 0).ToList();
  377. if (taskData.Count < 1) return shareGroupInfoViews;
  378. var diIds = string.Join(",", taskData.Select(it => it.DIId).ToList());
  379. var sql = string.Format(@"Select Id,TeamName,TourCode,ClientName,VisitCountry,VisitStartDate,VisitEndDate,VisitDays,VisitPNumber
  380. From Grp_DelegationInfo Where Id In({0}) And IsDel = 0 Order By Id Desc", diIds);
  381. shareGroupInfoViews = await _dirRep._sqlSugar.SqlQueryable<Web_ShareGroupInfoView>(sql).ToListAsync();
  382. return shareGroupInfoViews;
  383. }
  384. #endregion
  385. #region 团组相关
  386. #region 建团按国家默认添加汇率 / 默认权限分配
  387. /// <summary>
  388. /// 团组汇率
  389. /// 建团时 添加基础汇率 CNY
  390. /// 按国家 添加 默认币种
  391. /// </summary>
  392. /// <param name="userId"></param>
  393. /// <param name="diId"></param>
  394. /// <returns></returns>
  395. public static async Task<Result> PostGroupRateAddInit(int userId, int diId)
  396. {
  397. Result result = new() { Code = -2 };
  398. if (userId < 1)
  399. {
  400. result.Msg = string.Format(@"请传入正确的userId");
  401. return result;
  402. }
  403. if (diId < 1)
  404. {
  405. result.Msg = string.Format(@"请传入正确的DiId");
  406. return result;
  407. }
  408. //美元(USD):1.0000|欧元(EUR):1.0000|墨西哥比索(MXN):1.0000
  409. string rateInit = string.Format(@"人民币(CNY):1.0000");
  410. //var gropInfo = _dirRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == diId).First();
  411. //if (gropInfo == null)
  412. //{
  413. // result.Msg = $@"未查询到团组信息!";
  414. // return result;
  415. //}
  416. var juheRateData = await _juHeApi.GetExchangeRateAsync();
  417. if (juheRateData.Error_code != 0)
  418. {
  419. result.Msg = juheRateData.Reason;
  420. return result;
  421. }
  422. List<ExchangeRateModel> exchangeRateModels = (List<ExchangeRateModel>)juheRateData.Result;
  423. if (exchangeRateModels.Count <= 0)
  424. {
  425. result.Msg = $@"未查询到聚合接口汇率信息!";
  426. return result;
  427. }
  428. if (exchangeRateModels.Count > 0)
  429. {
  430. var codes = _dirRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  431. for (int i = 0; i < exchangeRateModels.Count; i++)
  432. {
  433. string currencyName = exchangeRateModels[i].Name;
  434. string code = "";
  435. var currencyData = codes.Where(it => it.Remark == currencyName).FirstOrDefault();
  436. if (currencyData != null)
  437. {
  438. code = currencyData.Name;
  439. decimal currRate = 0.00M;
  440. string MSellPri = exchangeRateModels[i].MSellPri;
  441. if (!string.IsNullOrEmpty(MSellPri))
  442. {
  443. currRate = Convert.ToDecimal(MSellPri) / 100M;
  444. }
  445. rateInit += $@"|{currencyName}({code}):{currRate.ToString("#0.0000")}";
  446. }
  447. }
  448. }
  449. var cTableIds = _dirRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  450. if (cTableIds.Count < 1)
  451. {
  452. result.Msg = $@"未查询到操作模块信息!";
  453. return result;
  454. }
  455. List<Grp_TeamRate> grp_TeamRates = new List<Grp_TeamRate>();
  456. foreach (var item in cTableIds)
  457. {
  458. grp_TeamRates.Add(
  459. new Grp_TeamRate() { DiId = diId, CTable = item.Id, Remark = rateInit, CreateUserId = userId }
  460. );
  461. }
  462. if (grp_TeamRates.Count > 0)
  463. {
  464. var addId = _teamRateRep._sqlSugar.Insertable(grp_TeamRates).ExecuteCommand();
  465. if (addId < 1)
  466. {
  467. result.Msg = string.Format(@"添加失败!");
  468. return result;
  469. }
  470. }
  471. result.Code = 0;
  472. result.Msg = string.Format(@"操作成功!");
  473. return result;
  474. }
  475. /// <summary>
  476. /// 团组任务分配
  477. /// 建团时 默认按照岗位分配权限
  478. /// </summary>
  479. /// <param name="userId"></param>
  480. /// <param name="diId"></param>
  481. /// <param name="companyId"></param>
  482. /// <returns></returns>
  483. public static async Task<Result> PostGroupAuthAddInit(int userId, int diId, int companyId = 2)
  484. {
  485. Result result = new() { Code = -2 };
  486. if (userId < 0)
  487. {
  488. result.Msg = string.Format(@"请传入正确的userId");
  489. return result;
  490. }
  491. if (companyId < 0)
  492. {
  493. result.Msg = string.Format(@"请传入正确的companyId");
  494. return result;
  495. }
  496. if (diId < 0)
  497. {
  498. result.Msg = string.Format(@"请传入正确的DiId");
  499. return result;
  500. }
  501. var usersData = await _teamRateRep._sqlSugar
  502. .Queryable<Sys_Users>()
  503. .LeftJoin<Sys_Department>((su, sd) => su.DepId == sd.Id && sd.IsDel == 0)
  504. .LeftJoin<Sys_JobPost>((su, sd, sjp) => su.JobPostId == sjp.Id && sjp.IsDel == 0)
  505. .Where(su => su.IsDel == 0)
  506. .Select((su, sd, sjp) => new
  507. {
  508. su.DepId,
  509. sd.DepName,
  510. su.JobPostId,
  511. sjp.JobName,
  512. su.Id,
  513. su.CnName
  514. })
  515. .ToListAsync();
  516. /*
  517. * 76 酒店预订 --> 国交部门 酒店,主管 岗位
  518. * 77 行程 --> 国交部门 经理,主管 岗位
  519. * 79 车/导游地接 --> 国交部门 OP,主管 岗位
  520. * 80 签证 --> 国交部门 签证 岗位
  521. * 81 邀请/公务活动 --> 国交部门 商邀 岗位
  522. * 82 团组客户保险 --> 国交部 经理,主管 岗位
  523. * 85 机票预订 --> 国交部门 机票 岗位
  524. * 98 其他款项 --> 总经办部门 总经理 岗位/国交部门(ALL) 岗位/财务部门(ALL) 岗位/策划部门(ALL) 岗位/人事部门 采购 岗位
  525. * 1015 超支费用,69 收款退还 --> 财务部门(ALL)岗位
  526. * 1015 超支费用 --> 国交部(ALL)岗位
  527. * 1081 文档下载 --> 国交部门 酒店,主管 岗位
  528. */
  529. var groupsTaskAssignments = new List<Grp_GroupsTaskAssignment>();
  530. // 76 酒店预订 --> 国交部门(7) 酒店(25)、主管(22) 岗位
  531. groupsTaskAssignments.AddRange(
  532. usersData
  533. .Where(it => it.DepId == 7 && (it.JobPostId == 25 || it.JobPostId == 22))
  534. .Select(it => new Grp_GroupsTaskAssignment()
  535. {
  536. DIId = diId,
  537. CTId = 76,
  538. UId = it.Id,
  539. CreateUserId = userId
  540. }).ToList()
  541. );
  542. // 77 行程 --> 国交部门(7) 经理(32),主管(22) 岗位
  543. groupsTaskAssignments.AddRange(
  544. usersData
  545. .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 32))
  546. .Select(it => new Grp_GroupsTaskAssignment()
  547. {
  548. DIId = diId,
  549. CTId = 77,
  550. UId = it.Id,
  551. CreateUserId = userId
  552. }).ToList()
  553. );
  554. //79 车/导游地接 --> 国交部门(7) OP(28)、主管(22) 岗位
  555. groupsTaskAssignments.AddRange(
  556. usersData.Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 28))
  557. .Select(it => new Grp_GroupsTaskAssignment()
  558. {
  559. DIId = diId,
  560. CTId = 79,
  561. UId = it.Id,
  562. CreateUserId = userId
  563. }).ToList()
  564. );
  565. //81 邀请/公务活动 --> 国交部门(7) 商邀(27) 岗位
  566. groupsTaskAssignments.AddRange(
  567. usersData.Where(it => it.DepId == 7 && it.JobPostId == 27)
  568. .Select(it => new Grp_GroupsTaskAssignment()
  569. {
  570. DIId = diId,
  571. CTId = 81,
  572. UId = it.Id,
  573. CreateUserId = userId
  574. }).ToList()
  575. );
  576. //2024年8月26日16点27分 “邀请公务活动分配给王鸽(UserID:149)”
  577. groupsTaskAssignments.Add(
  578. new Grp_GroupsTaskAssignment()
  579. {
  580. DIId = diId,
  581. CTId = 81,
  582. UId = 149,
  583. CreateUserId = userId
  584. }
  585. );
  586. //80 签证 --> 国交部门(7) 签证(26) 岗位
  587. groupsTaskAssignments.AddRange(
  588. usersData
  589. .Where(it => it.DepId == 7 && it.JobPostId == 26)
  590. .Select(it => new Grp_GroupsTaskAssignment()
  591. {
  592. DIId = diId,
  593. CTId = 80,
  594. UId = it.Id,
  595. CreateUserId = userId
  596. }).ToList()
  597. );
  598. //82 团组客户保险 --> 国交部(7) 经理(32),主管(22) 岗位
  599. //2024-06-25 默认将保险权限分配给签证岗。 签证(26) 岗位
  600. List<int> insurancePositions = new List<int>() { 32, 22, 26 };
  601. groupsTaskAssignments.AddRange(
  602. usersData
  603. .Where(it => it.DepId == 7 && insurancePositions.Contains(it.JobPostId))
  604. .Select(it => new Grp_GroupsTaskAssignment()
  605. {
  606. DIId = diId,
  607. CTId = 82,
  608. UId = it.Id,
  609. CreateUserId = userId
  610. }).ToList()
  611. );
  612. //85 机票预订 --> 国交部门(7) 机票(24),主管(22) 岗位
  613. groupsTaskAssignments.AddRange(
  614. usersData
  615. .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 24))
  616. .Select(it => new Grp_GroupsTaskAssignment()
  617. {
  618. DIId = diId,
  619. CTId = 85,
  620. UId = it.Id,
  621. CreateUserId = userId
  622. }).ToList()
  623. );
  624. //98 其他款项 --> 总经办部门(1) 总经理(1) 岗位/国交部门(7)(ALL) 岗位/财务部门(3)(ALL) 岗位/策划部门(5)(ALL) 岗位/人事部门(4) 采购(74) 岗位
  625. var depIds = new List<int>() { 7, 3, 5 };
  626. var jobIds = new List<int>() { 1, 74 };
  627. groupsTaskAssignments.AddRange(
  628. usersData
  629. .Where(it => depIds.Contains(it.DepId) || jobIds.Contains(it.JobPostId))
  630. .Select(it => new Grp_GroupsTaskAssignment()
  631. {
  632. DIId = diId,
  633. CTId = 98,
  634. UId = it.Id,
  635. CreateUserId = userId
  636. }).ToList()
  637. );
  638. //2024年8月26日16点27分 “其他款项分配给王鸽(UserID:149)”
  639. groupsTaskAssignments.Add(new Grp_GroupsTaskAssignment()
  640. {
  641. DIId = diId,
  642. CTId = 98,
  643. UId = 149,
  644. CreateUserId = userId
  645. }
  646. );
  647. //1015 超支费用,285 收款退还 --> 财务部门(ALL)岗位
  648. groupsTaskAssignments.AddRange(
  649. usersData
  650. .Where(it => it.DepId == 3)
  651. .Select(it => new Grp_GroupsTaskAssignment()
  652. {
  653. DIId = diId,
  654. CTId = 1015,
  655. UId = it.Id,
  656. CreateUserId = userId
  657. }).ToList()
  658. );
  659. groupsTaskAssignments.AddRange(
  660. usersData
  661. .Where(it => it.DepId == 3)
  662. .Select(it => new Grp_GroupsTaskAssignment()
  663. {
  664. DIId = diId,
  665. CTId = 285,
  666. UId = it.Id,
  667. CreateUserId = userId
  668. }).ToList()
  669. );
  670. //1015 超支费用 --> 国交部(ALL)岗位
  671. groupsTaskAssignments.AddRange(
  672. usersData
  673. .Where(it => it.DepId == 7)
  674. .Select(it => new Grp_GroupsTaskAssignment()
  675. {
  676. DIId = diId,
  677. CTId = 1015,
  678. UId = it.Id,
  679. CreateUserId = userId
  680. }).ToList()
  681. );
  682. if (groupsTaskAssignments.Count > 0)
  683. {
  684. var addId = await _teamRateRep._sqlSugar.Insertable(groupsTaskAssignments).ExecuteCommandAsync();
  685. }
  686. result.Code = 0;
  687. result.Msg = string.Format(@"操作成功!");
  688. return result;
  689. }
  690. #endregion
  691. #region 员工是否是市场部人员
  692. /// <summary>
  693. /// 验证市场部客户人员
  694. /// </summary>
  695. /// <param name="userId"></param>
  696. /// <returns></returns>
  697. public static async Task<bool> IsMarketingStaff(int userId)
  698. {
  699. var userInfos = await _dirRep._sqlSugar
  700. .Queryable<Sys_Users>()
  701. .InnerJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  702. .Where((u, d) => u.IsDel == 0 && u.Id == userId && d.DepName.Contains("市场部"))
  703. .ToListAsync();
  704. if (userInfos.Count > 0) return true;
  705. return false;
  706. }
  707. #endregion
  708. #region 三公费用相关
  709. /// <summary>
  710. /// 保存操作前汇率
  711. /// </summary>
  712. /// <param name="currUserId"></param>
  713. /// <returns></returns>
  714. public static async Task<bool> RateRecordSave(int currUserId, int diId, string linkModule)
  715. {
  716. //var selectData = await _enterExitCostRep._sqlSugar.Queryable<Sys_ExchangeRateRecord>()
  717. // .Where(x => Convert.ToDateTime(x.RateDateTime).ToString("yyyy-MM-dd").Equals(DateTime.Now.ToString("yyyy-MM-dd")))
  718. // .FirstAsync();
  719. //if (selectData != null) return false;
  720. var _currencyRate = await _juHeApi.PostItemRateAsync(new string[] { });
  721. string rateInfoStr = string.Empty;
  722. var oaCurrencyData = await _sqlSugar.Queryable<Sys_SetData>()
  723. .Where(x => x.IsDel == 0 && x.STid == 66)
  724. .ToListAsync();
  725. foreach (var rate in _currencyRate)
  726. {
  727. var oaCurrncy = oaCurrencyData.Find(x => x.Remark.Equals(rate.Name));
  728. if (oaCurrncy == null) continue;
  729. //美元(USD):7.5|
  730. rateInfoStr += $"{rate.Name}({oaCurrncy.Name}):{rate.FSellPri}|";
  731. }
  732. if (string.IsNullOrEmpty(rateInfoStr)) return false;
  733. var add = await _sqlSugar
  734. .Insertable<Sys_ExchangeRateRecord>(new Sys_ExchangeRateRecord()
  735. {
  736. DiId = diId,
  737. LinkModule = linkModule,
  738. RateDateTime = DateTime.Now,
  739. RateInfo = rateInfoStr,
  740. CreateUserId = currUserId,
  741. IsDel = 0
  742. })
  743. .ExecuteCommandAsync();
  744. return add > 0 ? true : false;
  745. }
  746. /// <summary>
  747. /// 三公费用导入收款账单数据
  748. /// </summary>
  749. /// <param name="groupId"></param>
  750. /// <returns></returns>
  751. public static async Task<List<Fin_ForeignReceivables>> ReceivablesImportFeeAsync(int groupId)
  752. {
  753. var data = new List<Fin_ForeignReceivables>();
  754. var enterExitCosts = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == groupId).FirstAsync();
  755. var dayAndCosts = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == groupId).ToListAsync();
  756. var dayOtherCosts = await _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == groupId).ToListAsync(); //其他款项
  757. if (enterExitCosts == null) return data;
  758. //数据源
  759. var stayData = dayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  760. var mealData = dayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  761. var miscellaneousData = dayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  762. var trainData = dayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  763. //筛选 陪同人员 = 1
  764. var groupClientList = await _sqlSugar.Queryable<Grp_TourClientList>()
  765. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id)
  766. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id)
  767. .LeftJoin<Sys_SetData>((tcl, dc, cc, sd) => tcl.ShippingSpaceTypeId == sd.Id)
  768. .Where(tcl => tcl.IsDel == 0 &&
  769. tcl.DiId == groupId &&
  770. tcl.IsAccompany == 1
  771. )
  772. .Select((tcl, dc, cc, sd) => new
  773. {
  774. DiId = tcl.DiId,
  775. CompanyId = cc.Id,
  776. CompanyName = cc.CompanyFullName,
  777. ClienId = dc.Id,
  778. ClientName = dc.FirstName + dc.LastName,
  779. SpaceId = tcl.ShippingSpaceTypeId,
  780. SpaceName = sd.Name
  781. })
  782. .ToListAsync();
  783. if (!groupClientList.Any()) return data;
  784. decimal domesticFeeTotal = 0.00M, //境内费用
  785. economyClassFeeTotal = 0.00M, //经济舱费用
  786. businessClassFeeTotal = 0.00M, //公务舱费用
  787. firstClassFeeTotal = 0.00M, //头等舱费用
  788. stayFeeTotal = 0.00M, //住宿费
  789. mealsFeeTotal = 0.00M, //餐食费
  790. miscellaneousFeeTotal = 0.00M, //公杂费
  791. trainFeeTotal = 0.00M, //培训费
  792. otherPriceTotal = 0.00M; //其他款项
  793. //境内费用(其他费用)
  794. if (enterExitCosts.ChoiceOne == 1) domesticFeeTotal = enterExitCosts.InsidePay;
  795. //住宿费
  796. if (enterExitCosts.ChoiceThree == 1) stayFeeTotal = stayData.Sum(x => x.SubTotal);
  797. //伙食费
  798. if (enterExitCosts.ChoiceFour == 1) mealsFeeTotal = mealData.Sum(x => x.SubTotal);
  799. //公杂费
  800. if (enterExitCosts.ChoiceFive == 1) miscellaneousFeeTotal = miscellaneousData.Sum(x => x.SubTotal);
  801. //培训费
  802. if (enterExitCosts.ChoiceSix == 1) trainFeeTotal = trainData.Sum(x => x.SubTotal);
  803. //其他款项
  804. if (enterExitCosts.OtherExpenses_Checked == 1) otherPriceTotal = dayOtherCosts.Sum(x => x.SubTotal);
  805. decimal otherFeeTotal = domesticFeeTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainFeeTotal + otherPriceTotal;
  806. //国际旅费合计
  807. //经济舱
  808. if (enterExitCosts.SumJJC == 1) economyClassFeeTotal = enterExitCosts.OutsideJJPay + otherFeeTotal;
  809. //公务舱
  810. if (enterExitCosts.SumGWC == 1) businessClassFeeTotal = enterExitCosts.OutsideGWPay + otherFeeTotal;
  811. //头等舱
  812. if (enterExitCosts.SumTDC == 1) firstClassFeeTotal = enterExitCosts.OutsideTDPay + otherFeeTotal;
  813. var groupClientListGroup = groupClientList.GroupBy(x => x.CompanyId);
  814. foreach (var item in groupClientListGroup)
  815. {
  816. var companyName = item.FirstOrDefault().CompanyName;
  817. var airTicketGroup = item.GroupBy(x => x.SpaceId);
  818. foreach (var airTicket in airTicketGroup)
  819. {
  820. int quantity = airTicket.Count();
  821. if (quantity > 0)
  822. {
  823. var price = 0.00M;
  824. var spaceName = airTicket.FirstOrDefault()?.SpaceName ?? string.Empty;
  825. if (spaceName.Equals("经济舱")) price = economyClassFeeTotal;
  826. else if (spaceName.Equals("公务舱")) price = businessClassFeeTotal;
  827. else if (spaceName.Equals("头等舱")) price = firstClassFeeTotal;
  828. if (price > 0)
  829. {
  830. decimal itemTotal = price * quantity;
  831. data.Add(new Fin_ForeignReceivables()
  832. {
  833. Id = 0,
  834. CreateTime = DateTime.Now,
  835. Diid = groupId,
  836. PriceName = $"{companyName}-{spaceName}",
  837. Price = price,
  838. Count = quantity,
  839. Unit = "人",
  840. ItemSumPrice = itemTotal,
  841. Currency = 836,
  842. Rate = 1.0000M,
  843. AddingWay = 2,
  844. Remark = "由出入境费用导入费用",
  845. });
  846. }
  847. }
  848. }
  849. }
  850. return data;
  851. }
  852. #endregion
  853. #endregion
  854. #region 团组汇率
  855. /// <summary>
  856. /// 团组汇率
  857. /// 获取板块 币种 及 汇率
  858. /// 76 酒店预订 77 行程 79 车/导游地接
  859. /// 80 签证 82 团组客户保险 85 机票预订
  860. /// 98 其他款项 285 收款退还
  861. /// </summary>
  862. /// <param name="teamRateModels"></param>
  863. /// <param name="cTable"></param>
  864. /// <param name="currencyCode"></param>
  865. /// <returns>
  866. /// string
  867. /// eg: CNY 1.0000
  868. /// </returns>
  869. public static async Task<string> PostGroupRateByCTableAndCurrency(List<TeamRateModelView> teamRateModels, int cTable, List<string> currencyCodes)
  870. {
  871. string str = "";
  872. List<string> currencyRates = new List<string>();
  873. TeamRateModelView hotelRateData = teamRateModels.Where(it => it.CTableId == cTable).FirstOrDefault();
  874. if (hotelRateData != null)
  875. {
  876. var hotelRates = hotelRateData.TeamRates;
  877. foreach (var item in currencyCodes)
  878. {
  879. if (!string.IsNullOrEmpty(item))
  880. {
  881. var hotelRateInfo = hotelRates.Where(it => it.CurrencyCode.Equals(item)).FirstOrDefault();
  882. if (hotelRateInfo != null)
  883. {
  884. string str1 = string.Format("{0} {1}\r\n", hotelRateInfo.CurrencyCode, hotelRateInfo.Rate.ToString("#0.0000"));
  885. currencyRates.Add(str1);
  886. }
  887. }
  888. }
  889. if (currencyRates != null || currencyRates.Count > 0)
  890. {
  891. currencyRates = currencyRates.Distinct().ToList();
  892. foreach (var item in currencyRates)
  893. {
  894. str += item;
  895. }
  896. }
  897. }
  898. return str;
  899. }
  900. /// <summary>
  901. /// 团组汇率 币种 Item (来源:团组汇率)
  902. /// 根据 团组Id And 业务类型(CTable)Id
  903. /// api处理CTable = 285,默认返回CNY
  904. /// </summary>
  905. /// <param name="portType"></param>
  906. /// <param name="diId"></param>
  907. /// <param name="cTable"></param>
  908. /// <returns></returns>
  909. public static async Task<TeamRateModelGeneralView> PostGroupTeamRateByDiIdAndCTableId(int portType, int diId, int cTable)
  910. {
  911. TeamRateModelGeneralView _view = new TeamRateModelGeneralView();
  912. _view = await _teamRateRep.PostGroupTeamRateByDiIdAndCTableId(portType, diId, cTable);
  913. return _view;
  914. }
  915. /// <summary>
  916. /// 汇率备注拆分
  917. /// (美元(USD):7.2370|日元(JPY):0.0499|欧元(EUR):8.3000|英镑(GBP):9.1996|港币(HKD):0.9291)
  918. /// </summary>
  919. /// <param name="rateRemark"></param>
  920. /// <returns></returns>
  921. public static async Task<List<TeamRateDescAddCurrencyIdView>> SplitExchangeRate(this string rateRemark)
  922. {
  923. List<TeamRateDescAddCurrencyIdView> _view = new List<TeamRateDescAddCurrencyIdView>();
  924. List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();
  925. #region 获取所有币种
  926. string sql = string.Format(@"select * from Sys_SetData where STid = {0} and isdel = 0", 66);
  927. var DBdata = _setDataRep.GetListBySqlWithNolock(sql);
  928. if (DBdata == null || DBdata.Count == 0)
  929. {
  930. return _view;
  931. }
  932. currencyDatas = DBdata.Select(x => new SetDataInfoView
  933. {
  934. Name = x.Name,
  935. Id = x.Id,
  936. Remark = x.Remark,
  937. }).ToList();
  938. #endregion
  939. #region 拆分remark里的汇率
  940. if (string.IsNullOrEmpty(rateRemark))
  941. {
  942. return _view;
  943. }
  944. if (rateRemark.Contains("|"))
  945. {
  946. string[] currencyArr = rateRemark.Split("|");
  947. foreach (string currency in currencyArr)
  948. {
  949. string[] currency1 = currency.Split(":");
  950. string[] currency2 = currency1[0].Split("(");
  951. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  952. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  953. {
  954. CurrencyId = currencyDatas.Find(it => it.Name == currencyCode).Id,
  955. CurrencyCode = currencyCode,
  956. CurrencyName = currency2[0],
  957. Rate = decimal.Parse(currency1[1]),
  958. };
  959. _view.Add(rateDescView);
  960. }
  961. }
  962. else
  963. {
  964. try
  965. {
  966. string[] currency1 = rateRemark.Split(":");
  967. string[] currency2 = currency1[0].Split("(");
  968. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  969. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  970. {
  971. CurrencyId = currencyDatas.Find(it => it.Name == currencyCode).Id,
  972. CurrencyCode = currencyCode,
  973. CurrencyName = currency2[0],
  974. Rate = decimal.Parse(currency1[1]),
  975. };
  976. _view.Add(rateDescView);
  977. }
  978. catch (Exception)
  979. {
  980. return _view;
  981. }
  982. }
  983. #endregion
  984. return _view;
  985. }
  986. #endregion
  987. #region 汉字转换拼音
  988. private static Dictionary<int, List<string>> GetTotalPingYinDictionary(string text)
  989. {
  990. var chs = text.ToCharArray();
  991. //记录每个汉字的全拼
  992. Dictionary<int, List<string>> totalPingYinList = new Dictionary<int, List<string>>();
  993. for (int i = 0; i < chs.Length; i++)
  994. {
  995. var pinyinList = new List<string>();
  996. //是否是有效的汉字
  997. if (ChineseChar.IsValidChar(chs[i]))
  998. {
  999. ChineseChar cc = new ChineseChar(chs[i]);
  1000. pinyinList = cc.Pinyins.Where(p => !string.IsNullOrWhiteSpace(p)).ToList();
  1001. }
  1002. else
  1003. {
  1004. pinyinList.Add(chs[i].ToString());
  1005. }
  1006. //去除声调,转小写
  1007. pinyinList = pinyinList.ConvertAll(p => Regex.Replace(p, @"\d", "").ToLower());
  1008. //去重
  1009. pinyinList = pinyinList.Where(p => !string.IsNullOrWhiteSpace(p)).Distinct().ToList();
  1010. if (pinyinList.Any())
  1011. {
  1012. totalPingYinList[i] = pinyinList;
  1013. }
  1014. }
  1015. return totalPingYinList;
  1016. }
  1017. /// <summary>
  1018. /// 获取汉语拼音全拼
  1019. /// </summary>
  1020. /// <param name="text">The string.</param>
  1021. /// <returns></returns>
  1022. public static List<string> GetTotalPingYin(this string text)
  1023. {
  1024. var result = new List<string>();
  1025. foreach (var pys in GetTotalPingYinDictionary(text))
  1026. {
  1027. var items = pys.Value;
  1028. if (result.Count <= 0)
  1029. {
  1030. result = items;
  1031. }
  1032. else
  1033. {
  1034. //全拼循环匹配
  1035. var newTotalPingYinList = new List<string>();
  1036. foreach (var totalPingYin in result)
  1037. {
  1038. newTotalPingYinList.AddRange(items.Select(item => totalPingYin + item));
  1039. }
  1040. newTotalPingYinList = newTotalPingYinList.Distinct().ToList();
  1041. result = newTotalPingYinList;
  1042. }
  1043. }
  1044. return result;
  1045. }
  1046. /// <summary>
  1047. /// 获取中文第一个拼音
  1048. /// </summary>
  1049. /// <param name="text"></param>
  1050. /// <param name="isUp"></param>
  1051. /// <returns></returns>
  1052. public static string GetTotalPingYinFirst(this string text, bool isUp = true)
  1053. {
  1054. var returnstr = string.Empty;
  1055. var enResult = text.GetTotalPingYin();
  1056. if (enResult.Count == 0)
  1057. {
  1058. returnstr = text;
  1059. }
  1060. else if (isUp)
  1061. {
  1062. returnstr = enResult[0].ToUpper();
  1063. }
  1064. else
  1065. {
  1066. returnstr = enResult[0].ToLower();
  1067. }
  1068. return returnstr;
  1069. }
  1070. /// <summary>
  1071. /// 获取汉语拼音首字母
  1072. /// </summary>
  1073. /// <param name="text"></param>
  1074. /// <returns></returns>
  1075. public static List<string> GetFirstPingYin(this string text)
  1076. {
  1077. var result = new List<string>();
  1078. foreach (var pys in GetTotalPingYinDictionary(text))
  1079. {
  1080. var items = pys.Value;
  1081. if (result.Count <= 0)
  1082. {
  1083. result = items.ConvertAll(p => p.Substring(0, 1)).Distinct().ToList();
  1084. }
  1085. else
  1086. {
  1087. //首字母循环匹配
  1088. var newFirstPingYinList = new List<string>();
  1089. foreach (var firstPingYin in result)
  1090. {
  1091. newFirstPingYinList.AddRange(items.Select(item => firstPingYin + item.Substring(0, 1)));
  1092. }
  1093. newFirstPingYinList = newFirstPingYinList.Distinct().ToList();
  1094. result = newFirstPingYinList;
  1095. }
  1096. }
  1097. return result;
  1098. }
  1099. #endregion
  1100. #region 新客户资料表 操作记录
  1101. /// <summary>
  1102. /// 新客户资料表
  1103. /// 操作记录添加
  1104. /// </summary>
  1105. /// <param name="portType"></param>
  1106. /// <param name="operationEnum"></param>
  1107. /// <param name="userId"></param>
  1108. /// <param name="dataId"></param>
  1109. /// <param name="remark"></param>
  1110. /// <returns></returns>
  1111. public static async Task<bool> NewClientOperationRecord(int portType, OperationEnum operationEnum, int userId, int dataId, string remark)
  1112. {
  1113. Crm_TableOperationRecord _TableOperationRecord = new Crm_TableOperationRecord()
  1114. {
  1115. TableName = "Crm_NewClientData",
  1116. PortType = portType,
  1117. OperationItem = operationEnum,
  1118. DataId = dataId,
  1119. CreateUserId = userId,
  1120. CreateTime = DateTime.Now,
  1121. Remark = remark
  1122. };
  1123. bool add = await _tableOperationRecordRep._Add(_TableOperationRecord);
  1124. if (add) return false;
  1125. return false;
  1126. }
  1127. #endregion
  1128. #region 金额转大写
  1129. /// <summary>
  1130. /// 金额转换为大写数字
  1131. /// <para>1、支持的最大数字:999999999999.99(玖仟玖佰玖拾玖亿玖仟玖佰玖拾玖万玖仟玖佰玖拾玖元玖角玖分)</para>
  1132. /// <para>2、小数点后最多支持两位</para>
  1133. /// </summary>
  1134. /// <param name="num">数值</param>
  1135. /// <returns></returns>
  1136. public static string ConvertCNYUpper(this decimal num)
  1137. {
  1138. if (num == 0)
  1139. {
  1140. return "零元";
  1141. }
  1142. // 解决327000000转换后缺少单位万的问题
  1143. return ConvertToChinese(num);
  1144. }
  1145. #region 实例
  1146. /// <summary>
  1147. /// 要转换的数字
  1148. /// </summary>
  1149. private static decimal j;
  1150. /// <summary>
  1151. ///
  1152. /// </summary>
  1153. private static string[] NumChineseCharacter = new string[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
  1154. /// <summary>
  1155. /// 判断输入的数字是否大于double类型
  1156. /// </summary>
  1157. private static bool IsNumber
  1158. {
  1159. get
  1160. {
  1161. if (j > decimal.MaxValue || j <= 0)
  1162. return false;
  1163. else
  1164. return true;
  1165. }
  1166. }
  1167. /// <summary>
  1168. /// 数字转换成大写汉字主函数
  1169. /// </summary>
  1170. /// <returns>返回转换后的大写汉字</returns>
  1171. public static string ConvertToChinese(decimal m)
  1172. {
  1173. j = m;
  1174. string bb = "";
  1175. if (IsNumber)
  1176. {
  1177. string str = j.ToString();
  1178. string[] Num = str.Split('.');
  1179. if (Num.Length == 1)
  1180. {
  1181. bb = NumberString(Num[0]) + "元整";
  1182. bb = bb.Replace("零零", "零");
  1183. }
  1184. else
  1185. {
  1186. bb = NumberString(Num[0]) + "元";
  1187. bb += FloatString(Num[1]);
  1188. bb = bb.Replace("零零", "零");
  1189. }
  1190. }
  1191. else
  1192. {
  1193. throw new FormatException("你输入的数字格式不正确或不是数字!");
  1194. }
  1195. return bb;
  1196. }
  1197. /// <summary>
  1198. /// 小数位转换只支持两位的小数
  1199. /// </summary>
  1200. /// <param name="Num">转换的小数</param>
  1201. /// <returns>小数转换成汉字</returns>
  1202. private static string FloatString(string Num)
  1203. {
  1204. string cc = "";
  1205. if (Num.Length > 2)
  1206. {
  1207. throw new FormatException("小数位数过多.");
  1208. }
  1209. else
  1210. {
  1211. string bb = ConvertString(Num);
  1212. int len = bb.IndexOf("零");
  1213. if (len != 0)
  1214. {
  1215. bb = bb.Replace("零", "");
  1216. if (bb.Length == 1)
  1217. {
  1218. cc = bb.Substring(0, 1) + "角";
  1219. }
  1220. else
  1221. {
  1222. cc = bb.Substring(0, 1) + "角";
  1223. cc += bb.Substring(1, 1) + "分";
  1224. }
  1225. }
  1226. else
  1227. cc = bb + "分";
  1228. }
  1229. return cc;
  1230. }
  1231. /// <summary>
  1232. /// 判断数字位数以进行拆分转换
  1233. /// </summary>
  1234. /// <param name="Num">要进行拆分的数字</param>
  1235. /// <returns>转换成的汉字</returns>
  1236. private static string NumberString(string Num)
  1237. {
  1238. string bb = "";
  1239. if (Num.Length <= 4)
  1240. {
  1241. bb = Convert4(Num);
  1242. }
  1243. else if (Num.Length > 4 && Num.Length <= 8)
  1244. {
  1245. bb = Convert4(Num.Substring(0, Num.Length - 4)) + "万";
  1246. bb += Convert4(Num.Substring(Num.Length - 4, 4));
  1247. }
  1248. else if (Num.Length > 8 && Num.Length <= 12)
  1249. {
  1250. bb = Convert4(Num.Substring(0, Num.Length - 8)) + "亿";
  1251. if (Convert4(Num.Substring(Num.Length - 8, 4)) == "")
  1252. if (Convert4(Num.Substring(Num.Length - 4, 4)) != "")
  1253. bb += "零";
  1254. else
  1255. bb += "";
  1256. else
  1257. bb += Convert4(Num.Substring(Num.Length - 8, 4)) + "万";
  1258. bb += Convert4(Num.Substring(Num.Length - 4, 4));
  1259. }
  1260. else
  1261. {
  1262. throw new Exception("整数部分最多支持12位");
  1263. }
  1264. return bb;
  1265. }
  1266. /// <summary>
  1267. /// 四位数字的转换
  1268. /// </summary>
  1269. /// <param name="Num">准备转换的四位数字</param>
  1270. /// <returns>转换以后的汉字</returns>
  1271. private static string Convert4(string Num)
  1272. {
  1273. string bb = "";
  1274. if (Num.Length == 1)
  1275. {
  1276. bb = ConvertString(Num);
  1277. }
  1278. else if (Num.Length == 2)
  1279. {
  1280. bb = ConvertString(Num);
  1281. bb = Convert2(bb);
  1282. }
  1283. else if (Num.Length == 3)
  1284. {
  1285. bb = ConvertString(Num);
  1286. bb = Convert3(bb);
  1287. }
  1288. else
  1289. {
  1290. bb = ConvertString(Num);
  1291. string cc = "";
  1292. string len = bb.Substring(0, 4);
  1293. if (len != "零零零零")
  1294. {
  1295. len = bb.Substring(0, 3);
  1296. if (len != "零零零")
  1297. {
  1298. bb = bb.Replace("零零零", "");
  1299. if (bb.Length == 1)
  1300. {
  1301. bb = bb.Substring(0, 1) + "仟";
  1302. }
  1303. else
  1304. {
  1305. if (bb.Substring(0, 1) != "零" && bb.Substring(0, 2) != "零")
  1306. cc = bb.Substring(0, 1) + "仟";
  1307. else
  1308. cc = bb.Substring(0, 1);
  1309. bb = cc + Convert3(bb.Substring(1, 3));
  1310. }
  1311. }
  1312. else
  1313. {
  1314. bb = bb.Replace("零零零", "零");
  1315. }
  1316. }
  1317. else
  1318. {
  1319. bb = bb.Replace("零零零零", "");
  1320. }
  1321. }
  1322. return bb;
  1323. }
  1324. /// <summary>
  1325. /// 将数字转换成汉字
  1326. /// </summary>
  1327. /// <param name="Num">需要转换的数字</param>
  1328. /// <returns>转换后的汉字</returns>
  1329. private static string ConvertString(string Num)
  1330. {
  1331. string bb = "";
  1332. for (int i = 0; i < Num.Length; i++)
  1333. {
  1334. bb += NumChineseCharacter[int.Parse(Num.Substring(i, 1))];
  1335. }
  1336. return bb;
  1337. }
  1338. /// <summary>
  1339. /// 两位数字的转换
  1340. /// </summary>
  1341. /// <param name="Num">两位数字</param>
  1342. /// <returns>转换后的汉字</returns>
  1343. private static string Convert2(string Num)
  1344. {
  1345. string bb = ""; string cc = "";
  1346. string len = Num.Substring(0, 1);
  1347. if (len != "零")
  1348. {
  1349. bb = Num.Replace("零", "");
  1350. if (bb.Length == 1)
  1351. {
  1352. cc = bb.Substring(0, 1) + "拾";
  1353. }
  1354. else
  1355. {
  1356. cc = bb.Substring(0, 1) + "拾";
  1357. cc += bb.Substring(1, 1);
  1358. }
  1359. }
  1360. else
  1361. cc = Num;
  1362. return cc;
  1363. }
  1364. /// <summary>
  1365. /// 三位数字的转换
  1366. /// </summary>
  1367. /// <param name="Num">三位数字</param>
  1368. /// <returns>转换后的汉字</returns>
  1369. private static string Convert3(string Num)
  1370. {
  1371. string bb = ""; string cc = "";
  1372. string len = Num.Substring(0, 2);
  1373. if (len != "零零")
  1374. {
  1375. bb = Num.Replace("零零", "");
  1376. if (bb.Length == 1)
  1377. {
  1378. bb = bb.Substring(0, 1) + "佰";
  1379. }
  1380. else
  1381. {
  1382. if (bb.Substring(0, 1) != "零")
  1383. cc = bb.Substring(0, 1) + "佰";
  1384. else
  1385. cc = bb.Substring(0, 1);
  1386. bb = cc + Convert2(bb.Substring(1, 2));
  1387. }
  1388. }
  1389. else
  1390. {
  1391. bb = Num.Replace("零零", "零");
  1392. }
  1393. return bb;
  1394. }
  1395. #endregion
  1396. #endregion
  1397. #region 数字验证
  1398. /// <summary>
  1399. /// 验证数字字符串
  1400. /// </summary>
  1401. /// <param name="num"></param>
  1402. /// <returns></returns>
  1403. public static bool IsNumeric(this string numStr)
  1404. {
  1405. bool isNumeric = Regex.IsMatch(numStr, @"^\d+$");
  1406. if (isNumeric)
  1407. {
  1408. return true;
  1409. }
  1410. return false;
  1411. }
  1412. #endregion
  1413. #region 日期 格式转换
  1414. /// <summary>
  1415. /// 验证数字字符串
  1416. /// </summary>
  1417. /// <param name="str"></param>
  1418. /// <returns></returns>
  1419. public static string ConvertToDatetime(this string str)
  1420. {
  1421. if (!string.IsNullOrEmpty(str))
  1422. {
  1423. DateTime currentDate = Convert.ToDateTime(str);
  1424. return $"{currentDate.Year}年{currentDate.Month}月{currentDate.Day}日";
  1425. }
  1426. return "";
  1427. }
  1428. #endregion
  1429. #region 月份/季度
  1430. /// <summary>
  1431. /// 获取月份对应的起始天数
  1432. /// </summary>
  1433. /// <param name="year"></param>
  1434. /// <returns></returns>
  1435. public static List<MonthInfo> GetMonthInfos(int year)
  1436. {
  1437. List<MonthInfo> months = new List<MonthInfo>();
  1438. if (year > 1)
  1439. {
  1440. for (int i = 1; i < 13; i++)
  1441. {
  1442. months.Add(new MonthInfo()
  1443. {
  1444. Month = i,
  1445. Days = new DaysInfo() { BeginDays = 1, EndDays = DateTime.DaysInMonth(year, i) }
  1446. });
  1447. }
  1448. }
  1449. return months;
  1450. }
  1451. /// <summary>
  1452. /// 获取季度对应的起始天数
  1453. /// </summary>
  1454. /// <param name="year"></param>
  1455. /// <returns></returns>
  1456. public static List<MonthInfo> GetQuarter(int year)
  1457. {
  1458. List<MonthInfo> months = new List<MonthInfo>();
  1459. months.Add(new MonthInfo() { Month = 1, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //1.1 - 3.31
  1460. months.Add(new MonthInfo() { Month = 2, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //4.1 - 6.30
  1461. months.Add(new MonthInfo() { Month = 3, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //7.1 - 9.31
  1462. months.Add(new MonthInfo() { Month = 4, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //10.1 - 12.31
  1463. return months;
  1464. }
  1465. public class MonthInfo
  1466. {
  1467. public int Month { get; set; }
  1468. public DaysInfo Days { get; set; }
  1469. }
  1470. public class DaysInfo
  1471. {
  1472. public int BeginDays { get; set; }
  1473. public int EndDays { get; set; }
  1474. }
  1475. #endregion
  1476. #region op行程单,黑屏幕代码
  1477. public static string GetCountryStandingTime(int diId)
  1478. {
  1479. DataTable datas = GetTableByBlackCode(diId);
  1480. string countryStr = "[黑屏代码未录入].";
  1481. if (datas.Rows.Count > 0)
  1482. {
  1483. var airDatas = from row in datas.AsEnumerable()
  1484. select new
  1485. {
  1486. Three = row.Field<string>("Three"),
  1487. Day = row.Field<string>("Day"),
  1488. ArrivedDate = row.Field<string>("ArrivedDate"),
  1489. };
  1490. //三字码信息
  1491. List<Res_ThreeCode> listcode = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToList();
  1492. //string countryStr = "";
  1493. int index = 0;
  1494. List<string> cityCodes = new List<string>();
  1495. //去掉开始和结束城市
  1496. foreach (var row in airDatas)
  1497. {
  1498. if (!string.IsNullOrEmpty(row.Three))
  1499. {
  1500. if (index == 0) cityCodes.Add(row.Three.Substring(3, 3)); //到达国家
  1501. else if (airDatas.Count() - 1 == index) cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
  1502. else cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
  1503. }
  1504. index++;
  1505. }
  1506. cityCodes = cityCodes.Distinct().ToList();
  1507. if (cityCodes.Count > 0) countryStr = "";
  1508. foreach (var item in cityCodes)
  1509. {
  1510. var airData = airDatas.Where(it => it.Three.Contains(item)).ToList();
  1511. string country = listcode.Find(it => it.Three.Equals(item))?.Country ?? "Unknown";
  1512. if (country.Equals("中国"))
  1513. {
  1514. country = listcode.Find(it => it.Three.Equals(item))?.City ?? "Unknown";
  1515. }
  1516. int days = 0;
  1517. if (airData.Count == 2)
  1518. {
  1519. DateTime arr_dt = Convert.ToDateTime(airData[0].ArrivedDate); //抵达时间
  1520. DateTime dep_dt = Convert.ToDateTime(airData[1].Day); //离开时间
  1521. //days = (dep_dt - arr_dt).Days;
  1522. //countryStr += $@"{country}停留{days}日、";
  1523. countryStr += $@"{country}停留 日、";
  1524. }
  1525. }
  1526. if (countryStr.Length > 0) countryStr = countryStr.Substring(0, countryStr.Length - 1);
  1527. }
  1528. return countryStr;
  1529. }
  1530. /// <summary>
  1531. ///根据机票黑屏代码整理DataTable
  1532. /// </summary>
  1533. /// <param name="diid"></param>
  1534. /// <returns></returns>
  1535. public static DataTable GetTableByBlackCode1(int diid)
  1536. {
  1537. //黑屏代码信息
  1538. List<Air_TicketBlackCode> listcode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  1539. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  1540. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  1541. DataTable dt = new DataTable();
  1542. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  1543. dt.Columns.Add("Date", typeof(string));//起飞日期
  1544. dt.Columns.Add("Three", typeof(string));//三字码
  1545. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  1546. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  1547. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  1548. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  1549. dt.Columns.Add("AirModel", typeof(string)); //机型
  1550. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  1551. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  1552. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  1553. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  1554. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  1555. //判断是否录入黑屏代码
  1556. if (listcode.Count() == 0 || listcode == null)
  1557. {
  1558. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  1559. }
  1560. else
  1561. {
  1562. //读取单段黑屏代码
  1563. for (int i = 0; i < listcode.Count; i++)
  1564. {
  1565. //去除序号
  1566. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  1567. //去除多余空格,方法一Linq扩展方法
  1568. CodeList = CodeList.Where(str => str != "").ToArray();
  1569. CodeList = CodeList.Where(str => str != " ").ToArray();
  1570. //年
  1571. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  1572. //读取单条黑屏代码
  1573. for (int j = 0; j < CodeList.Count(); j++)
  1574. {
  1575. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  1576. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  1577. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1578. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  1579. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1580. //去除多余空格
  1581. Info = Info.Where(str => str != "").ToArray();
  1582. Info = Info.Where(str => str != " ").ToArray();
  1583. //判断黑屏代码是否正确拆分; 理应拆成9段
  1584. if (Info.Count() < 9)
  1585. {
  1586. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  1587. }
  1588. else
  1589. {
  1590. try
  1591. {
  1592. //月
  1593. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  1594. //日
  1595. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  1596. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  1597. if (j > 0)
  1598. {
  1599. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  1600. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1601. Temp = Temp.Where(str => str != "").ToArray();
  1602. Temp = Temp.Where(str => str != " ").ToArray();
  1603. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  1604. // 如果相邻月份之差小于0,则证明次一条年份需+1
  1605. if (month - monthTemp < 0)
  1606. {
  1607. year = year + 1;
  1608. }
  1609. //如果相邻代码三字码不顶真,提醒
  1610. string FootThree = Temp[2].Substring(3, 3);
  1611. string HeadThree = Info[2].Substring(0, 3);
  1612. if (FootThree != HeadThree)
  1613. {
  1614. //DelegationInfoService s = new DelegationInfoService();
  1615. //UsersService us = new UsersService();
  1616. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  1617. //77 行程
  1618. List<Grp_GroupsTaskAssignment> list2 = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  1619. foreach (var temp in list2)
  1620. {
  1621. //if (temp.UId != 21)
  1622. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  1623. // "黑屏代码提醒",
  1624. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  1625. }
  1626. //85 机票预订
  1627. List<Grp_GroupsTaskAssignment> list6 = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  1628. foreach (var temp in list6)
  1629. {
  1630. //if (temp.UId != 21)
  1631. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  1632. // "黑屏代码提醒",
  1633. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  1634. }
  1635. }
  1636. }
  1637. #endregion
  1638. #region 判断到达日期是否需要加1
  1639. if (Info[4].Contains("+"))
  1640. {
  1641. //日期+1
  1642. day = day + 1;
  1643. //判断是否进入下一月
  1644. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  1645. {
  1646. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  1647. month = month + 1;
  1648. //判断是否进入下一年
  1649. if (month > 12)
  1650. {
  1651. month = month - 12;
  1652. year = year + 1;
  1653. }
  1654. }
  1655. //月份整理格式
  1656. string monthTemp = month.ToString();
  1657. if (month < 10)
  1658. {
  1659. monthTemp = "0" + monthTemp;
  1660. }
  1661. //日期整理格式
  1662. string daytemp = day.ToString();
  1663. if (day < 10)
  1664. {
  1665. daytemp = "0" + daytemp;
  1666. }
  1667. string temp = Info[4].Split('+')[0];
  1668. //添加起飞数据
  1669. dt.Rows.Add(Info[0],
  1670. Info[1],
  1671. Info[2],
  1672. Info[3],
  1673. temp,
  1674. Info[5],
  1675. Info[6],
  1676. Info[7],
  1677. Info[8],
  1678. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  1679. year + "-" + monthTemp + "-" + daytemp,
  1680. "",
  1681. "0");
  1682. //加1天,添加到达数据
  1683. dt.Rows.Add(Info[0],
  1684. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  1685. Info[2],
  1686. Info[3],
  1687. temp,
  1688. Info[5],
  1689. Info[6],
  1690. Info[7],
  1691. Info[8],
  1692. year + "-" + monthTemp + "-" + daytemp,
  1693. year + "-" + monthTemp + "-" + daytemp,
  1694. "",
  1695. "1");
  1696. }
  1697. else
  1698. {
  1699. //月份整理格式
  1700. string monthTemp = month.ToString();
  1701. if (month < 10)
  1702. {
  1703. monthTemp = "0" + monthTemp;
  1704. }
  1705. //日期整理格式
  1706. string daytemp = day.ToString();
  1707. if (day < 10)
  1708. {
  1709. daytemp = "0" + daytemp;
  1710. }
  1711. dt.Rows.Add(Info[0],
  1712. Info[1],
  1713. Info[2],
  1714. Info[3],
  1715. Info[4],
  1716. Info[5],
  1717. Info[6],
  1718. Info[7],
  1719. Info[8],
  1720. year + "-" + monthTemp + "-" + daytemp,
  1721. year + "-" + monthTemp + "-" + daytemp,
  1722. "",
  1723. "0");
  1724. }
  1725. #endregion
  1726. }
  1727. catch (Exception ex)
  1728. {
  1729. string exstr = ex.Message.ToString();
  1730. }
  1731. }
  1732. }
  1733. //排序
  1734. dt.DefaultView.Sort = "Day asc";
  1735. dt = dt.DefaultView.ToTable();
  1736. }
  1737. }
  1738. return dt;
  1739. }
  1740. private readonly static string[] excludeArr = new string[] { "[中转]", "[转机]" };
  1741. /// <summary>
  1742. ///根据机票黑屏代码整理DataTable
  1743. /// </summary>
  1744. /// <param name="diid"></param>
  1745. /// <returns></returns>
  1746. public static DataTable GetTableByBlackCode(int diid)
  1747. {
  1748. //黑屏代码信息
  1749. List<Air_TicketBlackCode> listcode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  1750. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  1751. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  1752. DataTable dt = new DataTable();
  1753. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  1754. dt.Columns.Add("Date", typeof(string));//起飞日期
  1755. dt.Columns.Add("Three", typeof(string));//三字码
  1756. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  1757. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  1758. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  1759. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  1760. dt.Columns.Add("AirModel", typeof(string)); //机型
  1761. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  1762. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  1763. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  1764. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  1765. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  1766. //添加转机标识
  1767. dt.Columns.Add("isTransitShipment", typeof(bool));
  1768. //判断是否录入黑屏代码
  1769. if (listcode.Count() == 0 || listcode == null)
  1770. {
  1771. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null, false);
  1772. }
  1773. else
  1774. {
  1775. //读取单段黑屏代码
  1776. for (int i = 0; i < listcode.Count; i++)
  1777. {
  1778. //去除序号
  1779. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  1780. //去除多余空格,方法一Linq扩展方法
  1781. CodeList = CodeList.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  1782. //读取单条黑屏代码
  1783. for (int j = 0; j < CodeList.Count(); j++)
  1784. {
  1785. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  1786. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  1787. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1788. //去除多余空格
  1789. Info = Info.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  1790. //判断黑屏代码是否正确拆分; 理应拆成9段
  1791. if (Info.TakeWhile((x) =>
  1792. {
  1793. return !excludeArr.Contains(x);
  1794. }).Count() != 9)
  1795. {
  1796. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null, false);
  1797. //MessageBoxEx.Show("第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误, 请联系机票同事核对");
  1798. return dt;
  1799. }
  1800. else
  1801. {
  1802. try
  1803. {
  1804. var monthEn = Info[1].Substring(4, 3);
  1805. //月
  1806. int month = Convert.ToInt32(GetLonger(monthEn));
  1807. //日
  1808. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  1809. var time = new DateTime(DateTime.Now.Year, month, day); //
  1810. var isExist = Info.Contains("[中转]");
  1811. //dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  1812. //dt.Columns.Add("Date", typeof(string));//起飞日期
  1813. //dt.Columns.Add("Three", typeof(string));//三字码
  1814. //dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  1815. //dt.Columns.Add("EndTime", typeof(string));//到达时刻
  1816. //dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  1817. //dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  1818. //dt.Columns.Add("AirModel", typeof(string)); //机型
  1819. //dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  1820. //dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  1821. //dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  1822. //dt.Columns.Add("Error", typeof(string));//整理的到达日期
  1823. //dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  1824. dt.Rows.Add(Info[0],
  1825. Info[1],
  1826. Info[2],
  1827. Info[3],
  1828. Info[4],
  1829. Info[5],
  1830. Info[6],
  1831. Info[7],
  1832. Info[8],
  1833. time.ToString("yyyy-MM-dd"),
  1834. time.ToString("yyyy-MM-dd"),
  1835. "",
  1836. "0",
  1837. isExist
  1838. );
  1839. }
  1840. catch (Exception ex)
  1841. {
  1842. string exstr = ex.Message.ToString();
  1843. }
  1844. }
  1845. }
  1846. //排序
  1847. dt.DefaultView.Sort = "Day asc";
  1848. dt = dt.DefaultView.ToTable();
  1849. }
  1850. }
  1851. return dt;
  1852. }
  1853. /// <summary>
  1854. /// 根据星期,月份的缩写,转换成数字或者全称
  1855. /// 根据币种中文名称返回币种代码
  1856. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  1857. /// 20210903贾文滔
  1858. /// </summary>
  1859. /// <param name="startDate"></param>
  1860. /// <param name="endDate"></param>
  1861. /// <returns></returns>
  1862. public static string GetLonger(string temp)
  1863. {
  1864. string str = "";
  1865. switch (temp.ToUpper())
  1866. {
  1867. case "美元":
  1868. str = "USD";
  1869. break;
  1870. case "日元":
  1871. str = "JPY";
  1872. break;
  1873. case "英镑":
  1874. str = "GBP";
  1875. break;
  1876. case "欧元":
  1877. str = "EUR";
  1878. break;
  1879. case "港币":
  1880. str = "HKD";
  1881. break;
  1882. case "MO":
  1883. str = "星期一";
  1884. break;
  1885. case "TU":
  1886. str = "星期二";
  1887. break;
  1888. case "WE":
  1889. str = "星期三";
  1890. break;
  1891. case "TH":
  1892. str = "星期四";
  1893. break;
  1894. case "FR":
  1895. str = "星期五";
  1896. break;
  1897. case "SA":
  1898. str = "星期六";
  1899. break;
  1900. case "SU":
  1901. str = "星期天";
  1902. break;
  1903. case "JAN":
  1904. str = "01";
  1905. break;
  1906. case "FEB":
  1907. str = "02";
  1908. break;
  1909. case "MAR":
  1910. str = "03";
  1911. break;
  1912. case "APR":
  1913. str = "04";
  1914. break;
  1915. case "MAY":
  1916. str = "05";
  1917. break;
  1918. case "JUN":
  1919. str = "06";
  1920. break;
  1921. case "JUL":
  1922. str = "07";
  1923. break;
  1924. case "AUG":
  1925. str = "08";
  1926. break;
  1927. case "SEP":
  1928. str = "09";
  1929. break;
  1930. case "OCT":
  1931. str = "10";
  1932. break;
  1933. case "NOV":
  1934. str = "11";
  1935. break;
  1936. case "DEC":
  1937. str = "12";
  1938. break;
  1939. case "MONDAY":
  1940. str = "星期一";
  1941. break;
  1942. case "TUESDAY":
  1943. str = "星期二";
  1944. break;
  1945. case "WEDNESDAY":
  1946. str = "星期三";
  1947. break;
  1948. case "THURSDAY":
  1949. str = "星期四";
  1950. break;
  1951. case "FRIDAY":
  1952. str = "星期五";
  1953. break;
  1954. case "SATURDAY":
  1955. str = "星期六";
  1956. break;
  1957. case "SUNDAY":
  1958. str = "星期日";
  1959. break;
  1960. case "01":
  1961. str = "JAN";
  1962. break;
  1963. case "02":
  1964. str = "FEB";
  1965. break;
  1966. case "03":
  1967. str = "MAR";
  1968. break;
  1969. case "04":
  1970. str = "APR";
  1971. break;
  1972. case "05":
  1973. str = "MAY";
  1974. break;
  1975. case "06":
  1976. str = "JUN";
  1977. break;
  1978. case "07":
  1979. str = "JUL";
  1980. break;
  1981. case "08":
  1982. str = "AUG";
  1983. break;
  1984. case "09":
  1985. str = "SEP";
  1986. break;
  1987. case "10":
  1988. str = "OCT";
  1989. break;
  1990. case "11":
  1991. str = "NOV";
  1992. break;
  1993. case "12":
  1994. str = "DEC";
  1995. break;
  1996. case "2":
  1997. str = "空客A";
  1998. break;
  1999. case "3":
  2000. str = "空客A";
  2001. break;
  2002. case "7":
  2003. str = "波音";
  2004. break;
  2005. }
  2006. return str;
  2007. }
  2008. /// <summary>
  2009. /// 根据月份返回天数
  2010. /// </summary>
  2011. /// <param name="temp"></param>
  2012. /// <returns></returns>
  2013. public static string GetDaysByMonth(string Month, int year)
  2014. {
  2015. string str = "";
  2016. //判断是否是闰年
  2017. if (DateTime.IsLeapYear(year) == false)
  2018. {
  2019. switch (Month.ToUpper())
  2020. {
  2021. case "JAN":
  2022. str = "31";
  2023. break;
  2024. case "FEB":
  2025. str = "28";
  2026. break;
  2027. case "MAR":
  2028. str = "31";
  2029. break;
  2030. case "APR":
  2031. str = "30";
  2032. break;
  2033. case "MAY":
  2034. str = "31";
  2035. break;
  2036. case "JUN":
  2037. str = "30";
  2038. break;
  2039. case "JUL":
  2040. str = "31";
  2041. break;
  2042. case "AUG":
  2043. str = "31";
  2044. break;
  2045. case "SEP":
  2046. str = "30";
  2047. break;
  2048. case "OCT":
  2049. str = "31";
  2050. break;
  2051. case "NOV":
  2052. str = "30";
  2053. break;
  2054. case "DEC":
  2055. str = "31";
  2056. break;
  2057. case "01":
  2058. str = "31";
  2059. break;
  2060. case "02":
  2061. str = "28";
  2062. break;
  2063. case "03":
  2064. str = "31";
  2065. break;
  2066. case "04":
  2067. str = "30";
  2068. break;
  2069. case "05":
  2070. str = "31";
  2071. break;
  2072. case "06":
  2073. str = "30";
  2074. break;
  2075. case "07":
  2076. str = "31";
  2077. break;
  2078. case "08":
  2079. str = "31";
  2080. break;
  2081. case "09":
  2082. str = "30";
  2083. break;
  2084. case "10":
  2085. str = "31";
  2086. break;
  2087. case "11":
  2088. str = "30";
  2089. break;
  2090. case "12":
  2091. str = "31";
  2092. break;
  2093. }
  2094. }
  2095. else
  2096. {
  2097. switch (Month.ToUpper())
  2098. {
  2099. case "JAN":
  2100. str = "31";
  2101. break;
  2102. case "FEB":
  2103. str = "29";
  2104. break;
  2105. case "MAR":
  2106. str = "31";
  2107. break;
  2108. case "APR":
  2109. str = "30";
  2110. break;
  2111. case "MAY":
  2112. str = "31";
  2113. break;
  2114. case "JUN":
  2115. str = "30";
  2116. break;
  2117. case "JUL":
  2118. str = "31";
  2119. break;
  2120. case "AUG":
  2121. str = "31";
  2122. break;
  2123. case "SEP":
  2124. str = "30";
  2125. break;
  2126. case "OCT":
  2127. str = "31";
  2128. break;
  2129. case "NOV":
  2130. str = "30";
  2131. break;
  2132. case "DEC":
  2133. str = "31";
  2134. break;
  2135. case "01":
  2136. str = "31";
  2137. break;
  2138. case "02":
  2139. str = "29";
  2140. break;
  2141. case "03":
  2142. str = "31";
  2143. break;
  2144. case "04":
  2145. str = "30";
  2146. break;
  2147. case "05":
  2148. str = "31";
  2149. break;
  2150. case "06":
  2151. str = "30";
  2152. break;
  2153. case "07":
  2154. str = "31";
  2155. break;
  2156. case "08":
  2157. str = "31";
  2158. break;
  2159. case "09":
  2160. str = "30";
  2161. break;
  2162. case "10":
  2163. str = "31";
  2164. break;
  2165. case "11":
  2166. str = "30";
  2167. break;
  2168. case "12":
  2169. str = "31";
  2170. break;
  2171. }
  2172. }
  2173. return str;
  2174. }
  2175. /// <summary>
  2176. /// op行程单 团组 城市路径
  2177. /// </summary>
  2178. /// <param name="diid">团组Id</param>
  2179. /// <param name="separator">分隔符</param>
  2180. /// <returns></returns>
  2181. public static string GetGroupCityLine(int diid, string separator)
  2182. {
  2183. string city = string.Empty;
  2184. var blackCode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  2185. if (blackCode.Count > 0)
  2186. {
  2187. var black = blackCode.First();
  2188. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2189. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2190. if (blackSp.Length > 0)
  2191. {
  2192. try
  2193. {
  2194. var cityArrCode = new List<string>(20);
  2195. foreach (var item in blackSp)
  2196. {
  2197. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2198. var IndexSelect = itemSp[2];
  2199. var cityArrCodeLength = cityArrCode.Count - 1;
  2200. var startCity = IndexSelect.Substring(0, 3);
  2201. if (cityArrCodeLength > 0)
  2202. {
  2203. var arrEndCity = cityArrCode[cityArrCodeLength];
  2204. if (arrEndCity != startCity)
  2205. {
  2206. cityArrCode.Add(startCity.ToUpper());
  2207. }
  2208. }
  2209. else
  2210. {
  2211. cityArrCode.Add(startCity.ToUpper());
  2212. }
  2213. var endCity = IndexSelect.Substring(3, 3);
  2214. cityArrCode.Add(endCity.ToUpper());
  2215. }
  2216. var cityThree = string.Empty;
  2217. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2218. cityThree = cityThree.TrimEnd(',');
  2219. if (string.IsNullOrWhiteSpace(cityThree))
  2220. {
  2221. throw new Exception("error");
  2222. }
  2223. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  2224. var cityArr = _dirRep._sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  2225. foreach (var item in cityArrCode)
  2226. {
  2227. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2228. if (find != null)
  2229. {
  2230. city += find.City + separator;
  2231. }
  2232. else
  2233. {
  2234. city += item + "[三字码未收录]" + separator;
  2235. }
  2236. }
  2237. city = city.TrimEnd(char.Parse(separator));
  2238. }
  2239. catch (Exception e)
  2240. {
  2241. city = "[黑屏代码格式不正确!]";
  2242. }
  2243. }
  2244. }
  2245. else city = "[未录入黑屏代码]";
  2246. return city;
  2247. }
  2248. /// <summary>
  2249. /// op行程单 团组 城市路径
  2250. /// </summary>
  2251. /// <param name="diid">团组Id</param>
  2252. /// <param name="separator">分隔符</param>
  2253. /// <returns></returns>
  2254. public static Dictionary<int, string> GetGroupCityLineItem(List<int> diids, string separator)
  2255. {
  2256. Dictionary<int, string> dicCitys = new Dictionary<int, string>();
  2257. var cityCodes = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  2258. var blackCodes = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && diids.Contains(x.DiId)).ToList();
  2259. foreach (var diid in diids)
  2260. {
  2261. string city = string.Empty;
  2262. var blackCode = blackCodes.Where(it => it.DiId == diid).ToList();
  2263. if (blackCode.Count > 0)
  2264. {
  2265. var black = blackCode.First();
  2266. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2267. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2268. if (blackSp.Length > 0)
  2269. {
  2270. try
  2271. {
  2272. var cityArrCode = new List<string>(20);
  2273. foreach (var item in blackSp)
  2274. {
  2275. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2276. var IndexSelect = itemSp[2];
  2277. var cityArrCodeLength = cityArrCode.Count - 1;
  2278. var startCity = IndexSelect.Substring(0, 3);
  2279. if (cityArrCodeLength > 0)
  2280. {
  2281. var arrEndCity = cityArrCode[cityArrCodeLength];
  2282. if (arrEndCity != startCity)
  2283. {
  2284. cityArrCode.Add(startCity.ToUpper());
  2285. }
  2286. }
  2287. else
  2288. {
  2289. cityArrCode.Add(startCity.ToUpper());
  2290. }
  2291. var endCity = IndexSelect.Substring(3, 3);
  2292. cityArrCode.Add(endCity.ToUpper());
  2293. }
  2294. var cityThree = string.Empty;
  2295. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2296. cityThree = cityThree.TrimEnd(',');
  2297. if (string.IsNullOrWhiteSpace(cityThree))
  2298. {
  2299. throw new Exception("error");
  2300. }
  2301. var cityArr = cityCodes.Where(it => cityThree.Contains(it.Three.ToUpper())).ToList();
  2302. foreach (var item in cityArrCode)
  2303. {
  2304. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2305. if (find != null)
  2306. {
  2307. city += find.City + separator;
  2308. }
  2309. else
  2310. {
  2311. city += item + "[三字码未收录]" + separator;
  2312. }
  2313. }
  2314. city = city.TrimEnd(char.Parse(separator));
  2315. }
  2316. catch (Exception e)
  2317. {
  2318. city = "[黑屏代码格式不正确!]";
  2319. }
  2320. }
  2321. }
  2322. else city = "[未录入黑屏代码]";
  2323. dicCitys.Add(diid, city);
  2324. }
  2325. return dicCitys;
  2326. }
  2327. /// <summary>
  2328. /// op行程单相关团组信息 含途径城市
  2329. /// </summary>
  2330. /// <returns></returns>
  2331. public static async Task<List<MateOpGroupPageListView>> MateOpGroupPageListRedis()
  2332. {
  2333. List<MateOpGroupPageListView> _views = new List<MateOpGroupPageListView>();
  2334. string viewStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("MateOpGroupPageList");//string 取
  2335. if (!string.IsNullOrEmpty(viewStr))
  2336. {
  2337. _views = JsonConvert.DeserializeObject<List<MateOpGroupPageListView>>(viewStr);
  2338. }
  2339. else
  2340. {
  2341. string sql = string.Format($@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2342. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  2343. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  2344. JietuanOperator,IsSure,CreateTime,VisitCountry
  2345. From (
  2346. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  2347. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  2348. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  2349. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  2350. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.VisitCountry
  2351. From Grp_DelegationInfo gdi
  2352. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2353. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2354. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2355. Where gdi.IsDel = 0
  2356. ) temp");
  2357. _views = _dirRep._sqlSugar.SqlQueryable<MateOpGroupPageListView>(sql).ToList();
  2358. #region 处理所属部门
  2359. /*
  2360. * 1.sq 和 gyy 等显示 市场部
  2361. * 2.王鸽和主管及张总还有管理员号统一国交部
  2362. * 2-1. 4 管理员 ,21 张海麟
  2363. */
  2364. List<int> userIds = _views.Select(it => it.JietuanOperatorId).ToList();
  2365. List<int> userIds1 = new List<int>() { 4, 21 };
  2366. var UserDepDatas = _dirRep._sqlSugar.Queryable<Sys_Users>()
  2367. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  2368. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  2369. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  2370. .ToList();
  2371. #endregion
  2372. _views.ForEach(it =>
  2373. {
  2374. it.RouteCity = GetGroupCityLine(it.Id, @"/");
  2375. it.Department = UserDepDatas.Find(it1 => it.JietuanOperatorId == it1.UserId)?.DepName ?? "Unknown";
  2376. });
  2377. TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay;
  2378. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("MateOpGroupPageList", JsonConvert.SerializeObject(_views), ts);//string 存
  2379. }
  2380. return _views;
  2381. }
  2382. /// <summary>
  2383. /// 获取黑屏代码日期列表
  2384. /// </summary>
  2385. /// <param name="dt"></param>
  2386. /// <returns></returns>
  2387. public static List<string> GetTimeListByDataTable(DataTable dt)
  2388. {
  2389. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  2390. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  2391. List<string> timeList = new List<string>();
  2392. while (datestart <= dateend)
  2393. {
  2394. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  2395. datestart = datestart.AddDays(1);
  2396. }
  2397. return timeList;
  2398. }
  2399. const decimal conversion = 1.61M;
  2400. /// <summary>
  2401. /// 简要行程
  2402. /// </summary>
  2403. /// <param name="diid"></param>
  2404. /// <returns></returns>
  2405. public static Result GetBriefStroke(int diid)
  2406. {
  2407. DataTable resultTable = GetTableByBlackCode(diid);
  2408. if (resultTable == null)
  2409. {
  2410. return new Result { Code = -1, Msg = "黑屏代码有误或黑屏代码未录入" };
  2411. }
  2412. if (resultTable.Rows.Count == 0 || string.IsNullOrWhiteSpace(resultTable.Rows[0][1].ToString()))
  2413. {
  2414. string msg = string.Empty;
  2415. if (resultTable.Rows.Count > 0)
  2416. {
  2417. msg = resultTable.Rows[0]["Error"].ToString();
  2418. }
  2419. return new Result { Code = -1, Msg = $"黑屏代码有误;{msg}" };
  2420. }
  2421. var timeArr = GetTimeListByDataTable(resultTable);
  2422. var threeCodes = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList(); //三字码
  2423. var airCompanys = _dirRep._sqlSugar.Queryable<Res_AirCompany>().Where(it => it.IsDel == 0).ToList(); //航司公司
  2424. var obDatas = _dirRep._sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == diid).ToList(); //公务信息
  2425. var NewListTravel = new List<Grp_TravelList>();
  2426. var index = 0;
  2427. var stopCity = string.Empty;
  2428. foreach (var item in timeArr)
  2429. {
  2430. string trip = string.Empty;
  2431. string weekDay = string.Empty;
  2432. DateTime time = DateTime.Now;
  2433. if (DateTime.TryParse(item, out time))
  2434. {
  2435. weekDay = weekdays[(int)time.DayOfWeek];
  2436. }
  2437. else
  2438. {
  2439. weekDay = "日期格式不正确!";
  2440. }
  2441. var empty = "【未收入该三字码!请机票同事录入】";
  2442. var tabSelect = resultTable.Select(string.Format("Day = '{0}'", item));
  2443. var isMoreTraffic = false;
  2444. if (tabSelect.Length > 0)
  2445. {
  2446. isMoreTraffic = true;
  2447. var takeOffTime = DateTime.Parse(item);
  2448. var fallToTime = DateTime.Parse(item);
  2449. Res_ThreeCode start_Object = null;
  2450. Res_ThreeCode end_Object = null;
  2451. bool isTrade = false;
  2452. //air 处理
  2453. foreach (var tabRow in tabSelect)
  2454. {
  2455. takeOffTime = DateTime.Parse(item);
  2456. fallToTime = DateTime.Parse(item);
  2457. var takeOff = tabRow["StartTime"].ToString();
  2458. var fallTo = tabRow["EndTime"].ToString();
  2459. takeOffTime = takeOffTime.AddHours(int.Parse(takeOff.Substring(0, 2)));
  2460. takeOffTime = takeOffTime.AddMinutes(int.Parse(takeOff.Substring(2, 2)));
  2461. fallToTime = fallToTime.AddHours(int.Parse(fallTo.Substring(0, 2)));
  2462. fallToTime = fallToTime.AddMinutes(int.Parse(fallTo.Substring(2, 2)));
  2463. var threeCode = tabRow["Three"].ToString();
  2464. var start = threeCode.Substring(0, 3);
  2465. var end = threeCode.Substring(3, 3);
  2466. stopCity = end;
  2467. start_Object = threeCodes.Find(x => x.Three.ToUpper() == start.ToUpper());
  2468. end_Object = threeCodes.Find(x => x.Three.ToUpper() == end.ToUpper());
  2469. if (start_Object == null)
  2470. {
  2471. start_Object = new Res_ThreeCode()
  2472. {
  2473. AirPort = empty,
  2474. AirPort_En = empty,
  2475. City = empty,
  2476. Country = empty,
  2477. Four = empty,
  2478. Three = empty,
  2479. };
  2480. }
  2481. if (end_Object == null)
  2482. {
  2483. end_Object = new Res_ThreeCode()
  2484. {
  2485. AirPort = empty,
  2486. AirPort_En = empty,
  2487. City = empty,
  2488. Country = empty,
  2489. Four = empty,
  2490. Three = empty,
  2491. };
  2492. }
  2493. //航班号
  2494. string flightcode = tabRow["Fliagtcode"].ToString();
  2495. trip += $"{takeOffTime.ToString("HH:mm")}—{fallToTime.ToString("HH:mm")} {start_Object.City}—{end_Object.City} 航班号:{flightcode}\r\n";
  2496. }
  2497. //var airArrive = fallToTime; //航班落地时间
  2498. time = fallToTime.AddHours(1.5); //出机场一个半小时
  2499. string Time = string.Empty;
  2500. string Distance = string.Empty;
  2501. int GetGoogleResult = 0;
  2502. int GetDistResult = 0;
  2503. JObject Result = null;
  2504. try
  2505. {
  2506. Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace(" ", "").Trim();
  2507. Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString().Replace(" ", "").Trim();
  2508. if (Time.Contains("hours"))
  2509. {
  2510. Time = Time.Replace("hours", "小时");
  2511. }
  2512. if (Time.Contains("hour"))
  2513. {
  2514. Time = Time.Replace("hour", "小时");
  2515. }
  2516. Time = Time.Replace("mins", "分钟");
  2517. if (Distance.Contains("mi"))
  2518. {
  2519. var distSp = Regex.Split(Distance, "mi");
  2520. if (distSp.Length > 0)
  2521. {
  2522. Distance = (decimal.Parse(distSp[0]) * conversion).ToString("#0.00") + " 公里";
  2523. }
  2524. }
  2525. if (Distance.Contains("km"))
  2526. {
  2527. Distance = Distance.Replace("km", "公里");
  2528. }
  2529. if (Time.Contains("小时"))
  2530. {
  2531. var xs = Regex.Split(Time, "小时");
  2532. var xsValue = int.Parse(xs[0]);
  2533. var fz = Regex.Split(xs[1], "分钟");
  2534. var fzValue = int.Parse(fz[0]);
  2535. GetGoogleResult = xsValue * 60;
  2536. GetGoogleResult += fzValue;
  2537. }
  2538. else if (Time.Contains("分钟"))
  2539. {
  2540. GetGoogleResult = int.Parse(Regex.Split(Time, "分钟")[0]);
  2541. }
  2542. if (Distance.Contains("公里"))
  2543. {
  2544. GetDistResult = (int)decimal.Parse(Regex.Split(Distance, "公里")[0]);
  2545. }
  2546. if (GetGoogleResult > 0 && GetGoogleResult % 5 != 0)
  2547. {
  2548. while (GetGoogleResult % 5 != 0)
  2549. {
  2550. GetGoogleResult++;
  2551. }
  2552. }
  2553. if (GetDistResult % 5 != 0 && GetDistResult > 0)
  2554. {
  2555. while (GetDistResult % 5 != 0)
  2556. {
  2557. GetDistResult++;
  2558. }
  2559. }
  2560. int H = (GetGoogleResult / 60);
  2561. int m = (GetGoogleResult % 60);
  2562. string TimeStr = string.Empty;
  2563. if (H != 0)
  2564. {
  2565. if (H < 10)
  2566. {
  2567. TimeStr += "0" + H + "小时";
  2568. }
  2569. else
  2570. {
  2571. TimeStr += H + "小时";
  2572. }
  2573. }
  2574. if (m < 10)
  2575. {
  2576. TimeStr += "0" + m + "分钟";
  2577. }
  2578. else
  2579. {
  2580. TimeStr += m + "分钟";
  2581. }
  2582. Time = TimeStr;
  2583. Distance = GetDistResult.ToString() + "公里";
  2584. }
  2585. catch (Exception ex)
  2586. {
  2587. Time = "未知!";
  2588. Distance = "未知!";
  2589. }
  2590. //trip += $"{time.ToString("HH:mm")} 搭乘专车前往市区({end_Object.AirPort} - {end_Object.City}市区 路程{Distance},耗时{Time})";
  2591. //trip += $"{time.ToString("HH:mm")} 搭乘专车前往市区({end_Object.AirPort} - {end_Object.City}市区)";
  2592. time = time.AddMinutes(GetGoogleResult); //到达市区时间
  2593. string tripDate = Convert.ToDateTime(item).ToString("M月d日");
  2594. if (index == timeArr.Count - 1)
  2595. {
  2596. NewListTravel.Add(new Grp_TravelList
  2597. {
  2598. CreateTime = DateTime.Now,
  2599. CreateUserId = 0,
  2600. Diid = diid,
  2601. Date = tripDate,
  2602. Trip = trip,
  2603. WeekDay = weekDay,
  2604. Days = index + 1,
  2605. Traffic_First = "飞机",
  2606. Traffic_Second = "汽车",
  2607. Diffgroup = 1,
  2608. Issel = 1,
  2609. IsDel = 0,
  2610. });
  2611. continue;
  2612. }
  2613. if (time.Day != fallToTime.Day) //超出一天
  2614. {
  2615. NewListTravel.Add(new Grp_TravelList
  2616. {
  2617. CreateTime = DateTime.Now,
  2618. CreateUserId = 0,
  2619. Diid = diid,
  2620. Date = tripDate,
  2621. Trip = trip,
  2622. WeekDay = weekDay,
  2623. Days = index + 1,
  2624. Traffic_First = "飞机",
  2625. Traffic_Second = "汽车",
  2626. Diffgroup = 1,
  2627. Issel = 1,
  2628. IsDel = 0,
  2629. });
  2630. continue;
  2631. }
  2632. var obInfo = obDatas.Find(it => Convert.ToDateTime(it.Date).ToString("M月d日").Equals(tripDate));
  2633. string obtime = "";
  2634. string obcontent = "";
  2635. if (obInfo != null)
  2636. {
  2637. obtime = obInfo.Time;
  2638. obcontent = $"拜访{obInfo.Client ?? "公务出访单位未录入"}{obInfo.Job ?? "公务出访联系人职务未录入"}{obInfo.Contact ?? "公务出访联系人职务未录入"}";
  2639. }
  2640. bool obTime_bool = DateTime.TryParse(obtime, out DateTime obTimeDt);
  2641. if (time.Hour < 9) // && (airArrive < new DateTime(airArrive.Year,airArrive.Month,airArrive.Day,6, 30, 0))
  2642. {
  2643. if (obTime_bool)
  2644. {
  2645. if (obTimeDt.Hour < 9)
  2646. {
  2647. trip += $"{obTimeDt.ToString("HH:mm")}—10:30 {obcontent};\r\n";
  2648. }
  2649. }
  2650. else
  2651. {
  2652. trip += "09:00—10:30 公务活动;\r\n";
  2653. }
  2654. }
  2655. else if (time.Hour < 10)
  2656. {
  2657. if (obTime_bool)
  2658. {
  2659. if (obTimeDt.Hour < 10)
  2660. {
  2661. trip += $"{obTimeDt.ToString("HH:mm")}—12:00 {obcontent};\r\n";
  2662. }
  2663. }
  2664. else
  2665. {
  2666. trip += "10:30—12:00 公务活动;\r\n";
  2667. }
  2668. }
  2669. if (time.Hour < 13)
  2670. {
  2671. //trip += $"\r\n{time.ToString("HH:mm")} 午餐于当地餐厅;";
  2672. }
  2673. if (time < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
  2674. {
  2675. if (obTime_bool)
  2676. {
  2677. if (obTimeDt < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
  2678. {
  2679. trip += $"{obTimeDt.ToString("HH:mm")}—16:00 {obcontent};\r\n";
  2680. }
  2681. }
  2682. else
  2683. {
  2684. trip += "14:00—16:00 公务活动;\r\n";
  2685. }
  2686. }
  2687. else if (time.Hour < 16)
  2688. {
  2689. if (obTime_bool)
  2690. {
  2691. if (obTimeDt.Hour < 16)
  2692. {
  2693. trip += $"{obTimeDt.ToString("HH:mm")}—17:30 {obcontent};\r\n";
  2694. }
  2695. }
  2696. else
  2697. {
  2698. trip += "16:00—17:30 公务活动;\r\n";
  2699. }
  2700. }
  2701. //if (time.Hour < 18)
  2702. //{
  2703. // trip += $"\r\n18:00 晚餐于当地餐厅;";
  2704. //}
  2705. //time = time.AddHours(1);
  2706. //trip += $"\r\n{time.ToString("HH:mm")} 搭乘专车前往酒店,抵达后办理入住;";
  2707. }
  2708. else
  2709. {
  2710. var end_Object = threeCodes.Find(x => x.Three.ToUpper() == stopCity.ToUpper());
  2711. if (end_Object == null)
  2712. {
  2713. end_Object = new Res_ThreeCode()
  2714. {
  2715. AirPort = empty,
  2716. AirPort_En = empty,
  2717. City = empty,
  2718. Country = empty,
  2719. Four = empty,
  2720. Three = empty,
  2721. };
  2722. }
  2723. //trip += $"{end_Object.City}\r\n";
  2724. // trip += @"08:00 早餐于酒店;
  2725. //09:00—10:30 公务活动;
  2726. //12:00 午餐于当地餐厅;
  2727. //14:00—16:00 公务活动;
  2728. //18:00 晚餐于当地餐厅;
  2729. //19:00 入住酒店休息;";
  2730. trip += "09:00—10:30 公务活动;\r\n14:00—16:00 公务活动;\r\n";
  2731. }
  2732. string[] traffic = new string[] { "飞机", "汽车" };
  2733. if (!isMoreTraffic)
  2734. {
  2735. traffic = new string[] { "汽车", "" };
  2736. }
  2737. NewListTravel.Add(new Grp_TravelList
  2738. {
  2739. CreateTime = DateTime.Now,
  2740. CreateUserId = 0,
  2741. Diid = diid,
  2742. Date = Convert.ToDateTime(item).ToString("M月d日"),
  2743. Trip = trip,
  2744. WeekDay = weekDay,
  2745. Days = index + 1,
  2746. Traffic_First = traffic[0],
  2747. Traffic_Second = traffic[1],
  2748. Diffgroup = 1,
  2749. Issel = 1,
  2750. IsDel = 0,
  2751. });
  2752. index++;
  2753. }
  2754. return new Result() { Code = 0, Msg = "获取成功!", Data = NewListTravel };
  2755. }
  2756. /// <summary>
  2757. /// 根据日期获取星期
  2758. /// </summary>
  2759. /// <param name="dt"></param>
  2760. /// <returns></returns>
  2761. public static string GetWeek(this string dtStr)
  2762. {
  2763. string week = "";
  2764. bool isDt = DateTime.TryParse(dtStr, out DateTime dt);
  2765. if (isDt)
  2766. {
  2767. week = weekdays[(int)dt.DayOfWeek];
  2768. }
  2769. return week;
  2770. }
  2771. #endregion
  2772. #region 三公费用明细 文件下载
  2773. /// <summary>
  2774. /// 获取三公费用标准city
  2775. /// </summary>
  2776. /// <param name="placeData"></param>
  2777. /// <param name="nationalTravelFeeId"></param>
  2778. /// <returns></returns>
  2779. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  2780. {
  2781. string _city = string.Empty;
  2782. if (placeData.Count < 1) return _city;
  2783. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  2784. if (data == null) return _city;
  2785. string country = data.Country;
  2786. string city = data.City;
  2787. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  2788. else _city = city;
  2789. return _city;
  2790. }
  2791. /// <summary>
  2792. /// 三公费用明细 文件下载
  2793. /// </summary>
  2794. /// <param name="diId"></param>
  2795. /// <param name="userId"></param>
  2796. /// <param name="CTable"></param>
  2797. /// <returns></returns>
  2798. public static async Task<JsonView> EnterExitCostDownload(EnterExitCostDownloadDto dto, string fileFormat = "pdf")
  2799. {
  2800. var _view = new JsonView() { Code = StatusCodes.Status204NoContent };
  2801. if (dto.DiId < 1)
  2802. {
  2803. _view.Msg = "请传入有效的DiId参数;";
  2804. return _view;
  2805. }
  2806. if (dto.ExportType < 1)
  2807. {
  2808. _view.Msg = MsgTips.Port;
  2809. return _view;
  2810. }
  2811. if (dto.SubTypeId < 1)
  2812. {
  2813. _view.Msg = @"请传入有效的SubTypeId参数;
  2814. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  2815. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  2816. 3 团组成员名单 1 团组成员名单";
  2817. return _view;
  2818. }
  2819. try
  2820. {
  2821. var enterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  2822. var dayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  2823. if (enterExitCosts == null)
  2824. {
  2825. _view.Msg = @"该团组未填写出入境费用;";
  2826. return _view;
  2827. }
  2828. //数据源
  2829. List<Grp_DayAndCost> dac1 = dayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  2830. List<Grp_DayAndCost> dac2 = dayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  2831. List<Grp_DayAndCost> dac3 = dayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  2832. List<Grp_DayAndCost> dac4 = dayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  2833. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2834. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  2835. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  2836. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  2837. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  2838. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  2839. .Select((tcl, dc, cc) => new
  2840. {
  2841. Name = dc.LastName + dc.FirstName,
  2842. Sex = dc.Sex,
  2843. Birthday = dc.BirthDay,
  2844. Company = cc.CompanyFullName,
  2845. Job = dc.Job
  2846. })
  2847. .ToList();
  2848. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  2849. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  2850. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  2851. var rateDatas = await enterExitCosts.CurrencyRemark.SplitExchangeRate();
  2852. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  2853. if (dto.ExportType == 1) //明细表
  2854. {
  2855. if (dto.SubTypeId == 1005) //1005(默认明细表)
  2856. {
  2857. if (!fileFormat.Equals("pdf")) fileFormat = "docx";
  2858. //获取模板
  2859. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  2860. //载入模板
  2861. Document doc = new Document(tempPath);
  2862. DocumentBuilder builder = new DocumentBuilder(doc);
  2863. //利用键值对存放数据
  2864. Dictionary<string, string> dic = new Dictionary<string, string>();
  2865. decimal stayFeeTotal = dayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  2866. decimal mealsFeeTotal = dayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  2867. decimal miscellaneousFeeTotal = dayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  2868. decimal tainFeeTotal = dayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  2869. decimal insidePayTotal = enterExitCosts.InsidePay;
  2870. string row1_1 = "";
  2871. if (enterExitCosts.Visa > 0)
  2872. {
  2873. //insidePayTotal += enterExitCosts.Visa;
  2874. row1_1 = $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  2875. if (!string.IsNullOrEmpty(enterExitCosts.VisaRemark))
  2876. {
  2877. row1_1 += $"\t签证费用描述: {enterExitCosts.VisaRemark}";
  2878. }
  2879. }
  2880. string row1_2 = "";
  2881. if (enterExitCosts.YiMiao > 0)
  2882. {
  2883. //insidePayTotal += enterExitCosts.YiMiao;
  2884. row1_2 += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  2885. }
  2886. if (enterExitCosts.HeSuan > 0)
  2887. {
  2888. //insidePayTotal += enterExitCosts.HeSuan;
  2889. row1_2 += $"核酸检测费:{enterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  2890. }
  2891. if (enterExitCosts.Service > 0)
  2892. {
  2893. //insidePayTotal += enterExitCosts.Service;
  2894. row1_2 += $"服务费:{enterExitCosts.Service.ToString("#0.00")} 人民币/人";
  2895. }
  2896. string row1_3 = "";
  2897. if (enterExitCosts.Safe > 0)
  2898. {
  2899. //insidePayTotal += enterExitCosts.Safe;
  2900. row1_3 += $"保险费:{enterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  2901. }
  2902. if (enterExitCosts.Ticket > 0)
  2903. {
  2904. //insidePayTotal += enterExitCosts.Ticket;
  2905. row1_3 += $"参展门票:{enterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  2906. }
  2907. string row1 = "";
  2908. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  2909. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  2910. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  2911. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  2912. dic.Add("Row1Str", row1);
  2913. dic.Add("OutsideJJ", enterExitCosts.OutsideJJPay.ToString("#0.00"));
  2914. dic.Add("OutsaideGW", enterExitCosts.OutsideGWPay.ToString("#0.00"));
  2915. dic.Add("AirJJ", enterExitCosts.AirJJ.ToString("#0.00"));
  2916. dic.Add("AirGW", enterExitCosts.AirGW.ToString("#0.00"));
  2917. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  2918. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  2919. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  2920. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  2921. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  2922. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  2923. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideJJPay;
  2924. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideGWPay;
  2925. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  2926. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  2927. #region 填充word模板书签内容
  2928. foreach (var key in dic.Keys)
  2929. {
  2930. builder.MoveToBookmark(key);
  2931. builder.Write(dic[key]);
  2932. }
  2933. #endregion
  2934. #region 填充word表格内容
  2935. ////获读取指定表格方法二
  2936. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2937. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  2938. for (int i = 0; i < dac1.Count; i++)
  2939. {
  2940. Grp_DayAndCost dac = dac1[i];
  2941. if (dac == null) continue;
  2942. builder.MoveToCell(0, i, 0, 0);
  2943. builder.Write("第" + dac.Days.ToString() + "晚:");
  2944. builder.MoveToCell(0, i, 1, 0);
  2945. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  2946. //builder.Write(dac.Place == null ? "" : dac.Place);
  2947. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  2948. builder.MoveToCell(0, i, 2, 0);
  2949. builder.Write("费用标准:");
  2950. string curr = "";
  2951. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  2952. if (currData != null)
  2953. {
  2954. curr = currData.Name;
  2955. }
  2956. builder.MoveToCell(0, i, 3, 0);
  2957. builder.Write(dac.Cost.ToString("#0.00") + curr);
  2958. builder.MoveToCell(0, i, 4, 0);
  2959. builder.Write("费用小计:");
  2960. builder.MoveToCell(0, i, 5, 0);
  2961. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  2962. }
  2963. //删除多余行
  2964. while (table1.Rows.Count > dac1.Count)
  2965. {
  2966. table1.Rows.RemoveAt(dac1.Count);
  2967. }
  2968. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  2969. for (int i = 0; i < dac2.Count; i++)
  2970. {
  2971. Grp_DayAndCost dac = dac2[i];
  2972. if (dac == null) continue;
  2973. builder.MoveToCell(1, i, 0, 0);
  2974. builder.Write("第" + dac.Days.ToString() + "天:");
  2975. builder.MoveToCell(1, i, 1, 0);
  2976. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  2977. builder.MoveToCell(1, i, 2, 0);
  2978. builder.Write("费用标准:");
  2979. string curr = "";
  2980. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  2981. if (currData != null)
  2982. {
  2983. curr = currData.Name;
  2984. }
  2985. builder.MoveToCell(1, i, 3, 0);
  2986. builder.Write(dac.Cost.ToString("#0.00") + curr);
  2987. builder.MoveToCell(1, i, 4, 0);
  2988. builder.Write("费用小计:");
  2989. builder.MoveToCell(1, i, 5, 0);
  2990. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  2991. }
  2992. //删除多余行
  2993. while (table2.Rows.Count > dac2.Count)
  2994. {
  2995. table2.Rows.RemoveAt(dac2.Count);
  2996. }
  2997. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  2998. for (int i = 0; i < dac3.Count; i++)
  2999. {
  3000. Grp_DayAndCost dac = dac3[i];
  3001. if (dac == null) continue;
  3002. builder.MoveToCell(2, i, 0, 0);
  3003. builder.Write("第" + dac.Days.ToString() + "天:");
  3004. builder.MoveToCell(2, i, 1, 0);
  3005. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3006. builder.MoveToCell(2, i, 2, 0);
  3007. builder.Write("费用标准:");
  3008. string curr = "";
  3009. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3010. if (currData != null)
  3011. {
  3012. curr = currData.Name;
  3013. }
  3014. builder.MoveToCell(2, i, 3, 0);
  3015. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3016. builder.MoveToCell(2, i, 4, 0);
  3017. builder.Write("费用小计:");
  3018. builder.MoveToCell(2, i, 5, 0);
  3019. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3020. }
  3021. //删除多余行
  3022. while (table3.Rows.Count > dac3.Count)
  3023. {
  3024. table3.Rows.RemoveAt(dac3.Count);
  3025. }
  3026. #endregion
  3027. //文件名
  3028. //string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
  3029. //string strFileName = $"{_DelegationInfo.TeamName}-出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
  3030. string strFileName = $"{_DelegationInfo.TeamName}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileFormat}";
  3031. AsposeHelper.removewatermark_v2180();
  3032. //doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3033. var saveFormat = Aspose.Words.SaveFormat.Docx;
  3034. if (fileFormat.Equals("pdf"))
  3035. {
  3036. //doc.LayoutOptions.IsShowComments = false;
  3037. doc.LayoutOptions.IsShowHiddenText = false;
  3038. doc.LayoutOptions.IsShowParagraphMarks = false;
  3039. doc.LayoutOptions.RevisionOptions.DeletedTextEffect = RevisionTextEffect.None;
  3040. doc.AcceptAllRevisions();
  3041. Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
  3042. options.Compliance = PdfCompliance.PdfA1a;
  3043. options.CreateNoteHyperlinks = true;
  3044. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, options);
  3045. //_view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
  3046. _view.Data = new { Url = strFileName };
  3047. _view.Msg = "成功";
  3048. return _view;
  3049. }
  3050. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, saveFormat);
  3051. _view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
  3052. _view.Msg = "成功";
  3053. return _view;
  3054. }
  3055. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3056. {
  3057. //获取模板
  3058. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3059. //载入模板
  3060. Document doc = new Document(tempPath);
  3061. DocumentBuilder builder = new DocumentBuilder(doc);
  3062. Dictionary<string, string> dic = new Dictionary<string, string>();
  3063. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3064. {
  3065. List<string> list = new List<string>();
  3066. try
  3067. {
  3068. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3069. foreach (var item in spilitArr)
  3070. {
  3071. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3072. var depCode = spDotandEmpty[2].Substring(0, 3);
  3073. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3074. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3075. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3076. list.Add(depName);
  3077. list.Add(arrName);
  3078. }
  3079. list = list.Distinct().ToList();
  3080. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3081. }
  3082. catch (Exception)
  3083. {
  3084. dic.Add("ReturnCode", "行程录入不正确!");
  3085. }
  3086. }
  3087. else
  3088. {
  3089. dic.Add("ReturnCode", "未录入行程!");
  3090. }
  3091. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3092. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3093. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3094. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3095. {
  3096. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3097. dic.Add("Day", sp.Days.ToString());
  3098. }
  3099. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3100. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3101. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3102. //dic.Add("Names", Names);
  3103. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3104. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3105. decimal dac1totalPrice = 0.00M;
  3106. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3107. foreach (var dac in dac1)
  3108. {
  3109. if (dac.SubTotal == 0.00M)
  3110. {
  3111. continue;
  3112. }
  3113. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3114. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3115. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3116. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3117. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3118. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3119. builder.Write(currency);//币种
  3120. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3121. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3122. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3123. builder.Write("");//人数
  3124. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3125. builder.Write("");//天数
  3126. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3127. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3128. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3129. decimal rate = 0.00M;
  3130. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3131. builder.Write(rate.ToString("#0.0000"));//汇率
  3132. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3133. decimal rbmPrice = dac.SubTotal;
  3134. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3135. accommodationStartIndex++;
  3136. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3137. }
  3138. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3139. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3140. {
  3141. table1.Rows.RemoveAt(i - 1);
  3142. foodandotherStartIndex--;
  3143. }
  3144. if (dac2.Count == dac3.Count)//国家 币种 金额
  3145. {
  3146. for (int i = 0; i < dac2.Count; i++)
  3147. {
  3148. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3149. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3150. }
  3151. }
  3152. decimal dac2totalPrice = 0.00M;
  3153. foreach (var dac in dac2)
  3154. {
  3155. if (dac.SubTotal == 0)
  3156. {
  3157. continue;
  3158. }
  3159. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3160. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3161. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3162. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3163. builder.Write(currency);//币种
  3164. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3165. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3166. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3167. builder.Write("");//人数
  3168. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3169. builder.Write("");//天数
  3170. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3171. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3172. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3173. decimal rate = 0.00M;
  3174. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3175. builder.Write(rate.ToString("#0.0000"));//汇率
  3176. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3177. decimal rbmPrice = dac.SubTotal;
  3178. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3179. foodandotherStartIndex++;
  3180. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3181. }
  3182. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3183. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3184. {
  3185. table1.Rows.RemoveAt(i - 1);
  3186. }
  3187. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  3188. string otherFeeStr = "";
  3189. if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
  3190. if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
  3191. if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
  3192. if (otherFeeStr.Length > 0)
  3193. {
  3194. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3195. otherFeeStr = $"({otherFeeStr})";
  3196. dic.Add("OtherFeeStr", otherFeeStr);
  3197. }
  3198. //总计
  3199. decimal allPrice = dac1totalPrice + dac2totalPrice + enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket;
  3200. //国际旅费
  3201. string outsideJJ = "";
  3202. string allPriceJJ = "";
  3203. if (enterExitCosts.SumJJC == 1)
  3204. {
  3205. outsideJJ = string.Format(@"经济舱:{0} 元/人", enterExitCosts.AirJJ.ToString("#0.00"));
  3206. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + enterExitCosts.OutsideJJPay).ToString("#0.00"));
  3207. }
  3208. string outsideGW = "";
  3209. string allPriceGW = "";
  3210. if (enterExitCosts.SumGWC == 1)
  3211. {
  3212. outsideGW = string.Format(@"公务舱:{0} 元/人", enterExitCosts.AirGW.ToString("#0.00"));
  3213. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + enterExitCosts.OutsideGWPay).ToString("#0.00"));
  3214. }
  3215. if (enterExitCosts.SumJJC == 1 || enterExitCosts.SumGWC == 1)
  3216. {
  3217. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  3218. dic.Add("InTravelPrice", InTravelPriceStr);
  3219. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  3220. dic.Add("FinalSumPrice", FinalSumPriceStr);
  3221. }
  3222. //dic.Add("VisaPay", enterExitCosts.Visa.ToString("#0.00"));
  3223. //dic.Add("SafePay", enterExitCosts.Safe.ToString("#0.00"));
  3224. //dic.Add("YiMiao", enterExitCosts.YiMiao.ToString("#0.00"));
  3225. foreach (var key in dic.Keys)
  3226. {
  3227. builder.MoveToBookmark(key);
  3228. builder.Write(dic[key]);
  3229. }
  3230. //模板文件名
  3231. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3232. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3233. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3234. _view.Data = new { Url = url };
  3235. _view.Msg = "成功";
  3236. return _view;
  3237. }
  3238. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3239. {
  3240. //获取模板
  3241. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3242. //载入模板
  3243. WorkbookDesigner designer = new WorkbookDesigner();
  3244. designer.Workbook = new Workbook(tempPath);
  3245. Dictionary<string, string> dic = new Dictionary<string, string>();
  3246. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3247. {
  3248. List<string> list = new List<string>();
  3249. try
  3250. {
  3251. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3252. foreach (var item in spilitArr)
  3253. {
  3254. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3255. var depCode = spDotandEmpty[2].Substring(0, 3);
  3256. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3257. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3258. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3259. list.Add(depName);
  3260. list.Add(arrName);
  3261. }
  3262. list = list.Distinct().ToList();
  3263. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3264. }
  3265. catch (Exception)
  3266. {
  3267. dic.Add("ReturnCode", "行程录入不正确!");
  3268. }
  3269. }
  3270. else
  3271. {
  3272. dic.Add("ReturnCode", "未录入行程!");
  3273. }
  3274. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3275. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3276. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3277. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3278. {
  3279. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3280. dic.Add("Day", sp.Days.ToString());
  3281. }
  3282. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3283. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3284. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3285. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3286. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3287. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3288. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3289. designer.SetDataSource("Name", Names);
  3290. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3291. designer.SetDataSource("Day", dic["Day"] + "天");
  3292. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3293. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3294. int startIndex = 10;
  3295. const int startIndexcopy = 10;
  3296. if (dac2.Count == dac3.Count)//国家 币种 金额
  3297. {
  3298. for (int i = 0; i < dac2.Count; i++)
  3299. {
  3300. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3301. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3302. }
  3303. }
  3304. DataTable dtdac1 = new DataTable();
  3305. List<string> place = new List<string>();
  3306. dtdac1.Columns.AddRange(new DataColumn[] {
  3307. new DataColumn(){ ColumnName = "city"},
  3308. new DataColumn(){ ColumnName = "curr"},
  3309. new DataColumn(){ ColumnName = "criterion"},
  3310. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3311. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3312. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3313. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3314. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  3315. });
  3316. DataTable dtdac2 = new DataTable();
  3317. dtdac2.Columns.AddRange(new DataColumn[] {
  3318. new DataColumn(){ ColumnName = "city"},
  3319. new DataColumn(){ ColumnName = "curr"},
  3320. new DataColumn(){ ColumnName = "criterion"},
  3321. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3322. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3323. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3324. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3325. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  3326. });
  3327. dtdac1.TableName = "tb1";
  3328. dtdac2.TableName = "tb2";
  3329. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  3330. foreach (var item in dac1)
  3331. {
  3332. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  3333. if (place.Contains(item.Place))
  3334. {
  3335. continue;
  3336. }
  3337. DataRow row = dtdac1.NewRow();
  3338. row["city"] = item.Place;
  3339. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  3340. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  3341. row["curr"] = currency;
  3342. row["rate"] = rate.ToString("#0.0000");
  3343. row["criterion"] = item.Cost.ToString("#0.00");
  3344. row["number"] = 1;
  3345. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  3346. //row["costRMB"] = rbmPrice;
  3347. dtdac1.Rows.Add(row);
  3348. place.Add(item.Place);
  3349. }
  3350. place = new List<string>();
  3351. foreach (var item in dac2)
  3352. {
  3353. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  3354. if (place.Contains(item.Place))
  3355. {
  3356. continue;
  3357. }
  3358. DataRow row = dtdac2.NewRow();
  3359. row["city"] = item.Place;
  3360. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  3361. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  3362. row["curr"] = currency;
  3363. row["rate"] = rate.ToString("#0.0000");
  3364. row["criterion"] = item.Cost.ToString("#0.00");
  3365. row["number"] = 1;
  3366. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  3367. //row["cost"] = item.SubTotal;
  3368. //row["costRMB"] = rbmPrice;
  3369. dtdac2.Rows.Add(row);
  3370. place.Add(item.Place);
  3371. //dac2totalPrice += rbmPrice;
  3372. }
  3373. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  3374. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  3375. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3376. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  3377. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {enterExitCosts.CityTranffic.ToString("#0.00")} 元");
  3378. designer.SetDataSource("sumCityTranffic", @$"{enterExitCosts.CityTranffic.ToString("#0.00")} ");
  3379. string cell4Str = $" 4.国际旅费:经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{enterExitCosts.AirGW.ToString("#0.00")} 元/人";
  3380. string cellStr = $" 5.其他费用(";
  3381. if (enterExitCosts.Visa > 0) cellStr += $"签证费:{enterExitCosts.Visa.ToString("#0.00")}元,";
  3382. if (enterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")}元,";
  3383. if (enterExitCosts.HeSuan > 0) cellStr += $"核酸费:{enterExitCosts.HeSuan.ToString("#0.00")}元,";
  3384. if (enterExitCosts.Safe > 0) cellStr += $"保险费:{enterExitCosts.Safe.ToString("#0.00")}元,";
  3385. if (enterExitCosts.Ticket > 0) cellStr += $"参展门票费:{enterExitCosts.Ticket.ToString("#0.00")}元,";
  3386. if (enterExitCosts.Service > 0) cellStr += $"服务费:{enterExitCosts.Service.ToString("#0.00")}元,";
  3387. if (cellStr.Length > 8)
  3388. {
  3389. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  3390. }
  3391. cellStr += ")";
  3392. decimal otherFee = enterExitCosts.Visa + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.Service;
  3393. decimal s = dac1totalPrice + dac2totalPrice + enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay + otherFee;
  3394. decimal pxFee = dac4.Sum(it => it.Cost);
  3395. decimal glvFee = enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay;
  3396. string celllastStr1 = "";
  3397. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  3398. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  3399. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  3400. celllastStr1 += $",国际旅费 元";
  3401. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  3402. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  3403. designer.SetDataSource("cell4Str", cell4Str);
  3404. designer.SetDataSource("cellStr", cellStr);
  3405. designer.SetDataSource("cellSum", (enterExitCosts.Visa + enterExitCosts.Safe).ToString("#0.00"));
  3406. designer.SetDataSource("cellSum4", (enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay).ToString("#0.00"));
  3407. designer.SetDataSource("celllastStr", celllastStr);
  3408. Workbook wb = designer.Workbook;
  3409. var sheet = wb.Worksheets[0];
  3410. //绑定datatable数据集
  3411. designer.SetDataSource(dtdac1);
  3412. designer.SetDataSource(dtdac2);
  3413. designer.Process();
  3414. var rowStart = dtdac1.Rows.Count;
  3415. while (rowStart > 0)
  3416. {
  3417. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  3418. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  3419. startIndex++;
  3420. rowStart--;
  3421. }
  3422. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  3423. startIndex += 1; //总计行
  3424. rowStart = dtdac2.Rows.Count;
  3425. while (rowStart > 0)
  3426. {
  3427. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  3428. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  3429. startIndex++;
  3430. rowStart--;
  3431. }
  3432. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  3433. wb.CalculateFormula(true);
  3434. //模板文件名
  3435. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"; ;//$".xls";
  3436. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3437. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3438. _view.Data = new { Url = url };
  3439. _view.Msg = "成功";
  3440. return _view;
  3441. }
  3442. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  3443. {
  3444. //获取模板
  3445. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  3446. //载入模板
  3447. Document doc = new Document(tempPath);
  3448. DocumentBuilder builder = new DocumentBuilder(doc);
  3449. Dictionary<string, string> dic = new Dictionary<string, string>();
  3450. dic.Add("GroupName", _DelegationInfo.TeamName);
  3451. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3452. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  3453. string missionLeaderJob = "";//负责人job
  3454. int groupNumber = 0; //团人数
  3455. if (DeleClientList.Count > 0)
  3456. {
  3457. missionLeader = DeleClientList[0]?.Name ?? "";
  3458. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  3459. }
  3460. dic.Add("MissionLeader", missionLeader); //团负责人
  3461. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  3462. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  3463. #region MyRegion
  3464. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3465. //{
  3466. // List<string> list = new List<string>();
  3467. // try
  3468. // {
  3469. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3470. // foreach (var item in spilitArr)
  3471. // {
  3472. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3473. // var depCode = spDotandEmpty[2].Substring(0, 3);
  3474. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  3475. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3476. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3477. // list.Add(depName);
  3478. // list.Add(arrName);
  3479. // }
  3480. // list = list.Distinct().ToList();
  3481. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3482. // }
  3483. // catch (Exception)
  3484. // {
  3485. // dic.Add("ReturnCode", "行程录入不正确!");
  3486. // }
  3487. //}
  3488. //else
  3489. //{
  3490. // dic.Add("ReturnCode", "未录入行程!");
  3491. //}
  3492. List<string> countrys = _dirRep.GroupSplitCountry(_DelegationInfo.VisitCountry);
  3493. dic.Add("ReturnCode", string.Join("、", countrys));
  3494. #endregion
  3495. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3496. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3497. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3498. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3499. //{
  3500. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3501. // dic.Add("Day", sp.Days.ToString());
  3502. //}
  3503. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  3504. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  3505. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3506. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3507. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3508. //培训人员名单
  3509. int cultivateRowIndex = 7;
  3510. foreach (var item in DeleClientList)
  3511. {
  3512. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  3513. builder.Write(item.Name);
  3514. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  3515. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  3516. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  3517. string birthDay = "";
  3518. if (item.Birthday != null)
  3519. {
  3520. DateTime dt = Convert.ToDateTime(item.Birthday);
  3521. birthDay = $"{dt.Year}.{dt.Month}";
  3522. }
  3523. builder.Write(birthDay);
  3524. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  3525. builder.Write(item.Company);
  3526. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  3527. builder.Write(item.Job);
  3528. cultivateRowIndex++;
  3529. }
  3530. //删除多余行
  3531. //cultivateRowIndex -= 2;
  3532. int delRows = 10 + 7 - cultivateRowIndex;
  3533. if (delRows > 0)
  3534. {
  3535. for (int i = 0; i < delRows; i++)
  3536. {
  3537. table1.Rows.RemoveAt(cultivateRowIndex);
  3538. //cultivateRowIndex++;
  3539. }
  3540. }
  3541. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  3542. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  3543. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  3544. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  3545. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  3546. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  3547. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  3548. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  3549. decimal cityTranfficFeeToatal = enterExitCosts.CityTranffic; //城市区间交通费
  3550. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  3551. //其他费用
  3552. decimal otherFeeTotal = enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Service;
  3553. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  3554. //其他费用合计
  3555. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  3556. decimal _jjcFeeToatal = enterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  3557. decimal _gwcFeeToatal = enterExitCosts.AirGW + _otherFeeTotal; //公务舱
  3558. //公务舱合计
  3559. //国际旅费
  3560. string outsideJJ = "";
  3561. string allPriceJJ = "";
  3562. if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 0)
  3563. {
  3564. dic.Add("AirFeeTotal", enterExitCosts.AirJJ.ToString("#0.00"));
  3565. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  3566. }
  3567. if (enterExitCosts.SumGWC == 1 && enterExitCosts.SumJJC == 0)
  3568. {
  3569. dic.Add("AirFeeTotal", enterExitCosts.AirGW.ToString("#0.00"));
  3570. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  3571. }
  3572. if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 1)
  3573. {
  3574. string airFeeTotalStr = string.Format(@$"经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{enterExitCosts.AirGW.ToString("#0.00")}");
  3575. dic.Add("AirFeeTotal", airFeeTotalStr);
  3576. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  3577. dic.Add("FeeTotal", feeTotalStr);
  3578. }
  3579. foreach (var key in dic.Keys)
  3580. {
  3581. builder.MoveToBookmark(key);
  3582. builder.Write(dic[key]);
  3583. }
  3584. //模板文件名
  3585. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  3586. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3587. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3588. _view.Data = new { Url = url };
  3589. _view.Msg = "成功";
  3590. return _view;
  3591. }
  3592. }
  3593. else if (dto.ExportType == 2) //表格
  3594. {
  3595. //利用键值对存放数据
  3596. Dictionary<string, string> dic = new Dictionary<string, string>();
  3597. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3598. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3599. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3600. dic.Add("Day", sp.Days.ToString());
  3601. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3602. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  3603. {
  3604. //获取模板
  3605. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  3606. //载入模板
  3607. Document doc = new Document(tempPath);
  3608. DocumentBuilder builder = new DocumentBuilder(doc);
  3609. dic.Add("TeamName", _DelegationInfo.TeamName);
  3610. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3611. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  3612. string missionLeaderName = "",
  3613. missionLeaderJob = "";
  3614. if (DeleClientList.Count > 0)
  3615. {
  3616. missionLeaderName = DeleClientList[0].Name;
  3617. missionLeaderJob = DeleClientList[0].Job;
  3618. }
  3619. dic.Add("MissionLeaderName", missionLeaderName);
  3620. dic.Add("MissionLeaderJob", missionLeaderJob);
  3621. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  3622. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  3623. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3624. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3625. int rowCount = 10;//总人数行
  3626. int startRowIndex = 7; //起始行
  3627. for (int i = 0; i < DeleClientList.Count; i++)
  3628. {
  3629. builder.MoveToCell(0, startRowIndex, 0, 0);
  3630. builder.Write(DeleClientList[i].Name); //出国人员姓名
  3631. builder.MoveToCell(0, startRowIndex, 1, 0);
  3632. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  3633. builder.Write(sex);//性别
  3634. builder.MoveToCell(0, startRowIndex, 2, 0);
  3635. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  3636. builder.MoveToCell(0, startRowIndex, 3, 0);
  3637. builder.Write(DeleClientList[i].Company);//工作单位
  3638. builder.MoveToCell(0, startRowIndex, 4, 0);
  3639. builder.Write(DeleClientList[i].Job);//职务及级别
  3640. builder.MoveToCell(0, startRowIndex, 5, 0);
  3641. builder.Write("");//人员属性
  3642. builder.MoveToCell(0, startRowIndex, 6, 0);
  3643. builder.Write("");//上次出国时间
  3644. startRowIndex++;
  3645. }
  3646. int nullRow = rowCount - DeleClientList.Count;//空行
  3647. for (int i = 0; i < nullRow; i++)
  3648. {
  3649. table1.Rows.Remove(table1.Rows[startRowIndex]);
  3650. }
  3651. foreach (var key in dic.Keys)
  3652. {
  3653. builder.MoveToBookmark(key);
  3654. builder.Write(dic[key]);
  3655. }
  3656. //模板文件名
  3657. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  3658. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3659. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3660. _view.Data = new { Url = url };
  3661. _view.Msg = "成功";
  3662. return _view;
  3663. }
  3664. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  3665. {
  3666. //获取模板
  3667. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  3668. //载入模板
  3669. Document doc = new Document(tempPath);
  3670. DocumentBuilder builder = new DocumentBuilder(doc);
  3671. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  3672. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  3673. dic.Add("Names", Names);
  3674. int accommodationRows = 12, foodandotherRows = 12;
  3675. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  3676. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  3677. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3678. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3679. int accommodationStartIndex = 6;
  3680. decimal dac1totalPrice = 0.00M;
  3681. foreach (var dac in dac1)
  3682. {
  3683. if (dac.SubTotal == 0)
  3684. {
  3685. continue;
  3686. }
  3687. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3688. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3689. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3690. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  3691. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3692. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  3693. builder.Write(currency);//币种
  3694. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3695. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3696. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3697. builder.Write("");//人数
  3698. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3699. builder.Write("");//天数
  3700. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3701. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3702. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3703. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  3704. builder.Write(rate.ToString("#0.0000"));//汇率
  3705. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3706. decimal rbmPrice = rate * dac.SubTotal;
  3707. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3708. accommodationStartIndex++;
  3709. dac1totalPrice += rbmPrice;
  3710. }
  3711. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3712. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3713. builder.Write("小计");
  3714. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3715. builder.Write(dac1totalPrice.ToString("#0.00"));
  3716. accommodationStartIndex++;
  3717. int nullRow = accommodationRows - dac1.Count;
  3718. //删除空行
  3719. //if (nullRow > 0)
  3720. //{
  3721. // int rowIndex = accommodationStartIndex;
  3722. // for (int i = 0; i < nullRow; i++)
  3723. // {
  3724. // Row row = table1.Rows[rowIndex];
  3725. // row.Remove();
  3726. // rowIndex++;
  3727. // }
  3728. //}
  3729. if (dac2.Count == dac3.Count)//国家 币种 金额
  3730. {
  3731. for (int i = 0; i < dac2.Count; i++)
  3732. {
  3733. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3734. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3735. }
  3736. }
  3737. int foodandotherStartIndex = 19;//
  3738. decimal dac2totalPrice = 0.00M;
  3739. foreach (var dac in dac2)
  3740. {
  3741. if (dac.SubTotal == 0)
  3742. {
  3743. continue;
  3744. }
  3745. //foodandotherStartIndex = 12;
  3746. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3747. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  3748. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3749. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  3750. builder.Write(currency);//币种
  3751. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3752. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3753. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3754. builder.Write("");//人数
  3755. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3756. builder.Write("");//天数
  3757. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3758. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3759. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3760. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  3761. builder.Write(rate.ToString("#0.0000"));//汇率
  3762. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3763. decimal rbmPrice = rate * dac.SubTotal;
  3764. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3765. foodandotherStartIndex++;
  3766. dac2totalPrice += rbmPrice;
  3767. }
  3768. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3769. //删除空行
  3770. if (dac2.Count < foodandotherRows)
  3771. {
  3772. //int nullRow = accommodationRows - dac2.Count;
  3773. //while (table2.Rows.Count > dac2.Count)
  3774. //{
  3775. // table2.Rows.RemoveAt(dac2.Count);
  3776. //}
  3777. }
  3778. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  3779. string otherFeeStr = "";
  3780. if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
  3781. if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
  3782. if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
  3783. if (otherFeeStr.Length > 0)
  3784. {
  3785. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3786. otherFeeStr = $"({otherFeeStr})";
  3787. dic.Add("OtherFeeStr", otherFeeStr);
  3788. }
  3789. foreach (var key in dic.Keys)
  3790. {
  3791. builder.MoveToBookmark(key);
  3792. builder.Write(dic[key]);
  3793. }
  3794. //模板文件名
  3795. string strFileName = $"省级单位出(境)经费报销单.docx";
  3796. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3797. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3798. _view.Data = new { Url = url };
  3799. _view.Msg = "成功";
  3800. return _view;
  3801. }
  3802. }
  3803. else if (dto.ExportType == 3)
  3804. {
  3805. if (dto.SubTypeId == 1) //团组成员名单
  3806. {
  3807. if (DeleClientList.Count < 1)
  3808. {
  3809. _view.Msg = "团组成员暂未录入!!!";
  3810. return _view;
  3811. }
  3812. //获取模板
  3813. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  3814. //载入模板
  3815. Document doc = new Document(tempPath);
  3816. DocumentBuilder builder = new DocumentBuilder(doc);
  3817. //获取word里所有表格
  3818. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3819. //获取所填表格的序数
  3820. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3821. var rowStart = tableOne.Rows[0]; //获取第1行
  3822. //循环赋值
  3823. for (int i = 0; i < DeleClientList.Count; i++)
  3824. {
  3825. builder.MoveToCell(0, i + 1, 0, 0);
  3826. builder.Write(DeleClientList[i].Name);
  3827. builder.MoveToCell(0, i + 1, 1, 0);
  3828. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  3829. builder.Write(sex);
  3830. builder.MoveToCell(0, i + 1, 2, 0);
  3831. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  3832. builder.MoveToCell(0, i + 1, 3, 0);
  3833. builder.Write(DeleClientList[i].Company);
  3834. builder.MoveToCell(0, i + 1, 4, 0);
  3835. builder.Write(DeleClientList[i].Job);
  3836. }
  3837. //删除多余行
  3838. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  3839. {
  3840. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  3841. }
  3842. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  3843. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  3844. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  3845. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3846. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3847. _view.Data = new { Url = url };
  3848. _view.Msg = "成功";
  3849. return _view;
  3850. }
  3851. }
  3852. }
  3853. catch (Exception ex)
  3854. {
  3855. _view.Code = StatusCodes.Status500InternalServerError;
  3856. _view.Msg = ex.Message;
  3857. return _view;
  3858. }
  3859. return _view;
  3860. }
  3861. #endregion
  3862. #region iOS推送通知
  3863. #endregion
  3864. }
  3865. }