GroupsController.cs 187 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. namespace OASystem.API.Controllers
  39. {
  40. /// <summary>
  41. /// 团组相关
  42. /// </summary>
  43. //[Authorize]
  44. [Route("api/[controller]/[action]")]
  45. public class GroupsController : ControllerBase
  46. {
  47. private readonly GrpScheduleRepository _grpScheduleRep;
  48. private readonly IMapper _mapper;
  49. private readonly DelegationInfoRepository _groupRepository;
  50. private readonly TaskAssignmentRepository _taskAssignmentRep;
  51. private readonly AirTicketResRepository _airTicketResRep;
  52. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  53. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  54. private readonly DelegationEnDataRepository _delegationEnDataRep;
  55. private readonly DelegationVisaRepository _delegationVisaRep;
  56. private readonly VisaPriceRepository _visaPriceRep;
  57. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  58. private readonly HotelPriceRepository _hotelPriceRep;
  59. private readonly CustomersRepository _customersRep;
  60. private readonly MessageRepository _message;
  61. private readonly SqlSugarClient _sqlSugar;
  62. #region 成本相关
  63. private readonly CheckBoxsRepository _checkBoxs;
  64. private readonly GroupCostRepository _GroupCostRepository;
  65. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  66. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  67. #endregion
  68. private readonly SetDataRepository _setDataRep;
  69. private string url;
  70. private string path;
  71. private readonly EnterExitCostRepository _enterExitCostRep;
  72. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  73. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  74. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  75. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  76. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  77. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep)
  78. {
  79. _mapper = mapper;
  80. _grpScheduleRep = grpScheduleRep;
  81. _groupRepository = groupRepository;
  82. _taskAssignmentRep = taskAssignmentRep;
  83. _airTicketResRep = airTicketResRep;
  84. _sqlSugar = sqlSugar;
  85. url = AppSettingsHelper.Get("ExcelBaseUrl");
  86. path = AppSettingsHelper.Get("ExcelBasePath");
  87. if (!System.IO.Directory.Exists(path))
  88. {
  89. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  90. }
  91. _decreasePaymentsRep = decreasePaymentsRep;
  92. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  93. _delegationEnDataRep = delegationEnDataRep;
  94. _enterExitCostRep = enterExitCostRep;
  95. _delegationVisaRep = delegationVisaRep;
  96. _message = message;
  97. _visaPriceRep = visaPriceRep;
  98. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  99. _checkBoxs = checkBoxs;
  100. _GroupCostRepository = GroupCostRepository;
  101. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  102. _GroupCostParameterRepository = GroupCostParameterRepository;
  103. _hotelPriceRep = hotelPriceRep;
  104. _customersRep = customersRep;
  105. _setDataRep = setDataRep;
  106. }
  107. #region 流程管控
  108. /// <summary>
  109. /// 获取团组流程管控信息
  110. /// </summary>
  111. /// <param name="paras">参数Json字符串</param>
  112. /// <returns></returns>
  113. [HttpPost]
  114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  115. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  116. {
  117. if (string.IsNullOrEmpty(_jsonDto.Paras))
  118. {
  119. return Ok(JsonView(false, "参数为空"));
  120. }
  121. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  122. if (_ScheduleDto != null)
  123. {
  124. if (_ScheduleDto.SearchType == 2)//获取列表
  125. {
  126. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  127. return Ok(JsonView(_grpScheduleViewList));
  128. }
  129. else//获取对象
  130. {
  131. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  132. if (_grpScheduleView != null)
  133. {
  134. return Ok(JsonView(_grpScheduleView));
  135. }
  136. }
  137. }
  138. else
  139. {
  140. return Ok(JsonView(false, "参数反序列化失败"));
  141. }
  142. return Ok(JsonView(false, "暂无数据!"));
  143. }
  144. /// <summary>
  145. /// 修改团组流程管控详细表数据
  146. /// </summary>
  147. /// <param name="paras"></param>
  148. /// <returns></returns>
  149. [HttpPost]
  150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  151. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  152. {
  153. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  154. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  155. .SetColumns(it => it.Duty == _detail.Duty)
  156. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  157. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  158. .SetColumns(it => it.JobContent == _detail.JobContent)
  159. .SetColumns(it => it.Remark == _detail.Remark)
  160. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  161. .Where(s => s.Id == dto.Id)
  162. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  163. .ExecuteCommandAsync();
  164. if (result > 0)
  165. {
  166. return Ok(JsonView(true, "保存成功!"));
  167. }
  168. return Ok(JsonView(false, "保存失败!"));
  169. }
  170. /// <summary>
  171. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  172. /// </summary>
  173. /// <param name="dto"></param>
  174. /// <returns></returns>
  175. [HttpPost]
  176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  177. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  178. {
  179. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  180. _detail.IsDel = 1;
  181. _detail.DeleteUserId = dto.Duty;
  182. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  183. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  184. .SetColumns(it => it.IsDel == _detail.IsDel)
  185. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  186. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  187. .Where(it => it.Id == dto.Id)
  188. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  189. //.WhereColumns(s => s.Id == dto.Id)
  190. .ExecuteCommandAsync();
  191. if (result > 0)
  192. {
  193. return Ok(JsonView(true, "删除成功!"));
  194. }
  195. return Ok(JsonView(false, "删除失败!"));
  196. }
  197. /// <summary>
  198. /// 增加团组流程管控详细表数据
  199. /// </summary>
  200. /// <param name="dto"></param>
  201. /// <returns></returns>
  202. [HttpPost]
  203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  204. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  205. {
  206. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  207. if (DateTime.Now < _detail.ExpectBeginDt)
  208. {
  209. _detail.StepStatus = 0;
  210. }
  211. else
  212. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  213. _detail.StepStatus = 1;
  214. }
  215. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  216. if (result > 0)
  217. {
  218. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  219. return Ok(JsonView(true, "添加成功!", _result));
  220. }
  221. return Ok(JsonView(false, "添加失败!"));
  222. }
  223. #endregion
  224. #region 团组基本信息
  225. /// <summary>
  226. /// 接团信息列表
  227. /// </summary>
  228. /// <param name="dto">团组列表请求dto</param>
  229. /// <returns></returns>
  230. [HttpPost]
  231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  232. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  233. {
  234. var groupData = await _groupRepository.GetGroupList(dto);
  235. if (groupData.Code != 0)
  236. {
  237. return Ok(JsonView(false, groupData.Msg));
  238. }
  239. return Ok(JsonView(groupData.Data));
  240. }
  241. /// <summary>
  242. /// 接团信息列表 Page
  243. /// </summary>
  244. /// <param name="dto">团组列表请求dto</param>
  245. /// <returns></returns>
  246. [HttpPost]
  247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  248. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  249. {
  250. #region 参数验证
  251. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  252. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  253. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  254. #region 页面操作权限验证
  255. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  256. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  257. #endregion
  258. #endregion
  259. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  260. {
  261. string sqlWhere = string.Empty;
  262. if (dto.IsSure == 0) //未完成
  263. {
  264. sqlWhere += string.Format(@" And IsSure = 0");
  265. }
  266. else if (dto.IsSure == 1) //已完成
  267. {
  268. sqlWhere += string.Format(@" And IsSure = 1");
  269. }
  270. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  271. {
  272. string tj = dto.SearchCriteria;
  273. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  274. tj, tj, tj, tj, tj);
  275. }
  276. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  277. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  278. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  279. From (
  280. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  281. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  282. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  283. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  284. From Grp_DelegationInfo gdi
  285. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  286. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  287. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  288. Where gdi.IsDel = 0 {0}
  289. ) temp ", sqlWhere);
  290. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  291. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  292. var _view = new
  293. {
  294. PageFuncAuth = pageFunAuthView,
  295. Data = _DelegationList
  296. };
  297. return Ok(JsonView(true, "查询成功!", _view, total));
  298. }
  299. else
  300. {
  301. return Ok(JsonView(false, "查询失败"));
  302. }
  303. }
  304. /// <summary>
  305. /// 接团信息详情
  306. /// </summary>
  307. /// <param name="dto">团组info请求dto</param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  312. {
  313. var groupData = await _groupRepository.GetGroupInfo(dto);
  314. if (groupData.Code != 0)
  315. {
  316. return Ok(JsonView(false, groupData.Msg));
  317. }
  318. return Ok(JsonView(groupData.Data));
  319. }
  320. /// <summary>
  321. /// 接团信息 编辑添加
  322. /// 基础信息数据源
  323. /// </summary>
  324. /// <param name="dto"></param>
  325. /// <returns></returns>
  326. [HttpPost]
  327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  328. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  329. {
  330. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  331. if (groupData.Code != 0)
  332. {
  333. return Ok(JsonView(false, groupData.Msg));
  334. }
  335. return Ok(JsonView(groupData.Data));
  336. }
  337. /// <summary>
  338. /// 接团信息 操作(增改)
  339. /// </summary>
  340. /// <param name="dto"></param>
  341. /// <returns></returns>
  342. [HttpPost]
  343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  344. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  345. {
  346. try
  347. {
  348. var groupData = await _groupRepository.GroupOperation(dto);
  349. if (groupData.Code != 0)
  350. {
  351. return Ok(JsonView(false, groupData.Msg));
  352. }
  353. return Ok(JsonView(true));
  354. }
  355. catch (Exception ex)
  356. {
  357. Logs("[response]" + JsonConvert.SerializeObject(dto));
  358. Logs(ex.Message);
  359. return Ok(JsonView(false, ex.Message));
  360. }
  361. }
  362. /// <summary>
  363. /// 接团信息 操作(删除)
  364. /// </summary>
  365. /// <param name="dto"></param>
  366. /// <returns></returns>
  367. [HttpPost]
  368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  369. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  370. {
  371. try
  372. {
  373. var groupData = await _groupRepository.GroupDel(dto);
  374. if (groupData.Code != 0)
  375. {
  376. return Ok(JsonView(false, groupData.Msg));
  377. }
  378. return Ok(JsonView(true));
  379. }
  380. catch (Exception ex)
  381. {
  382. Logs("[response]" + JsonConvert.SerializeObject(dto));
  383. Logs(ex.Message);
  384. return Ok(JsonView(false, ex.Message));
  385. }
  386. }
  387. /// <summary>
  388. /// 获取团组销售报价号
  389. /// 团组添加时 使用
  390. /// </summary>
  391. /// <returns></returns>
  392. [HttpPost]
  393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  394. public async Task<IActionResult> GetGroupSalesQuoteNo()
  395. {
  396. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  397. if (groupData.Code != 0)
  398. {
  399. return Ok(JsonView(false, groupData.Msg));
  400. }
  401. object salesQuoteNo = new
  402. {
  403. SalesQuoteNo = groupData.Data
  404. };
  405. return Ok(JsonView(salesQuoteNo));
  406. }
  407. /// <summary>
  408. /// 设置确认出团
  409. /// </summary>
  410. /// <param name="dto"></param>
  411. /// <returns></returns>
  412. [HttpPost]
  413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  414. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  415. {
  416. var groupData = await _groupRepository.ConfirmationGroup(dto);
  417. if (groupData.Code != 0)
  418. {
  419. return Ok(JsonView(false, groupData.Msg));
  420. }
  421. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  422. return Ok(JsonView(true, "操作成功!", groupData.Data));
  423. }
  424. /// <summary>
  425. /// 获取团组名称data And 签证国别Data
  426. /// </summary>
  427. /// <param name="dto"></param>
  428. /// <returns></returns>
  429. [HttpPost]
  430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  431. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  432. {
  433. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  434. if (groupData.Code != 0)
  435. {
  436. return Ok(JsonView(false, groupData.Msg));
  437. }
  438. return Ok(JsonView(groupData.Data));
  439. }
  440. /// <summary>
  441. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  442. /// </summary>
  443. /// <returns></returns>
  444. [HttpPost]
  445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  446. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  447. {
  448. try
  449. {
  450. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  451. if (groupData.Code != 0)
  452. {
  453. return Ok(JsonView(false, groupData.Msg));
  454. }
  455. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  456. }
  457. catch (Exception ex)
  458. {
  459. return Ok(JsonView(false, "程序错误!"));
  460. throw;
  461. }
  462. }
  463. #endregion
  464. #region 团组&签证
  465. /// <summary>
  466. /// 根据团组Id获取签证客户信息List
  467. /// </summary>
  468. /// <param name="dto">请求dto</param>
  469. /// <returns></returns>
  470. [HttpPost]
  471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  472. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  473. {
  474. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  475. if (groupData.Code != 0)
  476. {
  477. return Ok(JsonView(false, groupData.Msg));
  478. }
  479. return Ok(JsonView(groupData.Data));
  480. }
  481. /// <summary>
  482. /// IOS获取团组签证拍照上传进度01(团组列表)
  483. /// </summary>
  484. /// <param name="dto">请求dto</param>
  485. /// <returns></returns>
  486. [HttpPost]
  487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  488. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  489. {
  490. if (dto == null)
  491. {
  492. return Ok(JsonView(false, "参数为空"));
  493. }
  494. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  495. return Ok(JsonView(visaList));
  496. }
  497. /// <summary>
  498. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  499. /// </summary>
  500. /// <returns></returns>
  501. [HttpPost]
  502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  503. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  504. {
  505. if (dto == null)
  506. {
  507. return Ok(JsonView(false, "请求错误:"));
  508. }
  509. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  510. return Ok(JsonView(list));
  511. }
  512. /// <summary>
  513. /// IOS获取团组签证拍照上传进度03(相册)
  514. /// </summary>
  515. /// <returns></returns>
  516. [HttpPost]
  517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  518. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  519. {
  520. if (dto == null)
  521. {
  522. return Ok(JsonView(false, "请求错误:"));
  523. }
  524. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  525. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  526. list.ForEach(s => s.url = url);
  527. return Ok(JsonView(list));
  528. }
  529. /// <summary>
  530. /// IOS获取团组签证拍照上传进度04(图片上传)
  531. /// </summary>
  532. /// <param name="dto"></param>
  533. /// <returns></returns>
  534. [HttpPost]
  535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  536. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  537. {
  538. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  539. //if (!string.IsNullOrEmpty(result))
  540. //{
  541. //}
  542. //else {
  543. // return Ok(JsonView(false, "上传失败"));
  544. //}
  545. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  546. int sucNum = 0;
  547. try
  548. {
  549. foreach (var item in dto.base64DataList)
  550. {
  551. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  552. string result = decodeBase64ToImage(item, imageName);
  553. if (!string.IsNullOrEmpty(result))
  554. {
  555. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  556. pic.CreateUserId = dto.CreateUserId;
  557. pic.PicName = imageName;
  558. pic.PicPath = result;
  559. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  560. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  561. if (insertResult > 0)
  562. {
  563. sucNum++;
  564. }
  565. }
  566. }
  567. }
  568. catch (Exception ex)
  569. {
  570. return Ok(JsonView(false, ex.Message));
  571. }
  572. string msg = string.Format(@"成功上传{0}张", sucNum);
  573. return Ok(JsonView(true, msg));
  574. }
  575. private string decodeBase64ToImage(string base64DataURL, string imgName)
  576. {
  577. string filename = "";//声明一个string类型的相对路径
  578. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  579. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  580. try//会有异常抛出,try,catch一下
  581. {
  582. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  583. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  584. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  585. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  586. //文件名称
  587. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  588. //上传的文件的路径
  589. string filePath = "";
  590. if (!Directory.Exists(fileDir))
  591. {
  592. Directory.CreateDirectory(fileDir);
  593. }
  594. //上传的文件的路径
  595. filePath = fileDir + filename;
  596. //string url = HttpRuntime.AppDomainAppPath.ToString();
  597. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  598. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  599. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  600. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  601. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  602. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  603. ms.Close();//关闭当前流,并释放所有与之关联的资源
  604. bitmap.Dispose();
  605. }
  606. catch (Exception e)
  607. {
  608. string massage = e.Message;
  609. Logs("IOS图片上传Error:" + massage);
  610. //filename = e.Message;
  611. }
  612. return filename;//返回相对路径
  613. }
  614. /// <summary>
  615. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  616. /// </summary>
  617. /// <param name="dto"></param>
  618. /// <returns></returns>
  619. [HttpPost]
  620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  621. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  622. {
  623. if (dto == null)
  624. {
  625. return Ok(JsonView(false, "请求错误:"));
  626. }
  627. string msg = "参数错误";
  628. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  629. {
  630. try
  631. {
  632. //_delegationVisaRep.BeginTran();
  633. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  634. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  635. .Where(s => s.Id == dto.visaProgressCustomerId)
  636. .ExecuteCommandAsync();
  637. if (updCount > 0 && dto.publishCode == 1)
  638. {
  639. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  640. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  641. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  642. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  643. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  644. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  645. if (groupData == null)
  646. {
  647. _delegationVisaRep.RollbackTran();
  648. }
  649. string title = string.Format(@"[签证进度更新]");
  650. string content = string.Format(@"测试文本");
  651. bool rst = await _message.AddMsg(new MessageDto()
  652. {
  653. Type = 5,
  654. IssuerId = dto.publisher,
  655. Title = title,
  656. Content = content,
  657. ReleaseTime = DateTime.Now,
  658. UIdList = new List<int> {
  659. 234
  660. }
  661. });
  662. if (rst)
  663. {
  664. return Ok(JsonView(true, "发送通知成功"));
  665. }
  666. }
  667. //_delegationVisaRep.CommitTran();
  668. }
  669. catch (Exception)
  670. {
  671. //_delegationVisaRep.RollbackTran();
  672. }
  673. }
  674. return Ok(JsonView(true, msg));
  675. }
  676. #endregion
  677. #region 团组任务分配
  678. /// <summary>
  679. /// 团组任务分配初始化
  680. /// </summary>
  681. /// <param name="dto"></param>
  682. /// <returns></returns>
  683. [HttpPost]
  684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  685. public async Task<IActionResult> GetTaskAssignmen()
  686. {
  687. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  688. if (groupData.Code != 0)
  689. {
  690. return Ok(JsonView(false, groupData.Msg));
  691. }
  692. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  693. }
  694. /// <summary>
  695. /// 团组任务分配查询
  696. /// </summary>
  697. /// <param name="dto"></param>
  698. /// <returns></returns>
  699. [HttpPost]
  700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  701. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  702. {
  703. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  704. if (groupData.Code != 0)
  705. {
  706. return Ok(JsonView(false, groupData.Msg));
  707. }
  708. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  709. }
  710. /// <summary>
  711. /// 团组任务分配操作
  712. /// </summary>
  713. /// <param name="dto"></param>
  714. /// <returns></returns>
  715. [HttpPost]
  716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  717. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  718. {
  719. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  720. if (groupData.Code != 0)
  721. {
  722. return Ok(JsonView(false, groupData.Msg));
  723. }
  724. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  725. }
  726. #endregion
  727. #region 团组费用审核
  728. /// <summary>
  729. /// 费用审核
  730. /// 团组列表 Page
  731. /// </summary>
  732. /// <param name="_dto">团组列表请求dto</param>
  733. /// <returns></returns>
  734. [HttpPost]
  735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  736. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  737. {
  738. #region 参数验证
  739. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  740. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  741. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  742. #region 页面操作权限验证
  743. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  744. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  745. #endregion
  746. #endregion
  747. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  748. {
  749. string sqlWhere = string.Empty;
  750. if (_dto.IsSure == 0) //未完成
  751. {
  752. sqlWhere += string.Format(@" And IsSure = 0");
  753. }
  754. else if (_dto.IsSure == 1) //已完成
  755. {
  756. sqlWhere += string.Format(@" And IsSure = 1");
  757. }
  758. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  759. {
  760. string tj = _dto.SearchCriteria;
  761. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  762. tj, tj, tj, tj, tj);
  763. }
  764. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  765. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  766. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  767. From (
  768. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  769. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  770. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  771. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  772. From Grp_DelegationInfo gdi
  773. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  774. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  775. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  776. Where gdi.IsDel = 0 {0}
  777. ) temp ", sqlWhere);
  778. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  779. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  780. var _view = new
  781. {
  782. PageFuncAuth = pageFunAuthView,
  783. Data = _DelegationList
  784. };
  785. return Ok(JsonView(true, "查询成功!", _view, total));
  786. }
  787. else
  788. {
  789. return Ok(JsonView(false, "查询失败"));
  790. }
  791. }
  792. /// <summary>
  793. /// 获取团组费用审核
  794. /// </summary>
  795. /// <param name="paras">参数Json字符串</param>
  796. /// <returns></returns>
  797. [HttpPost]
  798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  799. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  800. {
  801. #region 参数验证
  802. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  803. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  804. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  805. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  806. #region 页面操作权限验证
  807. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId,_dto.PageId);
  808. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  809. #endregion
  810. #endregion
  811. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  812. #region 费用清单
  813. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  814. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  815. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  816. List<Grp_CreditCardPayment> entityList = _groupRepository
  817. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  818. .Where(exp.ToExpression())
  819. .ToList();
  820. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  821. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  822. /*
  823. * 币种信息
  824. */
  825. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  826. /*
  827. * 用户信息
  828. */
  829. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  830. /*
  831. * 处理详情数据
  832. */
  833. foreach (var entity in entityList)
  834. {
  835. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  836. _detail.Id = entity.Id;
  837. /*
  838. * Bus名称
  839. */
  840. _detail.BusName = "";
  841. /*
  842. *费用所属
  843. */
  844. switch (entity.CTable)
  845. {
  846. case 85:
  847. Grp_AirTicketReservations jpRes = _groupRepository.Query<Grp_AirTicketReservations>(s => s.Id == entity.CId).First();
  848. if (jpRes != null)
  849. {
  850. string FlightsDescription = jpRes.FlightsDescription;
  851. string PriceDescription = jpRes.PriceDescription;
  852. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  853. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  854. }
  855. break;
  856. case 79:
  857. _detail.BusName = "待增加";
  858. break;
  859. case 98:
  860. Grp_DecreasePayments gdpRes = _groupRepository.Query<Grp_DecreasePayments>(s => s.Id == entity.CId).First();
  861. if (gdpRes != null)
  862. {
  863. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  864. _detail.PriceNameContent = gdpRes.PriceName;
  865. }
  866. break;
  867. default:
  868. break;
  869. }
  870. /*
  871. * 费用模块
  872. */
  873. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.CTable).First();
  874. if (sdPriceName != null)
  875. {
  876. _detail.PriceName = sdPriceName.Name;
  877. }
  878. /*
  879. * 应付款金额
  880. */
  881. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).First();
  882. string PaymentCurrency_WaitPay = "Unknown";
  883. if (sdPaymentCurrency_WaitPay != null)
  884. {
  885. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  886. }
  887. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1() + " " + PaymentCurrency_WaitPay;
  888. /*
  889. * 此次付款金额
  890. */
  891. decimal CurrPayStr = 0;
  892. if (entity.PayPercentage == 0)
  893. {
  894. if (entity.PayThenMoney != 0)
  895. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  896. }
  897. else
  898. {
  899. CurrPayStr = (entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate)).ConvertToDecimal1();
  900. }
  901. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  902. /*
  903. * 剩余尾款
  904. */
  905. decimal BalanceStr = 0;
  906. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  907. BalanceStr = 0;
  908. else
  909. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  910. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  911. /*
  912. * 申请人
  913. */
  914. string operatorName = " - ";
  915. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).First();
  916. if (_opUser != null)
  917. {
  918. operatorName = _opUser.CnName;
  919. }
  920. _detail.OperatorName = operatorName;
  921. /*
  922. * 审核人
  923. */
  924. string auditOperatorName = "Unknown";
  925. if (entity.AuditGMOperate == 0)
  926. auditOperatorName = " - ";
  927. else if (entity.AuditGMOperate == 4)
  928. auditOperatorName = "自动审核";
  929. else
  930. {
  931. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).First();
  932. if (_adUser != null)
  933. {
  934. auditOperatorName = _adUser.CnName;
  935. }
  936. }
  937. _detail.AuditOperatorName = auditOperatorName;
  938. /*
  939. * 超预算比例
  940. */
  941. string overBudgetStr = "";
  942. if (entity.ExceedBudget == -1)
  943. overBudgetStr = sdPriceName.Name + "尚无预算";
  944. else if (entity.ExceedBudget == 0)
  945. overBudgetStr = "未超预算";
  946. else
  947. overBudgetStr = entity.ExceedBudget.ToString("P");
  948. _detail.OverBudget = overBudgetStr;
  949. /*
  950. * 费用总计
  951. */
  952. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  953. {
  954. CurrencyId = entity.PaymentCurrency,
  955. CurrencyName = PaymentCurrency_WaitPay,
  956. AmountPayable = entity.PayMoney,
  957. ThisPayment = CurrPayStr,
  958. BalancePayment = BalanceStr,
  959. AuditedFunds = CurrPayStr
  960. });
  961. _detail.IsAuditGM = entity.IsAuditGM;
  962. detailList.Add(_detail);
  963. }
  964. #endregion
  965. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  966. /*
  967. * 下方描述处理
  968. */
  969. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  970. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  971. if (ccpCurrencyPrice != null)
  972. {
  973. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  974. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  975. }
  976. else
  977. {
  978. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  979. }
  980. string amountPayableStr = string.Format(@"应付款总金额: ");
  981. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  982. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  983. string auditedFundsStr = string.Format(@"已审费用总额: ");
  984. foreach (var item in nonDuplicat)
  985. {
  986. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  987. if (strs.Count > 0)
  988. {
  989. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  990. decimal thisPayment = strs.Sum(it => it.ThisPayment);
  991. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  992. decimal auditedFunds = strs.Sum(it => it.AuditedFunds);
  993. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  994. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  995. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  996. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  997. }
  998. }
  999. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1000. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1001. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1002. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1003. var _view1 = new
  1004. {
  1005. PageFuncAuth = pageFunAuthView,
  1006. Data = _view
  1007. };
  1008. return Ok(JsonView(_view1));
  1009. }
  1010. /// <summary>
  1011. /// 费用审核
  1012. /// 修改团组费用审核状态
  1013. /// </summary>
  1014. /// <param name="_dto">参数Json字符串</param>
  1015. /// <returns></returns>
  1016. [HttpPost]
  1017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1018. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1019. {
  1020. #region 参数验证
  1021. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1022. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1023. #endregion
  1024. #region 页面操作权限验证
  1025. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1026. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1027. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1028. #endregion
  1029. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1030. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1031. DateTime dtNow = DateTime.Now;
  1032. _groupRepository.BeginTran();
  1033. int rst = 0;
  1034. foreach (var item in idList)
  1035. {
  1036. int CreditId = int.Parse(item);
  1037. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1038. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1039. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1040. .SetColumns(it => it.AuditGMDate == dtNow.ToString())
  1041. .Where(s => s.Id == CreditId)
  1042. .ExecuteCommandAsync();
  1043. if (result < 1)
  1044. {
  1045. rst = -1;
  1046. }
  1047. else
  1048. {
  1049. _groupRepository.RollbackTran();
  1050. return Ok(JsonView(false, "保存失败并回滚!"));
  1051. }
  1052. }
  1053. _groupRepository.CommitTran();
  1054. if (rst == 0)
  1055. {
  1056. return Ok(JsonView(true, "保存成功!"));
  1057. }
  1058. return Ok(JsonView(false, "保存失败!"));
  1059. }
  1060. #endregion
  1061. #region 机票费用录入
  1062. /// <summary>
  1063. /// 机票录入当前登录人可操作团组
  1064. /// </summary>
  1065. /// <param name="dto"></param>
  1066. /// <returns></returns>
  1067. [HttpPost]
  1068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1069. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1070. {
  1071. try
  1072. {
  1073. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1074. if (groupData.Code != 0)
  1075. {
  1076. return Ok(JsonView(false, groupData.Msg));
  1077. }
  1078. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1079. }
  1080. catch (Exception ex)
  1081. {
  1082. return Ok(JsonView(false, "程序错误!"));
  1083. throw;
  1084. }
  1085. }
  1086. /// <summary>
  1087. /// 机票费用录入列表
  1088. /// </summary>
  1089. /// <param name="dto"></param>
  1090. /// <returns></returns>
  1091. [HttpPost]
  1092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1093. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1094. {
  1095. try
  1096. {
  1097. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1098. if (groupData.Code != 0)
  1099. {
  1100. return Ok(JsonView(false, groupData.Msg));
  1101. }
  1102. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1103. }
  1104. catch (Exception ex)
  1105. {
  1106. return Ok(JsonView(false, "程序错误!"));
  1107. throw;
  1108. }
  1109. }
  1110. /// <summary>
  1111. /// 根据id查询费用录入信息
  1112. /// </summary>
  1113. /// <param name="dto"></param>
  1114. /// <returns></returns>
  1115. [HttpPost]
  1116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1117. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1118. {
  1119. try
  1120. {
  1121. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1122. if (groupData.Code != 0)
  1123. {
  1124. return Ok(JsonView(false, groupData.Msg));
  1125. }
  1126. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1127. }
  1128. catch (Exception ex)
  1129. {
  1130. return Ok(JsonView(false, "程序错误!"));
  1131. throw;
  1132. }
  1133. }
  1134. /// <summary>
  1135. /// 机票费用录入操作(Status:1.新增,2.修改)
  1136. /// </summary>
  1137. /// <param name="dto"></param>
  1138. /// <returns></returns>
  1139. [HttpPost]
  1140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1141. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1142. {
  1143. try
  1144. {
  1145. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  1146. if (groupData.Code != 0)
  1147. {
  1148. return Ok(JsonView(false, groupData.Msg));
  1149. }
  1150. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1151. }
  1152. catch (Exception ex)
  1153. {
  1154. return Ok(JsonView(false, "程序错误!"));
  1155. throw;
  1156. }
  1157. }
  1158. /// <summary>
  1159. /// 根据舱位类型查询接团客户名单信息
  1160. /// </summary>
  1161. /// <param name="dto"></param>
  1162. /// <returns></returns>
  1163. [HttpPost]
  1164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1165. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1166. {
  1167. try
  1168. {
  1169. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1170. if (crm_Groups.Count != 0)
  1171. {
  1172. List<dynamic> Customer = new List<dynamic>();
  1173. foreach (var item in crm_Groups)
  1174. {
  1175. var data = new
  1176. {
  1177. Id = item.Id,
  1178. Pinyin = item.Pinyin,
  1179. Name = item.LastName + item.FirstName
  1180. };
  1181. Customer.Add(data);
  1182. }
  1183. return Ok(JsonView(true, "查询成功!", Customer));
  1184. }
  1185. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1186. }
  1187. catch (Exception ex)
  1188. {
  1189. return Ok(JsonView(false, "程序错误!"));
  1190. throw;
  1191. }
  1192. }
  1193. /// <summary>
  1194. /// 机票费用录入,删除
  1195. /// </summary>
  1196. /// <param name="dto"></param>
  1197. /// <returns></returns>
  1198. [HttpPost]
  1199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1200. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1201. {
  1202. try
  1203. {
  1204. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1205. if (!res)
  1206. {
  1207. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1208. {
  1209. IsDel = 1,
  1210. DeleteUserId = dto.DeleteUserId,
  1211. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1212. }).ExecuteCommandAsync();
  1213. return Ok(JsonView(false, "删除失败"));
  1214. }
  1215. return Ok(JsonView(true, "删除成功!"));
  1216. }
  1217. catch (Exception ex)
  1218. {
  1219. return Ok(JsonView(false, "程序错误!"));
  1220. throw;
  1221. }
  1222. }
  1223. /// <summary>
  1224. /// 导出机票录入报表
  1225. /// </summary>
  1226. /// <param name="dto"></param>
  1227. /// <returns></returns>
  1228. [HttpPost]
  1229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1230. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1231. {
  1232. try
  1233. {
  1234. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1235. if (groupData.Code != 0)
  1236. {
  1237. return Ok(JsonView(false, groupData.Msg));
  1238. }
  1239. else
  1240. {
  1241. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1242. if (AirTicketReservations.Count != 0)
  1243. {
  1244. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1245. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1246. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1247. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1248. WorkbookDesigner designer = new WorkbookDesigner();
  1249. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1250. decimal countCost = 0;
  1251. foreach (var item in AirTicketReservations)
  1252. {
  1253. if (item.BankType == "其他")
  1254. {
  1255. item.BankNo = "--";
  1256. }
  1257. else
  1258. {
  1259. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  1260. }
  1261. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1262. item.Price = System.Decimal.Round(item.Price, 2);
  1263. countCost += Convert.ToDecimal(item.Price);
  1264. }
  1265. designer.SetDataSource("Export", AirTicketReservations);
  1266. designer.SetDataSource("ExportDiCode", diCode);
  1267. designer.SetDataSource("ExportDiName", diName);
  1268. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1269. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1270. designer.Process();
  1271. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  1272. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1273. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1274. return Ok(JsonView(true, "成功", url = rst));
  1275. }
  1276. else
  1277. {
  1278. return Ok(JsonView(false, "暂无数据!"));
  1279. }
  1280. }
  1281. }
  1282. catch (Exception ex)
  1283. {
  1284. return Ok(JsonView(false, "程序错误!"));
  1285. throw;
  1286. }
  1287. }
  1288. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1289. /// <summary>
  1290. /// 行程单导出
  1291. /// </summary>
  1292. /// <param name="dto"></param>
  1293. /// <returns></returns>
  1294. [HttpPost]
  1295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1296. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1297. {
  1298. try
  1299. {
  1300. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1301. if (groupData.Code != 0)
  1302. {
  1303. return Ok(JsonView(false, groupData.Msg));
  1304. }
  1305. else
  1306. {
  1307. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1308. if (dto.Language == "CN")
  1309. {
  1310. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1311. DocumentBuilder builder = new DocumentBuilder(doc);
  1312. int tableIndex = 0;//表格索引
  1313. //得到文档中的第一个表格
  1314. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1315. foreach (var item in _AirTicketReservations)
  1316. {
  1317. #region 处理固定数据
  1318. string[] FlightsCode = item.FlightsCode.Split('/');
  1319. if (FlightsCode.Length != 0)
  1320. {
  1321. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1322. if (_AirCompany != null)
  1323. {
  1324. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1325. }
  1326. else
  1327. {
  1328. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1329. }
  1330. }
  1331. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1332. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1333. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1334. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1335. string name = "";
  1336. foreach (string clientName in nameArray)
  1337. {
  1338. if (!name.Contains(clientName))
  1339. {
  1340. name += clientName + ",";
  1341. }
  1342. }
  1343. if (!string.IsNullOrWhiteSpace(name))
  1344. {
  1345. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1346. }
  1347. else
  1348. {
  1349. table.Range.Bookmarks["ClientName"].Text = "--";
  1350. }
  1351. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1352. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1353. table.Range.Bookmarks["JointTicket"].Text = "--";
  1354. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1355. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1356. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1357. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1358. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1359. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1360. #endregion
  1361. #region 循环数据处理
  1362. List<AirInfo> airs = new List<AirInfo>();
  1363. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1364. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1365. for (int i = 0; i < FlightsCode.Length; i++)
  1366. {
  1367. AirInfo air = new AirInfo();
  1368. string[] tempstr = DayArray[i]
  1369. .Replace("\r\n", string.Empty)
  1370. .Replace("\\r\\n", string.Empty)
  1371. .TrimStart().TrimEnd()
  1372. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1373. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1374. string starCity = "";
  1375. if (star_Three != null)
  1376. {
  1377. starCity = star_Three.AirPort;
  1378. }
  1379. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1380. string EndCity = "";
  1381. if (End_Three != null)
  1382. {
  1383. EndCity = End_Three.AirPort;
  1384. }
  1385. air.Destination = starCity + "/" + EndCity;
  1386. air.Flight = FlightsCode[i];
  1387. air.SeatingClass = item.CTypeName;
  1388. string dateTime = tempstr[2];
  1389. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1390. air.FlightDate = DateTemp;
  1391. air.DepartureTime = tempstr[5];
  1392. air.LandingTime = tempstr[6];
  1393. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1394. air.TicketStatus = "--";
  1395. air.Luggage = "--";
  1396. air.DepartureTerminal = "--";
  1397. air.LandingTerminal = "--";
  1398. airs.Add(air);
  1399. }
  1400. int row = 13;
  1401. for (int i = 0; i < airs.Count; i++)
  1402. {
  1403. if (airs.Count > 2)
  1404. {
  1405. for (int j = 0; j < airs.Count - 2; j++)
  1406. {
  1407. var CopyRow = table.Rows[12].Clone(true);
  1408. table.Rows.Add(CopyRow);
  1409. }
  1410. }
  1411. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1412. int index = 0;
  1413. foreach (PropertyInfo property in properties)
  1414. {
  1415. string value = property.GetValue(airs[i]).ToString();
  1416. Cell ishcel0 = table.Rows[row].Cells[index];
  1417. Paragraph p = new Paragraph(doc);
  1418. string s = value;
  1419. p.AppendChild(new Run(doc, s));
  1420. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1421. ishcel0.AppendChild(p);
  1422. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1423. index++;
  1424. }
  1425. row++;
  1426. }
  1427. #endregion
  1428. Paragraph lastParagraph = new Paragraph(doc);
  1429. //第一个表格末尾加段落
  1430. table.ParentNode.InsertAfter(lastParagraph, table);
  1431. //复制第一个表格
  1432. Table cloneTable = (Table)table.Clone(true);
  1433. //在文档末尾段落后面加入复制的表格
  1434. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1435. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1436. {
  1437. int rownewsIndex = 13;
  1438. for (int i = 0; i < 2; i++)
  1439. {
  1440. var CopyRow = table.Rows[12].Clone(true);
  1441. table.Rows.RemoveAt(13);
  1442. table.Rows.Add(CopyRow);
  1443. rownewsIndex++;
  1444. }
  1445. }
  1446. else
  1447. {
  1448. table.Rows.RemoveAt(12);
  1449. }
  1450. cloneTable.Rows.RemoveAt(12);
  1451. }
  1452. if (_AirTicketReservations.Count != 0)
  1453. {
  1454. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1455. if (FlightsCode.Length != 0)
  1456. {
  1457. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1458. if (_AirCompany != null)
  1459. {
  1460. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1461. }
  1462. else
  1463. {
  1464. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1465. }
  1466. }
  1467. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1468. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1469. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1470. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1471. string name = "";
  1472. foreach (string clientName in nameArray)
  1473. {
  1474. if (!name.Contains(clientName))
  1475. {
  1476. name += clientName + ",";
  1477. }
  1478. }
  1479. if (!string.IsNullOrWhiteSpace(name))
  1480. {
  1481. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1482. }
  1483. else
  1484. {
  1485. table.Range.Bookmarks["ClientName"].Text = "--";
  1486. }
  1487. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1488. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1489. table.Range.Bookmarks["JointTicket"].Text = "--";
  1490. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1491. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1492. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1493. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1494. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1495. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1496. }
  1497. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1498. //保存合并后的文档
  1499. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1500. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1501. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1502. return Ok(JsonView(true, "成功!", rst));
  1503. }
  1504. else
  1505. {
  1506. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1507. DocumentBuilder builder = new DocumentBuilder(doc);
  1508. int tableIndex = 0;//表格索引
  1509. //得到文档中的第一个表格
  1510. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1511. List<string> texts = new List<string>();
  1512. foreach (var item in _AirTicketReservations)
  1513. {
  1514. string[] FlightsCode = item.FlightsCode.Split('/');
  1515. if (FlightsCode.Length != 0)
  1516. {
  1517. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1518. if (_AirCompany != null)
  1519. {
  1520. if (!transDic.ContainsKey(_AirCompany.CnName))
  1521. {
  1522. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1523. }
  1524. }
  1525. else
  1526. {
  1527. if (!transDic.ContainsKey("--"))
  1528. {
  1529. transDic.Add("--", "--");
  1530. }
  1531. }
  1532. }
  1533. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1534. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1535. string name = "";
  1536. foreach (string clientName in nameArray)
  1537. {
  1538. name += clientName + ",";
  1539. }
  1540. if (!texts.Contains(name))
  1541. {
  1542. texts.Add(name);
  1543. }
  1544. List<AirInfo> airs = new List<AirInfo>();
  1545. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1546. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1547. for (int i = 0; i < FlightsCode.Length; i++)
  1548. {
  1549. AirInfo air = new AirInfo();
  1550. string[] tempstr = DayArray[i]
  1551. .Replace("\r\n", string.Empty)
  1552. .Replace("\\r\\n", string.Empty)
  1553. .TrimStart().TrimEnd()
  1554. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1555. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1556. if (star_Three != null)
  1557. {
  1558. if (!transDic.ContainsKey(star_Three.AirPort))
  1559. {
  1560. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1561. }
  1562. }
  1563. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1564. if (End_Three != null)
  1565. {
  1566. if (!transDic.ContainsKey(End_Three.AirPort))
  1567. {
  1568. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1569. }
  1570. }
  1571. if (!texts.Contains(item.CTypeName))
  1572. {
  1573. texts.Add(item.CTypeName);
  1574. }
  1575. }
  1576. }
  1577. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1578. if (transData.Count > 0)
  1579. {
  1580. foreach (TranslateResult item in transData)
  1581. {
  1582. if (!transDic.ContainsKey(item.Query))
  1583. {
  1584. transDic.Add(item.Query, item.Translation);
  1585. }
  1586. }
  1587. }
  1588. foreach (var item in _AirTicketReservations)
  1589. {
  1590. #region 处理固定数据
  1591. string[] FlightsCode = item.FlightsCode.Split('/');
  1592. if (FlightsCode.Length != 0)
  1593. {
  1594. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1595. if (_AirCompany != null)
  1596. {
  1597. string str = "--";
  1598. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1599. if (!string.IsNullOrEmpty(translateResult))
  1600. {
  1601. str = translateResult;
  1602. str = _airTicketResRep.Processing(str);
  1603. }
  1604. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1605. }
  1606. else
  1607. {
  1608. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1609. }
  1610. }
  1611. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1612. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1613. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1614. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1615. string names = "";
  1616. foreach (string clientName in nameArray)
  1617. {
  1618. names += clientName + ",";
  1619. }
  1620. if (!string.IsNullOrWhiteSpace(names))
  1621. {
  1622. string str = "--";
  1623. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1624. if (!string.IsNullOrEmpty(translateResult))
  1625. {
  1626. str = translateResult;
  1627. str = _airTicketResRep.Processing(str);
  1628. }
  1629. table.Range.Bookmarks["ClientName"].Text = str;
  1630. }
  1631. else
  1632. {
  1633. table.Range.Bookmarks["ClientName"].Text = "--";
  1634. }
  1635. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1636. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1637. table.Range.Bookmarks["JointTicket"].Text = "--";
  1638. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1639. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1640. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1641. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1642. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1643. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1644. #endregion
  1645. #region 循环数据处理
  1646. List<AirInfo> airs = new List<AirInfo>();
  1647. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1648. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1649. for (int i = 0; i < FlightsCode.Length; i++)
  1650. {
  1651. AirInfo air = new AirInfo();
  1652. string[] tempstr = DayArray[i]
  1653. .Replace("\r\n", string.Empty)
  1654. .Replace("\\r\\n", string.Empty)
  1655. .TrimStart().TrimEnd()
  1656. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1657. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1658. string starCity = "";
  1659. if (star_Three != null)
  1660. {
  1661. string str2 = "--";
  1662. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1663. if (!string.IsNullOrEmpty(translateResult2))
  1664. {
  1665. str2 = translateResult2;
  1666. str2 = _airTicketResRep.Processing(str2);
  1667. }
  1668. starCity = str2;
  1669. }
  1670. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1671. string EndCity = "";
  1672. if (End_Three != null)
  1673. {
  1674. string str1 = "--";
  1675. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1676. if (!string.IsNullOrEmpty(translateResult1))
  1677. {
  1678. str1 = translateResult1;
  1679. str1 = _airTicketResRep.Processing(str1);
  1680. }
  1681. EndCity = str1;
  1682. }
  1683. air.Destination = starCity + "/" + EndCity;
  1684. air.Flight = FlightsCode[i];
  1685. string str = "--";
  1686. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1687. if (!string.IsNullOrEmpty(translateResult))
  1688. {
  1689. str = translateResult;
  1690. str = _airTicketResRep.Processing(str);
  1691. }
  1692. air.SeatingClass = str;
  1693. string dateTime = tempstr[2];
  1694. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1695. air.FlightDate = DateTemp;
  1696. air.DepartureTime = tempstr[5];
  1697. air.LandingTime = tempstr[6];
  1698. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1699. air.TicketStatus = "--";
  1700. air.Luggage = "--";
  1701. air.DepartureTerminal = "--";
  1702. air.LandingTerminal = "--";
  1703. airs.Add(air);
  1704. }
  1705. int row = 13;
  1706. for (int i = 0; i < airs.Count; i++)
  1707. {
  1708. if (airs.Count > 2)
  1709. {
  1710. for (int j = 0; j < airs.Count - 2; j++)
  1711. {
  1712. var CopyRow = table.Rows[12].Clone(true);
  1713. table.Rows.Add(CopyRow);
  1714. }
  1715. }
  1716. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1717. int index = 0;
  1718. foreach (PropertyInfo property in properties)
  1719. {
  1720. string value = property.GetValue(airs[i]).ToString();
  1721. Cell ishcel0 = table.Rows[row].Cells[index];
  1722. Paragraph p = new Paragraph(doc);
  1723. string s = value;
  1724. p.AppendChild(new Run(doc, s));
  1725. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1726. ishcel0.AppendChild(p);
  1727. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1728. //ishcel0.CellFormat.VerticalAlignment=
  1729. index++;
  1730. }
  1731. row++;
  1732. }
  1733. #endregion
  1734. Paragraph lastParagraph = new Paragraph(doc);
  1735. //第一个表格末尾加段落
  1736. table.ParentNode.InsertAfter(lastParagraph, table);
  1737. //复制第一个表格
  1738. Table cloneTable = (Table)table.Clone(true);
  1739. //在文档末尾段落后面加入复制的表格
  1740. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1741. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1742. {
  1743. int rownewsIndex = 13;
  1744. for (int i = 0; i < 2; i++)
  1745. {
  1746. var CopyRow = table.Rows[12].Clone(true);
  1747. table.Rows.RemoveAt(13);
  1748. table.Rows.Add(CopyRow);
  1749. rownewsIndex++;
  1750. }
  1751. }
  1752. else
  1753. {
  1754. table.Rows.RemoveAt(12);
  1755. }
  1756. cloneTable.Rows.RemoveAt(12);
  1757. }
  1758. if (_AirTicketReservations.Count != 0)
  1759. {
  1760. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1761. if (FlightsCode.Length != 0)
  1762. {
  1763. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1764. if (_AirCompany != null)
  1765. {
  1766. string str = "--";
  1767. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1768. if (!string.IsNullOrEmpty(translateResult))
  1769. {
  1770. str = translateResult;
  1771. str = _airTicketResRep.Processing(str);
  1772. }
  1773. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1774. }
  1775. else
  1776. {
  1777. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1778. }
  1779. }
  1780. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1781. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1782. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1783. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1784. string names = "";
  1785. foreach (string clientName in nameArray)
  1786. {
  1787. names += clientName + ",";
  1788. }
  1789. if (!string.IsNullOrWhiteSpace(names))
  1790. {
  1791. string str = "--";
  1792. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1793. if (!string.IsNullOrEmpty(translateResult))
  1794. {
  1795. str = translateResult;
  1796. str = _airTicketResRep.Processing(str);
  1797. }
  1798. table.Range.Bookmarks["ClientName"].Text = str;
  1799. }
  1800. else
  1801. {
  1802. table.Range.Bookmarks["ClientName"].Text = "--";
  1803. }
  1804. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1805. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1806. table.Range.Bookmarks["JointTicket"].Text = "--";
  1807. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1808. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1809. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1810. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1811. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1812. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1813. }
  1814. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1815. //保存合并后的文档
  1816. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1817. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1818. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1819. return Ok(JsonView(true, "成功!", rst));
  1820. }
  1821. }
  1822. }
  1823. catch (Exception ex)
  1824. {
  1825. return Ok(JsonView(false, "程序错误!"));
  1826. throw;
  1827. }
  1828. }
  1829. #endregion
  1830. #region 团组增减款项
  1831. /// <summary>
  1832. /// 团组增减款项下拉框绑定
  1833. /// </summary>
  1834. /// <param name="dto"></param>
  1835. /// <returns></returns>
  1836. [HttpPost]
  1837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1838. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  1839. {
  1840. try
  1841. {
  1842. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  1843. if (groupData.Code != 0)
  1844. {
  1845. return Ok(JsonView(false, groupData.Msg));
  1846. }
  1847. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1848. }
  1849. catch (Exception ex)
  1850. {
  1851. return Ok(JsonView(false, "程序错误!"));
  1852. throw;
  1853. }
  1854. }
  1855. /// <summary>
  1856. /// 根据团组Id查询团组增减款项
  1857. /// </summary>
  1858. /// <param name="dto"></param>
  1859. /// <returns></returns>
  1860. [HttpPost]
  1861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1862. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  1863. {
  1864. try
  1865. {
  1866. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  1867. if (groupData.Code != 0)
  1868. {
  1869. return Ok(JsonView(false, groupData.Msg));
  1870. }
  1871. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1872. }
  1873. catch (Exception ex)
  1874. {
  1875. return Ok(JsonView(false, "程序错误!"));
  1876. throw;
  1877. }
  1878. }
  1879. /// <summary>
  1880. /// 团组增减款项操作(Status:1.新增,2.修改)
  1881. /// </summary>
  1882. /// <param name="dto"></param>
  1883. /// <returns></returns>
  1884. [HttpPost]
  1885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1886. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  1887. {
  1888. try
  1889. {
  1890. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  1891. if (groupData.Code != 0)
  1892. {
  1893. return Ok(JsonView(false, groupData.Msg));
  1894. }
  1895. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1896. }
  1897. catch (Exception ex)
  1898. {
  1899. return Ok(JsonView(false, "程序错误!"));
  1900. throw;
  1901. }
  1902. }
  1903. /// <summary>
  1904. /// 团组增减款项操作 删除
  1905. /// </summary>
  1906. /// <param name="dto"></param>
  1907. /// <returns></returns>
  1908. [HttpPost]
  1909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1910. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  1911. {
  1912. try
  1913. {
  1914. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  1915. if (!res)
  1916. {
  1917. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  1918. {
  1919. IsDel = 1,
  1920. DeleteUserId = dto.DeleteUserId,
  1921. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1922. }).ExecuteCommandAsync();
  1923. return Ok(JsonView(false, "删除失败"));
  1924. }
  1925. return Ok(JsonView(true, "删除成功!"));
  1926. }
  1927. catch (Exception ex)
  1928. {
  1929. return Ok(JsonView(false, "程序错误!"));
  1930. throw;
  1931. }
  1932. }
  1933. /// <summary>
  1934. /// 根据团组增减款项Id查询
  1935. /// </summary>
  1936. /// <param name="dto"></param>
  1937. /// <returns></returns>
  1938. [HttpPost]
  1939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1940. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  1941. {
  1942. try
  1943. {
  1944. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  1945. if (groupData.Code != 0)
  1946. {
  1947. return Ok(JsonView(false, groupData.Msg));
  1948. }
  1949. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1950. }
  1951. catch (Exception ex)
  1952. {
  1953. return Ok(JsonView(false, "程序错误!"));
  1954. throw;
  1955. }
  1956. }
  1957. #endregion
  1958. #region 文件上传、删除
  1959. /// <summary>
  1960. /// region 文件上传 可以带参数
  1961. /// </summary>
  1962. /// <param name="file"></param>
  1963. /// <returns></returns>
  1964. [HttpPost]
  1965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1966. public async Task<IActionResult> UploadProject(IFormFile file)
  1967. {
  1968. try
  1969. {
  1970. var TypeName = Request.Headers["TypeName"].ToString();
  1971. if (file != null)
  1972. {
  1973. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1974. //文件名称
  1975. string projectFileName = file.FileName;
  1976. //上传的文件的路径
  1977. string filePath = "";
  1978. if (TypeName == "A")//A代表团组增减款项
  1979. {
  1980. if (!Directory.Exists(fileDir))
  1981. {
  1982. Directory.CreateDirectory(fileDir);
  1983. }
  1984. //上传的文件的路径
  1985. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  1986. }
  1987. else if (TypeName == "B")//B代表商邀相关文件
  1988. {
  1989. if (!Directory.Exists(fileDir))
  1990. {
  1991. Directory.CreateDirectory(fileDir);
  1992. }
  1993. //上传的文件的路径
  1994. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1995. }
  1996. using (FileStream fs = System.IO.File.Create(filePath))
  1997. {
  1998. file.CopyTo(fs);
  1999. fs.Flush();
  2000. }
  2001. return Ok(JsonView(true, "上传成功!", projectFileName));
  2002. }
  2003. else
  2004. {
  2005. return Ok(JsonView(false, "上传失败!"));
  2006. }
  2007. }
  2008. catch (Exception ex)
  2009. {
  2010. return Ok(JsonView(false, "程序错误!"));
  2011. throw;
  2012. }
  2013. }
  2014. /// <summary>
  2015. /// 删除指定文件
  2016. /// </summary>
  2017. /// <param name="dto"></param>
  2018. /// <returns></returns>
  2019. [HttpPost]
  2020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2021. public async Task<IActionResult> DelFile(DelFileDto dto)
  2022. {
  2023. try
  2024. {
  2025. var TypeName = Request.Headers["TypeName"].ToString();
  2026. string filePath = "";
  2027. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2028. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2029. int id = 0;
  2030. if (TypeName == "A")
  2031. {
  2032. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2033. // 删除该文件
  2034. System.IO.File.Delete(filePath);
  2035. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2036. }
  2037. else if (TypeName == "B")
  2038. {
  2039. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2040. // 删除该文件
  2041. System.IO.File.Delete(filePath);
  2042. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2043. }
  2044. if (id != 0)
  2045. {
  2046. return Ok(JsonView(true, "成功!"));
  2047. }
  2048. else
  2049. {
  2050. return Ok(JsonView(false, "失败!"));
  2051. }
  2052. }
  2053. catch (Exception ex)
  2054. {
  2055. return Ok(JsonView(false, "程序错误!"));
  2056. throw;
  2057. }
  2058. }
  2059. #endregion
  2060. #region 商邀费用录入
  2061. /// <summary>
  2062. /// 根据团组Id查询商邀费用列表
  2063. /// </summary>
  2064. /// <param name="dto"></param>
  2065. /// <returns></returns>
  2066. [HttpPost]
  2067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2068. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2069. {
  2070. try
  2071. {
  2072. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2073. if (groupData.Code != 0)
  2074. {
  2075. return Ok(JsonView(false, groupData.Msg));
  2076. }
  2077. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2078. }
  2079. catch (Exception ex)
  2080. {
  2081. return Ok(JsonView(false, "程序错误!"));
  2082. throw;
  2083. }
  2084. }
  2085. /// <summary>
  2086. /// 根据商邀费用ID查询C表和商邀费用数据
  2087. /// </summary>
  2088. /// <param name="dto"></param>
  2089. /// <returns></returns>
  2090. [HttpPost]
  2091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2092. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2093. {
  2094. try
  2095. {
  2096. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2097. if (groupData.Code != 0)
  2098. {
  2099. return Ok(JsonView(false, groupData.Msg));
  2100. }
  2101. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2102. }
  2103. catch (Exception ex)
  2104. {
  2105. return Ok(JsonView(false, "程序错误!"));
  2106. throw;
  2107. }
  2108. }
  2109. /// <summary>
  2110. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2111. /// </summary>
  2112. /// <param name="dto"></param>
  2113. /// <returns></returns>
  2114. [HttpPost]
  2115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2116. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2117. {
  2118. try
  2119. {
  2120. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
  2121. if (groupData.Code != 0)
  2122. {
  2123. return Ok(JsonView(false, groupData.Msg));
  2124. }
  2125. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2126. }
  2127. catch (Exception ex)
  2128. {
  2129. return Ok(JsonView(false, "程序错误!"));
  2130. throw;
  2131. }
  2132. }
  2133. /// <summary>
  2134. /// 商邀删除
  2135. /// </summary>
  2136. /// <param name="dto"></param>
  2137. /// <returns></returns>
  2138. [HttpPost]
  2139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2140. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2141. {
  2142. try
  2143. {
  2144. var res = await _InvitationOfficialActivitiesRep.SoftDeleteByIdAsync<Grp_InvitationOfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  2145. if (!res)
  2146. {
  2147. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 81).SetColumns(a => new Grp_CreditCardPayment()
  2148. {
  2149. IsDel = 1,
  2150. DeleteUserId = dto.DeleteUserId,
  2151. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2152. }).ExecuteCommandAsync();
  2153. return Ok(JsonView(false, "删除失败"));
  2154. }
  2155. return Ok(JsonView(true, "删除成功!"));
  2156. }
  2157. catch (Exception ex)
  2158. {
  2159. return Ok(JsonView(false, "程序错误!"));
  2160. throw;
  2161. }
  2162. }
  2163. #endregion
  2164. #region 团组英文资料
  2165. /// <summary>
  2166. /// 查询团组英文所有资料
  2167. /// </summary>
  2168. /// <param name="dto"></param>
  2169. /// <returns></returns>
  2170. [HttpPost]
  2171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2172. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2173. {
  2174. try
  2175. {
  2176. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  2177. if (groupData.Code != 0)
  2178. {
  2179. return Ok(JsonView(false, groupData.Msg));
  2180. }
  2181. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2182. }
  2183. catch (Exception ex)
  2184. {
  2185. return Ok(JsonView(false, "程序错误!"));
  2186. throw;
  2187. }
  2188. }
  2189. /// <summary>
  2190. /// 团组英文资料操作(Status:1.新增,2.修改)
  2191. /// </summary>
  2192. /// <param name="dto"></param>
  2193. /// <returns></returns>
  2194. [HttpPost]
  2195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2196. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2197. {
  2198. try
  2199. {
  2200. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2201. if (groupData.Code != 0)
  2202. {
  2203. return Ok(JsonView(false, groupData.Msg));
  2204. }
  2205. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2206. }
  2207. catch (Exception ex)
  2208. {
  2209. return Ok(JsonView(false, "程序错误!"));
  2210. throw;
  2211. }
  2212. }
  2213. /// <summary>
  2214. /// 团组英文资料Id查询数据
  2215. /// </summary>
  2216. /// <param name="dto"></param>
  2217. /// <returns></returns>
  2218. [HttpPost]
  2219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2220. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2221. {
  2222. try
  2223. {
  2224. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2225. if (_DelegationEnData != null)
  2226. {
  2227. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2228. }
  2229. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  2230. }
  2231. catch (Exception ex)
  2232. {
  2233. return Ok(JsonView(false, "程序错误!"));
  2234. throw;
  2235. }
  2236. }
  2237. /// <summary>
  2238. /// 团组英文资料删除
  2239. /// </summary>
  2240. /// <param name="dto"></param>
  2241. /// <returns></returns>
  2242. [HttpPost]
  2243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2244. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2245. {
  2246. try
  2247. {
  2248. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2249. if (!res)
  2250. {
  2251. return Ok(JsonView(false, "删除失败"));
  2252. }
  2253. return Ok(JsonView(true, "删除成功!"));
  2254. }
  2255. catch (Exception ex)
  2256. {
  2257. return Ok(JsonView(false, "程序错误!"));
  2258. throw;
  2259. }
  2260. }
  2261. #endregion
  2262. #region 导出邀请函
  2263. /// <summary>
  2264. /// 导出邀请函页面初始化
  2265. /// </summary>
  2266. /// <param name="dto"></param>
  2267. /// <returns></returns>
  2268. [HttpPost]
  2269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2270. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2271. {
  2272. try
  2273. {
  2274. List<Grp_DelegationInfo> grp_Delegations = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToListAsync();
  2275. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2276. if (dto.DiId == 0)
  2277. {
  2278. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2279. }
  2280. else
  2281. {
  2282. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2283. }
  2284. return Ok(JsonView(true, "查询成功!", new
  2285. {
  2286. deleClient = crm_Deles,
  2287. delegations = grp_Delegations
  2288. }));
  2289. }
  2290. catch (Exception ex)
  2291. {
  2292. return Ok(JsonView(false, "程序错误!"));
  2293. throw;
  2294. }
  2295. }
  2296. /// <summary>
  2297. /// 导出邀请函
  2298. /// </summary>
  2299. /// <param name="dto"></param>
  2300. /// <returns></returns>
  2301. [HttpPost]
  2302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2303. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2304. {
  2305. try
  2306. {
  2307. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2308. List<Crm_DeleClient> crm_DeleClients = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2309. List<string> texts = new List<string>();
  2310. if (crm_DeleClients.Count != 0)
  2311. {
  2312. foreach (Crm_DeleClient item in crm_DeleClients)
  2313. {
  2314. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2315. {
  2316. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2317. }
  2318. else
  2319. {
  2320. string name = item.LastName + item.FirstName;
  2321. texts.Add(name);
  2322. }
  2323. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  2324. {
  2325. if (!transDic.ContainsKey(item.Job))
  2326. {
  2327. texts.Add(item.Job);
  2328. }
  2329. }
  2330. if (item.CrmCompanyId != 0)
  2331. {
  2332. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == item.CrmCompanyId && a.IsDel == 0);
  2333. if (!transDic.ContainsKey(crm_Customer.CompanyName))
  2334. {
  2335. texts.Add(crm_Customer.CompanyName);
  2336. }
  2337. }
  2338. }
  2339. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2340. if (transData.Count > 0)
  2341. {
  2342. foreach (TranslateResult item in transData)
  2343. {
  2344. if (!transDic.ContainsKey(item.Query))
  2345. {
  2346. transDic.Add(item.Query, item.Translation);
  2347. }
  2348. }
  2349. }
  2350. List<guestList> list = new List<guestList>();
  2351. foreach (Crm_DeleClient dele in crm_DeleClients)
  2352. {
  2353. guestList guestList = new guestList();
  2354. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  2355. {
  2356. guestList.Name = dele.Pinyin;
  2357. }
  2358. else
  2359. {
  2360. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  2361. guestList.Name = Name;
  2362. }
  2363. if (dele.Sex == 0)
  2364. {
  2365. guestList.Sex = "Male";
  2366. }
  2367. else if (dele.Sex == 1)
  2368. {
  2369. guestList.Sex = "Female";
  2370. }
  2371. guestList.DOB = dele.BirthDay.Replace('-', '.');
  2372. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == dele.CrmCompanyId && a.IsDel == 0);
  2373. string jobName = transDic.Where(s => s.Key == crm_Customer.CompanyName).FirstOrDefault().Value + " " + transDic.Where(s => s.Key == dele.Job).FirstOrDefault().Value;
  2374. guestList.Job = jobName;
  2375. list.Add(guestList);
  2376. }
  2377. //载入模板
  2378. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  2379. DocumentBuilder builder = new DocumentBuilder(doc);
  2380. //获取word里所有表格
  2381. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2382. //获取所填表格的序数
  2383. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2384. var rowStart = tableOne.Rows[0]; //获取第1行
  2385. //循环赋值
  2386. for (int i = 0; i < list.Count; i++)
  2387. {
  2388. builder.MoveToCell(0, i + 1, 0, 0);
  2389. builder.Write(list[i].Name.ToString());
  2390. builder.MoveToCell(0, i + 1, 1, 0);
  2391. builder.Write(list[i].Sex.ToString());
  2392. builder.MoveToCell(0, i + 1, 2, 0);
  2393. builder.Write(list[i].DOB.ToString());
  2394. builder.MoveToCell(0, i + 1, 3, 0);
  2395. builder.Write(list[i].Job.ToString());
  2396. }
  2397. //删除多余行
  2398. while (tableOne.Rows.Count > list.Count + 1)
  2399. {
  2400. tableOne.Rows.RemoveAt(list.Count + 1);
  2401. }
  2402. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2403. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  2404. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  2405. doc.Save(filePath);
  2406. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件" + fileName;
  2407. return Ok(JsonView(true, "成功!", Url));
  2408. }
  2409. else
  2410. {
  2411. return Ok(JsonView(false, "失败,该团组没有客户名单!"));
  2412. }
  2413. }
  2414. catch (Exception ex)
  2415. {
  2416. return Ok(JsonView(false, "程序错误!"));
  2417. throw;
  2418. }
  2419. }
  2420. #endregion
  2421. #region 团组经理模块 出入境费用
  2422. ///// <summary>
  2423. ///// 团组模块 - 出入境费用
  2424. ///// </summary>
  2425. ///// <returns></returns>
  2426. //[HttpPost]
  2427. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2428. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  2429. //{
  2430. // try
  2431. // {
  2432. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  2433. // if (data.Code != 0)
  2434. // {
  2435. // return Ok(JsonView(false, data.Msg));
  2436. // }
  2437. // return Ok(JsonView(true, "查询成功!"));
  2438. // }
  2439. // catch (Exception ex)
  2440. // {
  2441. // return Ok(JsonView(false, ex.Message));
  2442. // throw;
  2443. // }
  2444. //}
  2445. /// <summary>
  2446. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  2447. /// </summary>
  2448. /// <returns></returns>
  2449. [HttpPost]
  2450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2451. public async Task<IActionResult> SetDayAndCostAreaChange()
  2452. {
  2453. try
  2454. {
  2455. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  2456. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  2457. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  2458. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  2459. foreach (var item in unite) //处理交集数据
  2460. {
  2461. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  2462. }
  2463. foreach (var item in merge) //处理差集数据
  2464. {
  2465. int nationalTravelFeeId = 0;
  2466. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  2467. if (cityData != null) nationalTravelFeeId = cityData.Id;
  2468. else
  2469. {
  2470. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  2471. if (countryData != null) nationalTravelFeeId = countryData.Id;
  2472. }
  2473. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  2474. }
  2475. //只更新dayAndCost 的 nationalTravelFeeId;
  2476. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  2477. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  2478. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  2479. }
  2480. catch (Exception ex)
  2481. {
  2482. return Ok(JsonView(false, ex.Message));
  2483. throw;
  2484. }
  2485. }
  2486. /// <summary>
  2487. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  2488. /// </summary>
  2489. /// <returns></returns>
  2490. [HttpPost]
  2491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2492. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  2493. {
  2494. try
  2495. {
  2496. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  2497. string currencySql = string.Format("Select * From Sys_SetData Where STid = 66 And IsDel = 0");
  2498. var currencyData = await _sqlSugar.SqlQueryable<SetDataInfoView>(currencySql).ToListAsync();
  2499. //string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2500. // Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2501. // Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2502. // Where gntf.Isdel = 0");
  2503. //var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2504. return Ok(JsonView(true, "查询成功!", new
  2505. {
  2506. GroupNameData = groupNameData.Data,
  2507. CurrencyData = currencyData,
  2508. //NationalTravelFeeData = nationalTravelFeeData
  2509. }));
  2510. }
  2511. catch (Exception ex)
  2512. {
  2513. return Ok(JsonView(false, ex.Message));
  2514. throw;
  2515. }
  2516. }
  2517. /// <summary>
  2518. /// 团组模块 - 出入境费用 - Info
  2519. /// </summary>
  2520. /// <returns></returns>
  2521. [HttpPost]
  2522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2523. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  2524. {
  2525. try
  2526. {
  2527. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  2528. if (data.Code != 0)
  2529. {
  2530. return Ok(JsonView(false, data.Msg));
  2531. }
  2532. return Ok(JsonView(true, "查询成功!", data.Data));
  2533. }
  2534. catch (Exception ex)
  2535. {
  2536. return Ok(JsonView(false, ex.Message));
  2537. }
  2538. }
  2539. /// <summary>
  2540. /// 团组模块 - 出入境费用 - Add And Update
  2541. /// </summary>
  2542. /// <returns></returns>
  2543. [HttpPost]
  2544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2545. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  2546. {
  2547. try
  2548. {
  2549. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2550. if (data.Code != 0)
  2551. {
  2552. return Ok(JsonView(false, data.Msg));
  2553. }
  2554. return Ok(JsonView(true, data.Msg, data.Data));
  2555. }
  2556. catch (Exception ex)
  2557. {
  2558. return Ok(JsonView(false, ex.Message));
  2559. }
  2560. }
  2561. /// <summary>
  2562. /// 团组模块 - 出入境费用 - 明细表导出
  2563. /// </summary>
  2564. /// <returns></returns>
  2565. [HttpPost]
  2566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2567. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  2568. {
  2569. try
  2570. {
  2571. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2572. if (data.Code != 0)
  2573. {
  2574. return Ok(JsonView(false, data.Msg));
  2575. }
  2576. return Ok(JsonView(true, data.Msg, data.Data));
  2577. }
  2578. catch (Exception ex)
  2579. {
  2580. return Ok(JsonView(false, ex.Message));
  2581. }
  2582. }
  2583. /// <summary>
  2584. /// 团组模块 - 出入境费用 - 子项删除
  2585. /// </summary>
  2586. /// <returns></returns>
  2587. [HttpPost]
  2588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2589. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  2590. {
  2591. try
  2592. {
  2593. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  2594. if (data.Code != 0)
  2595. {
  2596. return Ok(JsonView(false, data.Msg));
  2597. }
  2598. return Ok(JsonView(true, "操作成功!", data.Data));
  2599. }
  2600. catch (Exception ex)
  2601. {
  2602. return Ok(JsonView(false, ex.Message));
  2603. }
  2604. }
  2605. /// <summary>
  2606. /// 团组模块 - 出入境国家费用标准 List
  2607. /// </summary>
  2608. /// <returns></returns>
  2609. [HttpPost]
  2610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2611. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  2612. {
  2613. try
  2614. {
  2615. Stopwatch sw = new Stopwatch();
  2616. sw.Start();
  2617. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2618. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2619. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2620. Where gntf.Isdel = 0");
  2621. var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2622. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  2623. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  2624. //foreach (var item in nationalTravel)
  2625. //{
  2626. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  2627. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  2628. // if (otherData != null)
  2629. // {
  2630. // cityData.Remove(otherData);
  2631. // cityData.Add(otherData);
  2632. // }
  2633. // nationalTravelFeeData1.Add(new
  2634. // {
  2635. // Country = item.Country,
  2636. // CityData = cityData
  2637. // });
  2638. //}
  2639. sw.Stop();
  2640. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  2641. }
  2642. catch (Exception ex)
  2643. {
  2644. return Ok(JsonView(false, ex.Message));
  2645. throw;
  2646. }
  2647. }
  2648. /// <summary>
  2649. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  2650. /// </summary>
  2651. /// <returns></returns>
  2652. [HttpPost]
  2653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2654. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  2655. {
  2656. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  2657. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  2658. List<string> countryData = new List<string>();
  2659. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  2660. countryData = countryData.Distinct().ToList();
  2661. List<dynamic> dataSource = new List<dynamic>();
  2662. foreach (var item in countryData)
  2663. {
  2664. List<string> cityData1 = new List<string>();
  2665. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  2666. var countryData2 = new
  2667. {
  2668. CountryName = item,
  2669. CityData = cityData1
  2670. };
  2671. dataSource.Add(countryData2);
  2672. }
  2673. return Ok(JsonView(true, "查询成功!", dataSource));
  2674. }
  2675. /// <summary>
  2676. /// 团组模块 - 出入境国家费用标准 Page List
  2677. /// </summary>
  2678. /// <returns></returns>
  2679. [HttpPost]
  2680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2681. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  2682. {
  2683. int portId = dto.PortType;
  2684. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2685. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  2686. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  2687. string whereSql = string.Empty;
  2688. if (!string.IsNullOrEmpty(dto.Country))
  2689. {
  2690. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  2691. }
  2692. if (!string.IsNullOrEmpty(dto.City))
  2693. {
  2694. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  2695. }
  2696. string pageSql = string.Format(@"Select * From (
  2697. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  2698. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  2699. From Grp_NationalTravelFee gntf
  2700. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2701. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2702. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  2703. RefAsync<int> total = 0;
  2704. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  2705. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  2706. }
  2707. /// <summary>
  2708. /// 团组模块 - 出入境国家费用标准 根据城市查询
  2709. /// </summary>
  2710. /// <returns></returns>
  2711. [HttpPost]
  2712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2713. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  2714. {
  2715. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  2716. int portId = dto.PortType;
  2717. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2718. string whereSql = string.Empty;
  2719. if (!string.IsNullOrEmpty(dto.Country))
  2720. {
  2721. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  2722. }
  2723. if (!string.IsNullOrEmpty(dto.City))
  2724. {
  2725. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  2726. }
  2727. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  2728. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  2729. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  2730. From Grp_NationalTravelFee gntf
  2731. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2732. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2733. Where gntf.Isdel = 0 {0} ", whereSql);
  2734. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  2735. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  2736. }
  2737. /// <summary>
  2738. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  2739. /// </summary>
  2740. /// <returns></returns>
  2741. [HttpPost]
  2742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2743. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  2744. {
  2745. try
  2746. {
  2747. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  2748. if (data.Code != 0)
  2749. {
  2750. return Ok(JsonView(false, data.Msg));
  2751. }
  2752. return Ok(JsonView(true, "操作成功!", data.Data));
  2753. }
  2754. catch (Exception ex)
  2755. {
  2756. return Ok(JsonView(false, ex.Message));
  2757. }
  2758. }
  2759. /// <summary>
  2760. /// 团组模块 - 出入境国家费用标准 - Del
  2761. /// </summary>
  2762. /// <returns></returns>
  2763. [HttpPost]
  2764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2765. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  2766. {
  2767. try
  2768. {
  2769. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  2770. {
  2771. Id = dto.Id,
  2772. DeleteUserId = dto.DeleteUserId,
  2773. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  2774. IsDel = 1
  2775. };
  2776. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  2777. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  2778. .WhereColumns(it => new { it.Id })
  2779. .ExecuteCommandAsync();
  2780. if (delStatus <= 0)
  2781. {
  2782. return Ok(JsonView(false, "删除失败!"));
  2783. }
  2784. return Ok(JsonView(true, "操作成功!"));
  2785. }
  2786. catch (Exception ex)
  2787. {
  2788. return Ok(JsonView(false, ex.Message));
  2789. }
  2790. }
  2791. #endregion
  2792. #region 签证费用录入
  2793. /// <summary>
  2794. /// 根据diid查询签证费用列表
  2795. /// </summary>
  2796. /// <param name="dto"></param>
  2797. /// <returns></returns>
  2798. [HttpPost]
  2799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2800. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  2801. {
  2802. try
  2803. {
  2804. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  2805. if (groupData.Code != 0)
  2806. {
  2807. return Ok(JsonView(false, groupData.Msg));
  2808. }
  2809. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2810. }
  2811. catch (Exception ex)
  2812. {
  2813. return Ok(JsonView(false, ex.Message));
  2814. }
  2815. }
  2816. /// <summary>
  2817. /// 根据签证费用Id查询单条数据及c表数据
  2818. /// </summary>
  2819. /// <param name="dto"></param>
  2820. /// <returns></returns>
  2821. [HttpPost]
  2822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2823. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  2824. {
  2825. try
  2826. {
  2827. Result groupData = await _visaPriceRep.PostVisaById(dto);
  2828. if (groupData.Code != 0)
  2829. {
  2830. return Ok(JsonView(false, groupData.Msg));
  2831. }
  2832. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2833. }
  2834. catch (Exception ex)
  2835. {
  2836. return Ok(JsonView(false, ex.Message));
  2837. }
  2838. }
  2839. /// <summary>
  2840. /// 签证费用删除
  2841. /// </summary>
  2842. /// <param name="dto"></param>
  2843. /// <returns></returns>
  2844. [HttpPost]
  2845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2846. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  2847. {
  2848. try
  2849. {
  2850. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  2851. if (!res)
  2852. {
  2853. return Ok(JsonView(false, "删除失败"));
  2854. }
  2855. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
  2856. {
  2857. IsDel = 1,
  2858. DeleteUserId = dto.DeleteUserId,
  2859. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2860. }).ExecuteCommandAsync();
  2861. return Ok(JsonView(true, "删除成功!"));
  2862. }
  2863. catch (Exception ex)
  2864. {
  2865. return Ok(JsonView(false, "程序错误!"));
  2866. throw;
  2867. }
  2868. }
  2869. /// <summary>
  2870. /// 签证费用录入下拉框初始化
  2871. /// </summary>
  2872. /// <returns></returns>
  2873. [HttpPost]
  2874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2875. public async Task<IActionResult> VisaPriceAddSelect()
  2876. {
  2877. try
  2878. {
  2879. //支付方式
  2880. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  2881. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  2882. //币种
  2883. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  2884. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  2885. //乘客类型
  2886. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  2887. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  2888. //卡类型
  2889. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  2890. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  2891. var data = new
  2892. {
  2893. Payment = _Payment,
  2894. CurrencyList = _CurrencyList,
  2895. PassengerType = _PassengerType,
  2896. BankCard = _BankCard
  2897. };
  2898. return Ok(JsonView(true, "查询成功!", data));
  2899. }
  2900. catch (Exception ex)
  2901. {
  2902. return Ok(JsonView(false, "程序错误!"));
  2903. throw;
  2904. }
  2905. }
  2906. /// <summary>
  2907. /// 签证费用录入操作(Status:1.新增,2.修改)
  2908. /// </summary>
  2909. /// <param name="dto"></param>
  2910. /// <returns></returns>
  2911. [HttpPost]
  2912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2913. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  2914. {
  2915. try
  2916. {
  2917. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  2918. if (groupData.Code != 0)
  2919. {
  2920. return Ok(JsonView(false, groupData.Msg));
  2921. }
  2922. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2923. }
  2924. catch (Exception ex)
  2925. {
  2926. return Ok(JsonView(false, ex.Message));
  2927. }
  2928. }
  2929. #endregion
  2930. #region op费用录入
  2931. /// <summary>
  2932. /// 根据diid查询op费用列表
  2933. /// </summary>
  2934. /// <param name="dto"></param>
  2935. /// <returns></returns>
  2936. [HttpPost]
  2937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2938. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  2939. {
  2940. try
  2941. {
  2942. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  2943. if (groupData.Code != 0)
  2944. {
  2945. return Ok(JsonView(false, groupData.Msg));
  2946. }
  2947. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2948. }
  2949. catch (Exception ex)
  2950. {
  2951. return Ok(JsonView(false, ex.Message));
  2952. }
  2953. }
  2954. /// <summary>
  2955. /// 根据op费用Id查询单条数据及c表数据
  2956. /// </summary>
  2957. /// <param name="dto"></param>
  2958. /// <returns></returns>
  2959. [HttpPost]
  2960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2961. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  2962. {
  2963. try
  2964. {
  2965. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  2966. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  2967. var data = new
  2968. {
  2969. CarTouristGuideGround = _groupData,
  2970. CreditCardPayment = _creditCardPayment
  2971. };
  2972. return Ok(JsonView(true, "查询成功!", data));
  2973. }
  2974. catch (Exception ex)
  2975. {
  2976. return Ok(JsonView(false, "程序错误!"));
  2977. }
  2978. }
  2979. /// <summary>
  2980. /// op费用删除
  2981. /// </summary>
  2982. /// <param name="dto"></param>
  2983. /// <returns></returns>
  2984. [HttpPost]
  2985. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2986. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  2987. {
  2988. try
  2989. {
  2990. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2991. if (!res)
  2992. {
  2993. return Ok(JsonView(false, "删除失败"));
  2994. }
  2995. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  2996. {
  2997. IsDel = 1,
  2998. DeleteUserId = dto.DeleteUserId,
  2999. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3000. }).ExecuteCommandAsync();
  3001. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  3002. {
  3003. IsDel = 1,
  3004. DeleteUserId = dto.DeleteUserId,
  3005. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3006. }).ExecuteCommandAsync();
  3007. return Ok(JsonView(true, "删除成功!"));
  3008. }
  3009. catch (Exception ex)
  3010. {
  3011. return Ok(JsonView(false, "程序错误!"));
  3012. throw;
  3013. }
  3014. }
  3015. /// <summary>
  3016. /// op费用录入操作(Status:1.新增,2.修改)
  3017. /// </summary>
  3018. /// <param name="dto"></param>
  3019. /// <returns></returns>
  3020. [HttpPost]
  3021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3022. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  3023. {
  3024. try
  3025. {
  3026. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  3027. if (groupData.Code != 0)
  3028. {
  3029. return Ok(JsonView(false, groupData.Msg));
  3030. }
  3031. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3032. }
  3033. catch (Exception ex)
  3034. {
  3035. return Ok(JsonView(false, ex.Message));
  3036. }
  3037. }
  3038. /// <summary>
  3039. /// 填写费用详细页面初始化绑定
  3040. /// </summary>
  3041. /// <param name="dto"></param>
  3042. /// <returns></returns>
  3043. [HttpPost]
  3044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3045. public async Task<IActionResult> CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  3046. {
  3047. try
  3048. {
  3049. Result groupData = await _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  3050. if (groupData.Code != 0)
  3051. {
  3052. return Ok(JsonView(false, groupData.Msg));
  3053. }
  3054. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3055. }
  3056. catch (Exception ex)
  3057. {
  3058. return Ok(JsonView(false, ex.Message));
  3059. }
  3060. }
  3061. /// <summary>
  3062. /// 根据op费用Id查询详细数据
  3063. /// </summary>
  3064. /// <param name="dto"></param>
  3065. /// <returns></returns>
  3066. [HttpPost]
  3067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3068. public async Task<IActionResult> OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  3069. {
  3070. try
  3071. {
  3072. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  3073. if (groupData.Code != 0)
  3074. {
  3075. return Ok(JsonView(false, groupData.Msg));
  3076. }
  3077. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3078. }
  3079. catch (Exception ex)
  3080. {
  3081. return Ok(JsonView(false, ex.Message));
  3082. }
  3083. }
  3084. /// <summary>
  3085. /// OP费用录入填写详情
  3086. /// </summary>
  3087. /// <param name="dto"></param>
  3088. /// <returns></returns>
  3089. [HttpPost]
  3090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3091. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  3092. {
  3093. try
  3094. {
  3095. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  3096. if (groupData.Code != 0)
  3097. {
  3098. return Ok(JsonView(false, groupData.Msg));
  3099. }
  3100. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3101. }
  3102. catch (Exception ex)
  3103. {
  3104. return Ok(JsonView(false, ex.Message));
  3105. }
  3106. }
  3107. #endregion
  3108. #region 团组成本
  3109. /// <summary>
  3110. /// 团组成本数据初始化
  3111. /// </summary>
  3112. /// <param name="dto"></param>
  3113. /// <returns></returns>
  3114. [HttpPost]
  3115. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  3116. {
  3117. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  3118. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  3119. WHEN COUNT(*) >= 0 THEN 'True'
  3120. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  3121. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  3122. ").ToList(); //团组列表
  3123. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  3124. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  3125. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  3126. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  3127. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  3128. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  3129. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  3130. //GroupCostParameter.Add(new
  3131. // Grp_GroupCostParameter());
  3132. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  3133. return Ok(JsonView(new
  3134. {
  3135. groupList,
  3136. groupInfo,
  3137. groupChecks,
  3138. groupCost = groupCostMap,
  3139. hotelNumber,
  3140. GroupCostParameter = GroupCostParameterMap,
  3141. }));
  3142. }
  3143. /// <summary>
  3144. /// 团组成本信息保存
  3145. /// </summary>
  3146. /// <param name="dto"></param>
  3147. /// <returns></returns>
  3148. [HttpPost]
  3149. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  3150. {
  3151. JsonView jw = null;
  3152. bool isTrue = false;
  3153. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  3154. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  3155. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  3156. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  3157. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  3158. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  3159. try
  3160. {
  3161. _sqlSugar.BeginTran();
  3162. isTrue = await _GroupCostRepository.
  3163. SaveGroupCostList(Grp_groups,dto.Diid); //列表
  3164. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs,dto.Diid); //选中项
  3165. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber,dto.Userid,dto.Diid); //酒店房间数量
  3166. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters , dto.Userid ,dto.Diid); //系数
  3167. _sqlSugar.CommitTran();
  3168. jw = JsonView(true, "保存成功!", isTrue);
  3169. }
  3170. catch (Exception)
  3171. {
  3172. _sqlSugar.RollbackTran();
  3173. jw = JsonView(false);
  3174. }
  3175. return Ok(jw);
  3176. }
  3177. /// <summary>
  3178. /// 司兼导数据
  3179. /// </summary>
  3180. /// <param name="dto"></param>
  3181. /// <returns></returns>
  3182. [HttpPost]
  3183. public IActionResult GetCarGuides(CarGuidesDto dto)
  3184. {
  3185. JsonView jw = null;
  3186. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  3187. jw = JsonView(true, "获取成功!", Data);
  3188. return Ok(jw);
  3189. }
  3190. /// <summary>
  3191. /// 导游数据
  3192. /// </summary>
  3193. /// <param name="dto"></param>
  3194. /// <returns></returns>
  3195. [HttpPost]
  3196. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  3197. {
  3198. JsonView jw = null;
  3199. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  3200. // SELECT*,ROW_NUMBER() OVER (ORDER BY Id) AS RowNumber FROM Grp_GuidesInfo where (city like '%{dto.City}%' or country like '%{dto.City}%' ) and isdel = 0 ) as b
  3201. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  3202. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  3203. jw = JsonView(true, "获取成功!", Data);
  3204. return Ok(jw);
  3205. }
  3206. /// <summary>
  3207. /// 成本车数据
  3208. /// </summary>
  3209. /// <param name="dto"></param>
  3210. /// <returns></returns>
  3211. [HttpPost]
  3212. public IActionResult GetCarInfo(CarGuidesDto dto)
  3213. {
  3214. JsonView jw = null;
  3215. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  3216. jw = JsonView(true, "获取成功!", Data);
  3217. return Ok(jw);
  3218. }
  3219. /// <summary>
  3220. /// 景点数据
  3221. /// </summary>
  3222. /// <param name="dto"></param>
  3223. /// <returns></returns>
  3224. [HttpPost]
  3225. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  3226. {
  3227. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  3228. return Ok(JsonView(true, "获取成功!", Data));
  3229. }
  3230. #endregion
  3231. #region 酒店预定
  3232. /// <summary>
  3233. /// 酒店预订页面初始化绑定
  3234. /// </summary>
  3235. /// <param name="dto"></param>
  3236. /// <returns></returns>
  3237. [HttpPost]
  3238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3239. public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
  3240. {
  3241. try
  3242. {
  3243. Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
  3244. if (groupData.Code != 0)
  3245. {
  3246. return Ok(JsonView(false, groupData.Msg));
  3247. }
  3248. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3249. }
  3250. catch (Exception ex)
  3251. {
  3252. return Ok(JsonView(false, ex.Message));
  3253. }
  3254. }
  3255. /// <summary>
  3256. /// 根据团组Id查询酒店费用列表
  3257. /// </summary>
  3258. /// <param name="dto"></param>
  3259. /// <returns></returns>
  3260. [HttpPost]
  3261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3262. public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  3263. {
  3264. try
  3265. {
  3266. Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
  3267. if (groupData.Code != 0)
  3268. {
  3269. return Ok(JsonView(false, groupData.Msg));
  3270. }
  3271. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3272. }
  3273. catch (Exception ex)
  3274. {
  3275. return Ok(JsonView(false, ex.Message));
  3276. }
  3277. }
  3278. /// <summary>
  3279. /// 根据酒店费用Id查询酒店费用详细
  3280. /// </summary>
  3281. /// <param name="dto"></param>
  3282. /// <returns></returns>
  3283. [HttpPost]
  3284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3285. public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
  3286. {
  3287. try
  3288. {
  3289. Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
  3290. if (groupData.Code != 0)
  3291. {
  3292. return Ok(JsonView(false, groupData.Msg));
  3293. }
  3294. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3295. }
  3296. catch (Exception ex)
  3297. {
  3298. return Ok(JsonView(false, ex.Message));
  3299. }
  3300. }
  3301. /// <summary>
  3302. /// 计算酒店付款总金额
  3303. /// </summary>
  3304. /// <param name="dto"></param>
  3305. /// <returns></returns>
  3306. [HttpPost]
  3307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3308. public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
  3309. {
  3310. try
  3311. {
  3312. Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
  3313. if (groupData.Code != 0)
  3314. {
  3315. return Ok(JsonView(false, groupData.Msg));
  3316. }
  3317. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3318. }
  3319. catch (Exception ex)
  3320. {
  3321. return Ok(JsonView(false, ex.Message));
  3322. }
  3323. }
  3324. /// <summary>
  3325. /// 酒店费用操作(Status:1.新增,2.修改)
  3326. /// </summary>
  3327. /// <param name="dto"></param>
  3328. /// <returns></returns>
  3329. [HttpPost]
  3330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3331. public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
  3332. {
  3333. try
  3334. {
  3335. Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
  3336. if (groupData.Code != 0)
  3337. {
  3338. return Ok(JsonView(false, groupData.Msg));
  3339. }
  3340. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3341. }
  3342. catch (Exception ex)
  3343. {
  3344. return Ok(JsonView(false, ex.Message));
  3345. }
  3346. }
  3347. /// <summary>
  3348. /// 文件上传
  3349. /// </summary>
  3350. /// <param name="file"></param>
  3351. /// <returns></returns>
  3352. [HttpPost]
  3353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3354. public async Task<IActionResult> UploadHotel(IFormFile file)
  3355. {
  3356. try
  3357. {
  3358. if (file != null)
  3359. {
  3360. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3361. //文件名称
  3362. string projectFileName = file.FileName;
  3363. //上传的文件的路径
  3364. string filePath = "";
  3365. if (!Directory.Exists(fileDir))
  3366. {
  3367. Directory.CreateDirectory(fileDir);
  3368. }
  3369. //上传的文件的路径
  3370. filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
  3371. using (FileStream fs = System.IO.File.Create(filePath))
  3372. {
  3373. file.CopyTo(fs);
  3374. fs.Flush();
  3375. }
  3376. return Ok(JsonView(true, "上传成功!", projectFileName));
  3377. }
  3378. else
  3379. {
  3380. return Ok(JsonView(false, "上传失败!"));
  3381. }
  3382. }
  3383. catch (Exception ex)
  3384. {
  3385. return Ok(JsonView(false, "程序错误!"));
  3386. throw;
  3387. }
  3388. }
  3389. /// <summary>
  3390. /// 删除指定文件
  3391. /// </summary>
  3392. /// <param name="dto"></param>
  3393. /// <returns></returns>
  3394. [HttpPost]
  3395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3396. public async Task<IActionResult> DelFileHotel(DelFileDto dto)
  3397. {
  3398. try
  3399. {
  3400. string filePath = "";
  3401. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3402. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3403. //int id = 0;
  3404. filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
  3405. // 删除该文件
  3406. try
  3407. {
  3408. System.IO.File.Delete(filePath);
  3409. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3410. {
  3411. Attachment = "",
  3412. }).ExecuteCommandAsync();
  3413. if (result != 0)
  3414. {
  3415. return Ok(JsonView(true, "成功!"));
  3416. }
  3417. else
  3418. {
  3419. return Ok(JsonView(false, "失败!"));
  3420. }
  3421. }
  3422. catch (Exception)
  3423. {
  3424. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3425. {
  3426. Attachment = "",
  3427. }).ExecuteCommandAsync();
  3428. if (result != 0)
  3429. {
  3430. return Ok(JsonView(true, "成功!"));
  3431. }
  3432. else
  3433. {
  3434. return Ok(JsonView(false, "失败!"));
  3435. }
  3436. throw;
  3437. }
  3438. }
  3439. catch (Exception ex)
  3440. {
  3441. return Ok(JsonView(false, "程序错误!"));
  3442. throw;
  3443. }
  3444. }
  3445. /// <summary>
  3446. /// 生成VOUCHER
  3447. /// </summary>
  3448. /// <param name=""></param>
  3449. /// <returns></returns>
  3450. [HttpPost]
  3451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3452. public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
  3453. {
  3454. Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
  3455. //判断数据是否完整
  3456. if (h != null)
  3457. {
  3458. if (!string.IsNullOrEmpty(h.DetermineNo))
  3459. {
  3460. string strFileName = "HotelStatement/";
  3461. Grp_DelegationInfo dele= _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
  3462. if (dele != null)
  3463. strFileName += dele.TourCode;
  3464. //载入模板
  3465. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3466. Document doc = new Document(sss);
  3467. DocumentBuilder builder = new DocumentBuilder(doc);
  3468. try
  3469. {
  3470. #region 替换Word模板书签内容
  3471. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  3472. //入住卷预定号码
  3473. if (doc.Range.Bookmarks["VNO"] != null)
  3474. {
  3475. Bookmark mark = doc.Range.Bookmarks["VNO"];
  3476. mark.Text = h.CheckNumber;
  3477. }
  3478. //酒店时间
  3479. if (doc.Range.Bookmarks["Date"] != null)
  3480. {
  3481. Bookmark mark = doc.Range.Bookmarks["Date"];
  3482. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3483. }
  3484. //团号
  3485. if (doc.Range.Bookmarks["TNo"] != null)
  3486. {
  3487. Bookmark mark = doc.Range.Bookmarks["TNo"];
  3488. mark.Text = dele.TourCode;
  3489. }
  3490. //预定号码
  3491. if (doc.Range.Bookmarks["BookingId"] != null)
  3492. {
  3493. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  3494. mark.Text = h.ReservationsNo;
  3495. }
  3496. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  3497. {
  3498. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  3499. mark.Text = h.DetermineNo;
  3500. }
  3501. //酒店城市
  3502. if (doc.Range.Bookmarks["City"] != null)
  3503. {
  3504. Bookmark mark = doc.Range.Bookmarks["City"];
  3505. mark.Text = h.City;
  3506. }
  3507. //酒店名称
  3508. if (doc.Range.Bookmarks["HName"] != null)
  3509. {
  3510. Bookmark mark = doc.Range.Bookmarks["HName"];
  3511. mark.Text = h.HotelName;
  3512. }
  3513. //酒店地址
  3514. if (doc.Range.Bookmarks["Address"] != null)
  3515. {
  3516. Bookmark mark = doc.Range.Bookmarks["Address"];
  3517. mark.Text = h.HotelAddress;
  3518. }
  3519. //酒店电话
  3520. if (doc.Range.Bookmarks["Tel"] != null)
  3521. {
  3522. Bookmark mark = doc.Range.Bookmarks["Tel"];
  3523. mark.Text = h.HotelTel;
  3524. }
  3525. //酒店传真
  3526. if (doc.Range.Bookmarks["Fax"] != null)
  3527. {
  3528. Bookmark mark = doc.Range.Bookmarks["Fax"];
  3529. if (!string.IsNullOrWhiteSpace(h.HotelFax))
  3530. {
  3531. mark.Text = h.HotelFax;
  3532. }
  3533. }
  3534. //入住时间
  3535. if (doc.Range.Bookmarks["CIn"] != null)
  3536. {
  3537. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3538. Bookmark mark = doc.Range.Bookmarks["CIn"];
  3539. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  3540. }
  3541. //退房时间
  3542. if (doc.Range.Bookmarks["COut"] != null)
  3543. {
  3544. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3545. Bookmark mark = doc.Range.Bookmarks["COut"];
  3546. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3547. }
  3548. //客户名称
  3549. if (doc.Range.Bookmarks["GName"] != null)
  3550. {
  3551. Bookmark mark = doc.Range.Bookmarks["GName"];
  3552. mark.Text = h.GuestName;
  3553. }
  3554. //房间介绍
  3555. if (doc.Range.Bookmarks["ROOM"] != null)
  3556. {
  3557. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  3558. mark.Text = h.RoomExplanation;
  3559. }
  3560. //报价描述
  3561. if (doc.Range.Bookmarks["NOTE"] != null)
  3562. {
  3563. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  3564. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a=>a.Id==h.ReservationsWebsite);
  3565. if (ss != null)
  3566. mark.Text = ss.Name;
  3567. }
  3568. //入住时间
  3569. if (doc.Range.Bookmarks["CheckIn"] != null)
  3570. {
  3571. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3572. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  3573. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  3574. }
  3575. //退房时间
  3576. if (doc.Range.Bookmarks["CheckOut"] != null)
  3577. {
  3578. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3579. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  3580. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3581. }
  3582. //日期
  3583. if (doc.Range.Bookmarks["DT"] != null)
  3584. {
  3585. Bookmark mark = doc.Range.Bookmarks["DT"];
  3586. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3587. }
  3588. //名称
  3589. if (doc.Range.Bookmarks["VName"] != null)
  3590. {
  3591. Bookmark mark = doc.Range.Bookmarks["VName"];
  3592. mark.Text = h.HotelName;
  3593. }
  3594. //号码
  3595. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  3596. {
  3597. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  3598. mark.Text = h.CheckNumber;
  3599. }
  3600. #endregion
  3601. //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  3602. strFileName += "VOUCHER.doc";
  3603. var fileDir = AppSettingsHelper.Get("WordBasePath")+ strFileName;
  3604. doc.Save(fileDir);
  3605. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  3606. return Ok(JsonView(true, "成功!", Url));
  3607. //保存为doc,并打开
  3608. }
  3609. catch (Exception ex)
  3610. {
  3611. throw;
  3612. }
  3613. }
  3614. else
  3615. {
  3616. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3617. }
  3618. }
  3619. else
  3620. {
  3621. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3622. }
  3623. }
  3624. /// <summary>
  3625. /// 导出确认单
  3626. /// </summary>
  3627. /// <param name=""></param>
  3628. /// <returns></returns>
  3629. [HttpPost]
  3630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3631. public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
  3632. {
  3633. //团组信息
  3634. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
  3635. //酒店数据
  3636. List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
  3637. //利datatable存储
  3638. DataTable dt = new DataTable();
  3639. dt.Columns.Add("CheckInDate", typeof(string));
  3640. dt.Columns.Add("City", typeof(string));
  3641. dt.Columns.Add("Hotel", typeof(string));
  3642. dt.Columns.Add("Room", typeof(string));
  3643. for (int i = 0; i < listhoteldata.Count; i++)
  3644. {
  3645. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  3646. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  3647. while (dayStart < dayEnd)
  3648. {
  3649. string temp = "";
  3650. DataRow row = dt.NewRow();
  3651. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  3652. row["City"] = listhoteldata[i].City;
  3653. row["Hotel"] = listhoteldata[i].HotelName;
  3654. if (listhoteldata[i].SingleRoomCount > 0)
  3655. {
  3656. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  3657. }
  3658. if (listhoteldata[i].DoubleRoomCount > 0)
  3659. {
  3660. temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
  3661. }
  3662. if (listhoteldata[i].SuiteRoomCount > 0)
  3663. {
  3664. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  3665. }
  3666. if (listhoteldata[i].OtherRoomCount > 0)
  3667. {
  3668. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  3669. }
  3670. row["Room"] = temp;
  3671. dt.Rows.Add(row);
  3672. dayStart = dayStart.AddDays(1);
  3673. }
  3674. }
  3675. Dictionary<string, string> dic = new Dictionary<string, string>();
  3676. dic.Add("Dele", di.TeamName);
  3677. dic.Add("City", di.VisitCountry);
  3678. //模板路径
  3679. //string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3680. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  3681. //载入模板
  3682. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  3683. DocumentBuilder builder = new DocumentBuilder(doc);
  3684. foreach (var key in dic.Keys)
  3685. {
  3686. builder.MoveToBookmark(key);
  3687. builder.Write(dic[key]);
  3688. }
  3689. //获取word里所有表格
  3690. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3691. //获取所填表格的序数
  3692. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3693. var rowStart = tableOne.Rows[0]; //获取第1行
  3694. try
  3695. {
  3696. //循环赋值
  3697. for (int i = 0; i < dt.Rows.Count; i++)
  3698. {
  3699. builder.MoveToCell(0, i + 1, 0, 0);
  3700. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  3701. builder.MoveToCell(0, i + 1, 1, 0);
  3702. builder.Write(dt.Rows[i]["City"].ToString());
  3703. builder.MoveToCell(0, i + 1, 2, 0);
  3704. builder.Write(dt.Rows[i]["Hotel"].ToString());
  3705. builder.MoveToCell(0, i + 1, 3, 0);
  3706. builder.Write(dt.Rows[i]["Room"].ToString());
  3707. }
  3708. }
  3709. catch
  3710. {
  3711. }
  3712. //删除多余行
  3713. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  3714. {
  3715. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  3716. }
  3717. string strFileName = di.TeamName + "酒店确认单.doc";
  3718. try
  3719. {
  3720. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  3721. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  3722. return Ok(JsonView(true, "成功", Url));
  3723. }
  3724. catch (Exception)
  3725. {
  3726. return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
  3727. throw;
  3728. }
  3729. //doc.Save(HttpUtility.UrlEncode(strFileName, Encoding.UTF8), Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);
  3730. }
  3731. /// <summary>
  3732. /// 酒店费用删除
  3733. /// </summary>
  3734. /// <param name="dto"></param>
  3735. /// <returns></returns>
  3736. [HttpPost]
  3737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3738. public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
  3739. {
  3740. try
  3741. {
  3742. var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3743. if (!res)
  3744. {
  3745. return Ok(JsonView(false, "删除失败"));
  3746. }
  3747. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
  3748. {
  3749. IsDel = 1,
  3750. DeleteUserId = dto.DeleteUserId,
  3751. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3752. }).ExecuteCommandAsync();
  3753. return Ok(JsonView(true, "删除成功!"));
  3754. }
  3755. catch (Exception ex)
  3756. {
  3757. return Ok(JsonView(false, "程序错误!"));
  3758. throw;
  3759. }
  3760. }
  3761. #endregion
  3762. #region 团组状态
  3763. /// <summary>
  3764. /// 团组状态列表 Page
  3765. /// </summary>
  3766. /// <param name="dto">团组列表请求dto</param>
  3767. /// <returns></returns>
  3768. [HttpPost]
  3769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3770. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  3771. {
  3772. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  3773. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  3774. {
  3775. string sqlWhere = string.Empty;
  3776. if (dto.IsSure == 0) //未完成
  3777. {
  3778. sqlWhere += string.Format(@" And IsSure = 0");
  3779. }
  3780. else if (dto.IsSure == 1) //已完成
  3781. {
  3782. sqlWhere += string.Format(@" And IsSure = 1");
  3783. }
  3784. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  3785. {
  3786. string tj = dto.SearchCriteria;
  3787. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  3788. tj, tj, tj, tj, tj);
  3789. }
  3790. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3791. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  3792. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3793. From (
  3794. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  3795. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  3796. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  3797. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3798. From Grp_DelegationInfo gdi
  3799. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3800. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3801. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3802. Where gdi.IsDel = 0 {0}
  3803. ) temp ", sqlWhere);
  3804. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3805. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  3806. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  3807. }
  3808. else
  3809. {
  3810. return Ok(JsonView(false, "查询失败"));
  3811. }
  3812. }
  3813. /// <summary>
  3814. /// 团组状态
  3815. /// 设置操作完成
  3816. /// </summary>
  3817. /// <param name="dto">团组列表请求dto</param>
  3818. /// <returns></returns>
  3819. [HttpPost]
  3820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3821. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  3822. {
  3823. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  3824. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  3825. {
  3826. Id = dto.Id,
  3827. IsSure = 1
  3828. };
  3829. var result = await _sqlSugar.Updateable(_DelegationInfo)
  3830. .UpdateColumns(it => new { it.IsSure })
  3831. .WhereColumns(it => new { it.Id })
  3832. .ExecuteCommandAsync();
  3833. if (result > 0)
  3834. {
  3835. return Ok(JsonView(true, "操作完成!"));
  3836. }
  3837. return Ok(JsonView(false, "操作失败!"));
  3838. }
  3839. #endregion
  3840. #region 保险费用录入
  3841. /// <summary>
  3842. /// 根据团组Id查询保险费用列表
  3843. /// </summary>
  3844. /// <param name="dto"></param>
  3845. /// <returns></returns>
  3846. [HttpPost]
  3847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3848. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  3849. {
  3850. try
  3851. {
  3852. Result groupData = await _customersRep.CustomersByDiId(dto);
  3853. if (groupData.Code != 0)
  3854. {
  3855. return Ok(JsonView(false, groupData.Msg));
  3856. }
  3857. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3858. }
  3859. catch (Exception ex)
  3860. {
  3861. return Ok(JsonView(false, ex.Message));
  3862. }
  3863. }
  3864. /// <summary>
  3865. /// 根据保险费用Id查询保险费用详细
  3866. /// </summary>
  3867. /// <param name="dto"></param>
  3868. /// <returns></returns>
  3869. [HttpPost]
  3870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3871. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  3872. {
  3873. try
  3874. {
  3875. Result groupData = await _customersRep.CustomersById(dto);
  3876. if (groupData.Code != 0)
  3877. {
  3878. return Ok(JsonView(false, groupData.Msg));
  3879. }
  3880. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3881. }
  3882. catch (Exception ex)
  3883. {
  3884. return Ok(JsonView(false, ex.Message));
  3885. }
  3886. }
  3887. /// <summary>
  3888. /// 酒店预订页面初始化绑定
  3889. /// </summary>
  3890. /// <param name="dto"></param>
  3891. /// <returns></returns>
  3892. [HttpPost]
  3893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3894. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  3895. {
  3896. try
  3897. {
  3898. Result groupData = await _customersRep.CustomersInitialize(dto);
  3899. if (groupData.Code != 0)
  3900. {
  3901. return Ok(JsonView(false, groupData.Msg));
  3902. }
  3903. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3904. }
  3905. catch (Exception ex)
  3906. {
  3907. return Ok(JsonView(false, ex.Message));
  3908. }
  3909. }
  3910. /// <summary>
  3911. /// 保险费用操作(Status:1.新增,2.修改)
  3912. /// </summary>
  3913. /// <param name="dto"></param>
  3914. /// <returns></returns>
  3915. [HttpPost]
  3916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3917. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  3918. {
  3919. try
  3920. {
  3921. Result groupData = await _customersRep.OpCustomers(dto);
  3922. if (groupData.Code != 0)
  3923. {
  3924. return Ok(JsonView(false, groupData.Msg));
  3925. }
  3926. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3927. }
  3928. catch (Exception ex)
  3929. {
  3930. return Ok(JsonView(false, ex.Message));
  3931. }
  3932. }
  3933. /// <summary>
  3934. /// 文件上传
  3935. /// </summary>
  3936. /// <param name="file"></param>
  3937. /// <returns></returns>
  3938. [HttpPost]
  3939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3940. public async Task<IActionResult> UploadCus(IFormFile file)
  3941. {
  3942. try
  3943. {
  3944. if (file != null)
  3945. {
  3946. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3947. //文件名称
  3948. string projectFileName = file.FileName;
  3949. //上传的文件的路径
  3950. string filePath = "";
  3951. if (!Directory.Exists(fileDir))
  3952. {
  3953. Directory.CreateDirectory(fileDir);
  3954. }
  3955. //上传的文件的路径
  3956. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  3957. using (FileStream fs = System.IO.File.Create(filePath))
  3958. {
  3959. file.CopyTo(fs);
  3960. fs.Flush();
  3961. }
  3962. return Ok(JsonView(true, "上传成功!", projectFileName));
  3963. }
  3964. else
  3965. {
  3966. return Ok(JsonView(false, "上传失败!"));
  3967. }
  3968. }
  3969. catch (Exception ex)
  3970. {
  3971. return Ok(JsonView(false, "程序错误!"));
  3972. throw;
  3973. }
  3974. }
  3975. /// <summary>
  3976. /// 删除指定文件
  3977. /// </summary>
  3978. /// <param name="dto"></param>
  3979. /// <returns></returns>
  3980. [HttpPost]
  3981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3982. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  3983. {
  3984. try
  3985. {
  3986. string filePath = "";
  3987. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3988. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3989. //int id = 0;
  3990. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  3991. // 删除该文件
  3992. try
  3993. {
  3994. System.IO.File.Delete(filePath);
  3995. var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
  3996. {
  3997. Attachment = "",
  3998. }).ExecuteCommandAsync();
  3999. if (result != 0)
  4000. {
  4001. return Ok(JsonView(true, "成功!"));
  4002. }
  4003. else
  4004. {
  4005. return Ok(JsonView(false, "失败!"));
  4006. }
  4007. }
  4008. catch (Exception)
  4009. {
  4010. var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
  4011. {
  4012. Attachment = "",
  4013. }).ExecuteCommandAsync();
  4014. if (result != 0)
  4015. {
  4016. return Ok(JsonView(true, "成功!"));
  4017. }
  4018. else
  4019. {
  4020. return Ok(JsonView(false, "失败!"));
  4021. }
  4022. }
  4023. }
  4024. catch (Exception ex)
  4025. {
  4026. return Ok(JsonView(false, "程序错误!"));
  4027. throw;
  4028. }
  4029. }
  4030. /// <summary>
  4031. /// 保险费用操作(删除)
  4032. /// </summary>
  4033. /// <param name="dto"></param>
  4034. /// <returns></returns>
  4035. [HttpPost]
  4036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4037. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  4038. {
  4039. try
  4040. {
  4041. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  4042. if (!res)
  4043. {
  4044. return Ok(JsonView(false, "删除失败"));
  4045. }
  4046. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  4047. {
  4048. IsDel = 1,
  4049. DeleteUserId = dto.DeleteUserId,
  4050. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4051. }).ExecuteCommandAsync();
  4052. return Ok(JsonView(true, "删除成功!"));
  4053. }
  4054. catch (Exception ex)
  4055. {
  4056. return Ok(JsonView(false, "程序错误!"));
  4057. throw;
  4058. }
  4059. }
  4060. #endregion
  4061. }
  4062. }