GroupsController.cs 187 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495
  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. }