ResourceController.cs 194 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using EyeSoft.Extensions;
  4. using EyeSoft.Reflection;
  5. using NPOI.SS.Formula.Functions;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  8. using OASystem.Domain.AesEncryption;
  9. using OASystem.Domain.Dtos.CRM;
  10. using OASystem.Domain.Dtos.Groups;
  11. using OASystem.Domain.Dtos.PersonnelModule;
  12. using OASystem.Domain.Entities.Groups;
  13. using OASystem.Domain.ViewModels.Groups;
  14. using OASystem.Domain.ViewModels.JuHeExchangeRate;
  15. using OASystem.Domain.ViewModels.QiYeWeChat;
  16. using OASystem.Infrastructure.Repositories.Groups;
  17. using Org.BouncyCastle.Asn1.X509;
  18. using Org.BouncyCastle.Utilities.Encoders;
  19. using System.Data;
  20. using System.Diagnostics;
  21. using System.IO;
  22. using static OASystem.API.OAMethodLib.JWTHelper;
  23. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  24. using static QRCoder.PayloadGenerator.SwissQrCode;
  25. namespace OASystem.API.Controllers
  26. {
  27. /// <summary>
  28. /// 资料相关
  29. /// </summary>
  30. //[Authorize]
  31. [Route("api/[controller]/[action]")]
  32. public class ResourceController : ControllerBase
  33. {
  34. private readonly IMapper _mapper;
  35. private readonly SqlSugarClient _sqlSugar;
  36. private readonly IConfiguration _config;
  37. private readonly CarDataRepository _carDataRep;
  38. private readonly LocalGuideDataRepository _localGuideDataRep;
  39. private readonly ThreeCodeRepository _ThreeCodeRep;
  40. private readonly HotelDataRepository _hotelDataRep;
  41. private readonly ResItemInfoRepository _resItemInfoRep;
  42. private readonly SetDataRepository _setDataRepository;
  43. private readonly CountryFeeRepository _countryFeeRep;
  44. private readonly SetDataTypeRepository _setDataTypeRep;
  45. private readonly AirTicketAgentRepository _airTicketAgentRep;
  46. private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
  47. private readonly OfficialActivitiesRepository _officialActivitiesRep;
  48. private readonly AskDataRepository _askDataRep;
  49. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  50. private readonly TourClientListRepository _tourClientListRep;
  51. private readonly DelegationInfoRepository _delegationInfoRep;
  52. private readonly TranslatorLibraryRepository _translatorRep;
  53. private readonly MediaSuppliersRepository _mediaSupplierRep;
  54. private readonly List<int> _portIds;
  55. private readonly BasicInsuranceCostRepository _insuranceCostRep;
  56. public ResourceController(
  57. IMapper mapper,
  58. IConfiguration config,
  59. SqlSugarClient sqlSugar,
  60. CarDataRepository carDataRep,
  61. LocalGuideDataRepository localGuideDataRep,
  62. ThreeCodeRepository threeCodeRep,
  63. HotelDataRepository hotelDataRep,
  64. ResItemInfoRepository resItemInfoRep,
  65. SetDataRepository setDataRepository,
  66. CountryFeeRepository countryFeeRep,
  67. SetDataTypeRepository setDataTypeRep,
  68. AirTicketAgentRepository airTicketAgentRep,
  69. InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep,
  70. OfficialActivitiesRepository officialActivitiesRep,
  71. AskDataRepository askDataRep,
  72. TicketBlackCodeRepository ticketBlackCodeRep,
  73. TourClientListRepository tourClientListRep,
  74. DelegationInfoRepository delegationInfoRep,
  75. TranslatorLibraryRepository translatorRep,
  76. MediaSuppliersRepository mediaSupplierRep,
  77. BasicInsuranceCostRepository insuranceCostRep
  78. )
  79. {
  80. _mapper = mapper;
  81. _config = config;
  82. _sqlSugar = sqlSugar;
  83. _carDataRep = carDataRep;
  84. _localGuideDataRep = localGuideDataRep;
  85. _ThreeCodeRep = threeCodeRep;
  86. _hotelDataRep = hotelDataRep;
  87. _resItemInfoRep = resItemInfoRep;
  88. _setDataRepository = setDataRepository;
  89. _countryFeeRep = countryFeeRep;
  90. _setDataTypeRep = setDataTypeRep;
  91. _airTicketAgentRep = airTicketAgentRep;
  92. _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
  93. _officialActivitiesRep = officialActivitiesRep;
  94. _askDataRep = askDataRep;
  95. _ticketBlackCodeRep = ticketBlackCodeRep;
  96. _tourClientListRep = tourClientListRep;
  97. _delegationInfoRep = delegationInfoRep;
  98. _translatorRep = translatorRep;
  99. _mediaSupplierRep = mediaSupplierRep;
  100. _portIds = new List<int> { 1, 2, 3 };
  101. _insuranceCostRep = insuranceCostRep;
  102. }
  103. #region 车公司资料板块
  104. /// <summary>
  105. /// 车公司信息查询
  106. /// </summary>
  107. /// <returns></returns>
  108. [HttpPost]
  109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  110. public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
  111. {
  112. Result LocalGuide = await _carDataRep.QueryCarData(dto);
  113. if (LocalGuide.Code == 0)
  114. {
  115. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  116. }
  117. else
  118. {
  119. return Ok(JsonView(false, LocalGuide.Msg));
  120. }
  121. }
  122. /// <summary>
  123. /// 车公司资料下拉框数据
  124. /// </summary>
  125. /// <returns></returns>
  126. [HttpPost]
  127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  128. public async Task<IActionResult> QueryCarSelect()
  129. {
  130. var carData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
  131. if (carData.Count == 0)
  132. {
  133. return Ok(JsonView(false, "暂无数据!"));
  134. }
  135. foreach (var item in carData) EncryptionProcessor.DecryptProperties(item);
  136. carData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
  137. carData = carData.Where((x, i) => carData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
  138. carData = carData.OrderBy(x => x.Id).ToList();
  139. var data = new List<CarDataSelectView>();
  140. foreach (CarDataSelectView car in carData)
  141. {
  142. if (!string.IsNullOrWhiteSpace(car.UnitArea))
  143. {
  144. data.Add(car);
  145. }
  146. }
  147. return Ok(JsonView(true, "查询成功", data));
  148. }
  149. /// <summary>
  150. /// 根据Id查询车公司详细数据
  151. /// </summary>
  152. /// <returns></returns>
  153. [HttpPost]
  154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  155. public async Task<IActionResult> QuerCarDataDetailById(QueryCarDataDetailDto dto)
  156. {
  157. string sql = string.Format(@" Select * From Res_CarData With(Nolock) Where Id = {0} ", dto.Id);
  158. var info = _resItemInfoRep._sqlSugar.SqlQueryable<CarDataDetailDataView>(sql).First();
  159. if (info == null)
  160. {
  161. return Ok(JsonView(false, "未找到相关数据!"));
  162. }
  163. EncryptionProcessor.DecryptProperties(info);
  164. return Ok(JsonView(true, "查询成功", info));
  165. }
  166. /// <summary>
  167. /// 车公司信息添加
  168. /// </summary>
  169. /// <returns></returns>
  170. [HttpPost]
  171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  172. public async Task<IActionResult> AddCarData(AddCarDataDto dto)
  173. {
  174. if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
  175. if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
  176. if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  177. if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  178. var carDadaInfo = _carDataRep
  179. .QueryDto<Res_CarData, CarDataView>(a => a.UnitArea == dto.UnitArea &&
  180. a.UnitName == dto.UnitName &&
  181. a.Contact == dto.Contact &&
  182. a.ContactTel == dto.ContactTel
  183. )
  184. .First();
  185. if (carDadaInfo != null) return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
  186. var carData = _mapper.Map<Res_CarData>(dto);
  187. EncryptionProcessor.EncryptProperties(carData);
  188. int id = await _carDataRep.AddAsyncReturnId(carData);
  189. if (id < 1) return Ok(JsonView(false, "添加失败!"));
  190. return Ok(JsonView(true, "添加成功", new { Id = id }));
  191. }
  192. /// <summary>
  193. /// 车公司信息修改
  194. /// </summary>
  195. /// <returns></returns>
  196. [HttpPost]
  197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  198. public async Task<IActionResult> UpCarData(UpCarDataDto dto)
  199. {
  200. if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
  201. if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
  202. if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  203. if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  204. var carData = _mapper.Map<Res_CarData>(dto);
  205. EncryptionProcessor.EncryptProperties(carData);
  206. var res = await _sqlSugar.Updateable(carData)
  207. .IgnoreColumns(x => new { x.CreateUserId, x.CreateTime, x.DeleteTime, x.DeleteUserId, x.IsDel })
  208. .ExecuteCommandAsync();
  209. if (res < 1) { return Ok(JsonView(false, "修改失败!")); }
  210. return Ok(JsonView(true, "修改成功"));
  211. }
  212. /// <summary>
  213. /// 车公司信息删除
  214. /// </summary>
  215. /// <returns></returns>
  216. [HttpPost]
  217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  218. public async Task<IActionResult> DelCarData(DelCarDataDto dto)
  219. {
  220. bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
  221. if (!res) { return Ok(JsonView(false, "删除失败!")); }
  222. return Ok(JsonView(true, "删除成功"));
  223. }
  224. #endregion
  225. #region 导游地接资料板块
  226. [HttpPost]
  227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  228. public async Task<IActionResult> LocalGuideBatchEncryption()
  229. {
  230. var infos = await _sqlSugar.Queryable<Res_LocalGuideData>().ToListAsync();
  231. foreach (var item in infos) EncryptionProcessor.EncryptProperties(item);
  232. var updTotal = await _sqlSugar.Updateable(infos).ExecuteCommandAsync();
  233. return Ok(JsonView(true));
  234. }
  235. /// <summary>
  236. /// 导游地接资料查询
  237. /// </summary>
  238. /// <param name="dto"></param>
  239. /// <returns></returns>
  240. [HttpPost]
  241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  242. public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
  243. {
  244. Stopwatch stopwatch = Stopwatch.StartNew();
  245. Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
  246. if (LocalGuide.Code == 0)
  247. {
  248. stopwatch.Stop();
  249. return Ok(JsonView(true, $"查询成功!耗时:{stopwatch.ElapsedMilliseconds} 毫秒", LocalGuide.Data));
  250. }
  251. stopwatch.Stop();
  252. return Ok(JsonView(false, LocalGuide.Msg + $" 耗时:{stopwatch.ElapsedMilliseconds} 毫秒"));
  253. }
  254. /// <summary>
  255. /// 导游地接资料下拉框数据
  256. /// </summary>
  257. /// <returns></returns>
  258. [HttpPost]
  259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  260. public async Task<IActionResult> QueryLocalGuideSelect()
  261. {
  262. var localGuides = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
  263. if (localGuides.Count == 0)
  264. {
  265. return Ok(JsonView(false, "暂无数据!"));
  266. }
  267. foreach (var item in localGuides) EncryptionProcessor.DecryptProperties(item);
  268. localGuides.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
  269. localGuides = localGuides.Where((x, i) => localGuides.FindIndex(z => z.UnitArea == x.UnitArea && !string.IsNullOrEmpty(z.UnitArea)) == i).ToList();
  270. localGuides = localGuides.OrderBy(x => x.Id).ToList();
  271. var data = new List<QueryLocalGuideSelectView>();
  272. foreach (QueryLocalGuideSelectView Local in localGuides)
  273. {
  274. if (!string.IsNullOrWhiteSpace(Local.UnitArea))
  275. {
  276. data.Add(Local);
  277. }
  278. }
  279. return Ok(JsonView(true, "查询成功", data));
  280. }
  281. /// <summary>
  282. /// 根据Id查询地接详细数据
  283. /// </summary>
  284. /// <returns></returns>
  285. [HttpPost]
  286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  287. public async Task<IActionResult> QueryLocalGuideDetailById(QueryLocalGuideDetailDto dto)
  288. {
  289. string sql = string.Format(@" Select * From Res_LocalGuideData With(Nolock) Where Id = {0} ", dto.Id);
  290. var info = _resItemInfoRep._sqlSugar.SqlQueryable<LocalGuideDetailDataView>(sql).First();
  291. if (info == null)
  292. {
  293. return Ok(JsonView(false, "未找到相关数据!"));
  294. }
  295. EncryptionProcessor.DecryptProperties(info);
  296. return Ok(JsonView(true, "查询成功", info));
  297. }
  298. /// <summary>
  299. /// 导游地接信息操作(Status:1.新增,2.修改)
  300. /// </summary>
  301. /// <returns></returns>
  302. [HttpPost]
  303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  304. public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
  305. {
  306. if (string.IsNullOrEmpty(dto.UnitArea)) return Ok(JsonView(false, "请检查单位区域是否填写!"));
  307. if (string.IsNullOrEmpty(dto.UnitName)) return Ok(JsonView(false, "请检查单位名称是否填写!"));
  308. if (string.IsNullOrEmpty(dto.Contact)) return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  309. if (string.IsNullOrEmpty(dto.ContactTel)) return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  310. Result result = await _localGuideDataRep.LocalGuideOperation(dto);
  311. if (result.Code != 0)
  312. {
  313. return Ok(JsonView(false, result.Msg));
  314. }
  315. return Ok(JsonView(true, result.Msg));
  316. }
  317. /// <summary>
  318. /// 导游地接信息操作(删除)
  319. /// </summary>
  320. /// <returns></returns>
  321. [HttpPost]
  322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  323. public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
  324. {
  325. var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
  326. if (!res)
  327. {
  328. return Ok(JsonView(false, "删除失败"));
  329. }
  330. return Ok(JsonView(true, "删除成功!"));
  331. }
  332. #endregion
  333. #region 机场三字码信息
  334. /// <summary>
  335. /// 机场三字码查询
  336. /// </summary>
  337. /// <param name="dto"></param>
  338. /// <returns></returns>
  339. [HttpPost]
  340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  341. public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
  342. {
  343. try
  344. {
  345. Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
  346. if (LocalGuide.Code == 0)
  347. {
  348. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  349. }
  350. else
  351. {
  352. return Ok(JsonView(false, LocalGuide.Msg));
  353. }
  354. }
  355. catch (Exception ex)
  356. {
  357. return Ok(JsonView(false, "程序错误!"));
  358. throw;
  359. }
  360. }
  361. /// <summary>
  362. /// 机场三字码数据城市下拉框数据
  363. /// </summary>
  364. /// <returns></returns>
  365. [HttpPost]
  366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  367. public async Task<IActionResult> QueryThreeCodeSelect()
  368. {
  369. try
  370. {
  371. var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
  372. if (ThreeCode.Count == 0)
  373. {
  374. return Ok(JsonView(false, "暂无数据!"));
  375. }
  376. ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
  377. ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  378. ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
  379. List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
  380. foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
  381. {
  382. if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
  383. {
  384. data.Add(_ThreeCode);
  385. }
  386. }
  387. return Ok(JsonView(true, "查询成功", data));
  388. }
  389. catch (Exception)
  390. {
  391. return Ok(JsonView(false, "程序错误!"));
  392. throw;
  393. }
  394. }
  395. /// <summary>
  396. /// 机场三字码资料操作(Status:1.新增,2.修改)
  397. /// </summary>
  398. /// <param name="dto"></param>
  399. /// <returns></returns>
  400. [HttpPost]
  401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  402. public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
  403. {
  404. try
  405. {
  406. if (dto.Three == "")
  407. {
  408. return Ok(JsonView(false, "请检查三字码是否填写!"));
  409. }
  410. if (dto.Country == "")
  411. {
  412. return Ok(JsonView(false, "请检查国家是否填写!"));
  413. }
  414. if (dto.City == "")
  415. {
  416. return Ok(JsonView(false, "请检查城市是否填写正确!"));
  417. }
  418. if (dto.AirPort == "")
  419. {
  420. return Ok(JsonView(false, "请检查机场是否填写正确!"));
  421. }
  422. Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
  423. if (result.Code != 0)
  424. {
  425. return Ok(JsonView(false, result.Msg));
  426. }
  427. return Ok(JsonView(true, result.Msg));
  428. }
  429. catch (Exception ex)
  430. {
  431. return Ok(JsonView(false, "程序错误!"));
  432. throw;
  433. }
  434. }
  435. /// <summary>
  436. /// 机场三字码资料操作(删除)
  437. /// </summary>
  438. /// <returns></returns>
  439. [HttpPost]
  440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  441. public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
  442. {
  443. try
  444. {
  445. var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
  446. if (!res)
  447. {
  448. return Ok(JsonView(false, "删除失败"));
  449. }
  450. return Ok(JsonView(true, "删除成功!"));
  451. }
  452. catch (Exception ex)
  453. {
  454. return Ok(JsonView(false, "程序错误!"));
  455. throw;
  456. }
  457. }
  458. /// <summary>
  459. ///根据ID查询三字码信息
  460. /// </summary>
  461. /// <returns></returns>
  462. [HttpPost]
  463. public IActionResult QuerySingleThreeCode(QuerySingleThreeCode dto)
  464. {
  465. var jw = JsonView(false);
  466. var single = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Id == dto.ID && x.IsDel == 0);
  467. if (single != null)
  468. {
  469. jw = JsonView(true, "获取成功!", new
  470. {
  471. single.Three,
  472. Four = single.Four?.Trim(),
  473. single.AirPort,
  474. single.AirPort_En,
  475. single.City,
  476. single.Country,
  477. single.Remark
  478. });
  479. }
  480. else
  481. {
  482. jw.Msg = "暂无!";
  483. }
  484. return Ok(jw);
  485. }
  486. #endregion
  487. #region 代理出票合作方资料
  488. /// <summary>
  489. /// 代理出票合作方资料
  490. /// </summary>
  491. /// <param name="dto"></param>
  492. /// <returns></returns>
  493. [HttpPost]
  494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  495. public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
  496. {
  497. var res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
  498. if (res_AirTicketAgents.Count > 1)
  499. {
  500. res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
  501. if (dto.PageSize == 0 && dto.PageIndex == 0)
  502. {
  503. foreach (var item in res_AirTicketAgents) EncryptionProcessor.DecryptProperties(item);
  504. return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
  505. }
  506. else
  507. {
  508. int count = res_AirTicketAgents.Count;
  509. float totalPage = (float)count / dto.PageSize;//总页数
  510. if (totalPage == 0) totalPage = 1;
  511. else totalPage = (int)Math.Ceiling((double)totalPage);
  512. var _AirTicketAgent = new List<Res_AirTicketAgent>();
  513. for (int i = 0; i < dto.PageSize; i++)
  514. {
  515. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  516. if (RowIndex < res_AirTicketAgents.Count)
  517. {
  518. EncryptionProcessor.DecryptProperties(res_AirTicketAgents[RowIndex]);
  519. _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
  520. }
  521. else break;
  522. }
  523. return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
  524. }
  525. }
  526. return Ok(JsonView(false, "暂无数据!"));
  527. }
  528. /// <summary>
  529. /// 代理出票合作方资料操作(Status:1.新增,2.修改)
  530. /// </summary>
  531. /// <param name="dto"></param>
  532. /// <returns></returns>
  533. [HttpPost]
  534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  535. public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
  536. {
  537. if (string.IsNullOrEmpty(dto.Account)) return Ok(JsonView(false, "请检查代理商账户是否填写!"));
  538. if (string.IsNullOrEmpty(dto.Bank)) return Ok(JsonView(false, "请检查代理商银行是否填写!"));
  539. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
  540. Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
  541. if (result.Code != 0) return Ok(JsonView(false, result.Msg));
  542. return Ok(JsonView(true, result.Msg));
  543. }
  544. /// <summary>
  545. /// 代理出票合作方资料操作(删除)
  546. /// </summary>
  547. /// <returns></returns>
  548. [HttpPost]
  549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  550. public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
  551. {
  552. var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
  553. if (!res) return Ok(JsonView(false, "删除失败"));
  554. return Ok(JsonView(true, "删除成功!"));
  555. }
  556. #endregion
  557. #region 酒店资料数据
  558. /// <summary>
  559. /// 酒店信息查询 Page
  560. /// </summary>
  561. /// <param name="dto"></param>
  562. /// <returns></returns>
  563. [HttpPost]
  564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  565. public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
  566. {
  567. string sqlWhere = string.Empty;
  568. if (!string.IsNullOrWhiteSpace(dto.Name))
  569. {
  570. sqlWhere += string.Format(@" And hd.Name like '%{0}%'", AesEncryptionHelper.Encrypt(dto.Name));
  571. }
  572. if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
  573. {
  574. sqlWhere += string.Format(@" And hd.City like '%{0}%'", AesEncryptionHelper.Encrypt(dto.City));
  575. }
  576. if (!string.IsNullOrWhiteSpace(dto.Contact))
  577. {
  578. sqlWhere += string.Format(@" And hd.Contact like '%{0}%'", AesEncryptionHelper.Encrypt(dto.Contact));
  579. }
  580. if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
  581. {
  582. sqlWhere += string.Format(@" And hd.ContactPhone like '%{0}%'", AesEncryptionHelper.Encrypt(dto.ContactPhone));
  583. }
  584. sqlWhere += string.Format(@" And hd.IsDel={0}", 0);
  585. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  586. {
  587. Regex r = new Regex("And");
  588. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  589. }
  590. string sql = string.Format(@"SELECT
  591. *
  592. FROM
  593. (
  594. SELECT
  595. ROW_NUMBER() OVER (
  596. ORDER BY
  597. hd.CreateTime DESC
  598. ) AS Row_Number,
  599. hd.Id,
  600. hd.City,
  601. hd.[Name],
  602. hd.Tel,
  603. hd.Fax,
  604. hd.Contact,
  605. hd.ContactPhone,
  606. u.CnName AS CreateUserName,
  607. hd.CreateTime
  608. FROM
  609. Res_HotelData hd
  610. WITH
  611. (NoLock)
  612. LEFT JOIN Sys_Users u
  613. WITH
  614. (NoLock) ON hd.CreateUserId = u.Id {0}
  615. ) Temp
  616. ", sqlWhere);
  617. if (dto.PortType == 1)
  618. {
  619. var HotelDataData = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToListAsync();
  620. if (HotelDataData.Count == 0)
  621. {
  622. return Ok(JsonView(false, "暂无数据"));
  623. }
  624. foreach (var item in HotelDataData)
  625. {
  626. EncryptionProcessor.DecryptProperties(item);
  627. }
  628. return Ok(JsonView(true, "操作成功", HotelDataData));
  629. }
  630. else if (dto.PortType == 2 || dto.PortType == 3)
  631. {
  632. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  633. var data = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
  634. foreach (var item in data) EncryptionProcessor.DecryptProperties(item);
  635. return Ok(JsonView(true, "操作成功", data, total));
  636. }
  637. else return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  638. }
  639. /// <summary>
  640. /// 酒店资料
  641. /// 详情
  642. /// add time:2024-05-14 11:57:10
  643. /// </summary>
  644. /// <returns></returns>
  645. [HttpPost]
  646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  647. public async Task<IActionResult> QueryHotelDataInfo(QueryHotelDataInfoDto dto)
  648. {
  649. var _view = await _hotelDataRep._Info(dto.PortType, dto.Id);
  650. if (_view.Code == 0)
  651. {
  652. return Ok(JsonView(true, _view.Msg, _view.Data));
  653. }
  654. return Ok(JsonView(false, _view.Msg));
  655. }
  656. /// <summary>
  657. /// 酒店资料下拉框数据
  658. /// </summary>
  659. /// <returns></returns>
  660. [HttpPost]
  661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  662. public async Task<IActionResult> QueryHotelDataSelect()
  663. {
  664. try
  665. {
  666. var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
  667. if (HotelData.Count == 0)
  668. {
  669. return Ok(JsonView(false, "暂无数据!"));
  670. }
  671. //解密
  672. foreach (var item in HotelData)
  673. {
  674. EncryptionProcessor.DecryptProperties(item);
  675. }
  676. HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
  677. HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  678. HotelData = HotelData.OrderBy(x => x.Id).ToList();
  679. var data = new List<QueryHotelDataSelect>();
  680. foreach (var Hotel in HotelData)
  681. {
  682. if (!string.IsNullOrWhiteSpace(Hotel.City))
  683. {
  684. data.Add(Hotel);
  685. }
  686. }
  687. return Ok(JsonView(true, "查询成功", data));
  688. }
  689. catch (Exception)
  690. {
  691. return Ok(JsonView(false, "程序错误!"));
  692. throw;
  693. }
  694. }
  695. /// <summary>
  696. /// 酒店资料操作(Status:1.新增,2.修改)
  697. /// </summary>
  698. /// <param name="dto"></param>
  699. /// <returns></returns>
  700. [HttpPost]
  701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  702. public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
  703. {
  704. if (string.IsNullOrEmpty(dto.City)) return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
  705. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查酒店名称是否填写!"));
  706. if (string.IsNullOrEmpty(dto.Address)) return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
  707. if (string.IsNullOrEmpty(dto.Tel)) return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
  708. Result result = await _hotelDataRep.OperationHotelData(dto);
  709. if (result.Code != 0) return Ok(JsonView(false, result.Msg));
  710. return Ok(JsonView(true, result.Msg));
  711. }
  712. /// <summary>
  713. /// 酒店资料操作(删除)
  714. /// </summary>
  715. /// <returns></returns>
  716. [HttpPost]
  717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  718. public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
  719. {
  720. try
  721. {
  722. var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
  723. if (!res)
  724. {
  725. return Ok(JsonView(false, "删除失败"));
  726. }
  727. return Ok(JsonView(true, "删除成功!"));
  728. }
  729. catch (Exception ex)
  730. {
  731. return Ok(JsonView(false, "程序错误!"));
  732. throw;
  733. }
  734. }
  735. #endregion
  736. #region 签证费用资料
  737. /// <summary>
  738. /// 签证费用资料查询
  739. /// </summary>
  740. /// <param name="dto"></param>
  741. /// <returns></returns>
  742. [HttpPost]
  743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  744. public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
  745. {
  746. if (dto.PortType == 1)
  747. {
  748. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  749. if (CountryFee.Count == 0)
  750. {
  751. return Ok(JsonView(false, "暂无数据!"));
  752. }
  753. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  754. return Ok(JsonView(true, "查询成功", CountryFee));
  755. }
  756. else if (dto.PortType == 2)
  757. {
  758. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  759. if (CountryFee.Count == 0)
  760. {
  761. return Ok(JsonView(false, "暂无数据!"));
  762. }
  763. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  764. return Ok(JsonView(true, "查询成功", CountryFee));
  765. }
  766. else
  767. {
  768. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  769. }
  770. }
  771. /// <summary>
  772. /// 签证费用资料操作(Status:1.新增,2.修改)
  773. /// </summary>
  774. /// <param name="dto"></param>
  775. /// <returns></returns>
  776. [HttpPost]
  777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  778. public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
  779. {
  780. if (string.IsNullOrWhiteSpace(dto.VisaContinent))
  781. {
  782. return Ok(JsonView(false, "请检查州名是否填写!"));
  783. }
  784. if (string.IsNullOrWhiteSpace(dto.VisaCountry))
  785. {
  786. return Ok(JsonView(false, "请检查国家名是否填写!"));
  787. }
  788. if (string.IsNullOrWhiteSpace(dto.VisaTime))
  789. {
  790. return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
  791. }
  792. if (string.IsNullOrWhiteSpace(dto.UrgentTime))
  793. {
  794. return Ok(JsonView(false, "请检加急时间是否填写正确!"));
  795. }
  796. Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
  797. if (result.Code == 0)
  798. {
  799. return Ok(JsonView(true, result.Msg));
  800. }
  801. return Ok(JsonView(false, result.Msg));
  802. }
  803. /// <summary>
  804. /// 签证费用资料操作(删除)
  805. /// </summary>
  806. /// <returns></returns>
  807. [HttpPost]
  808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  809. public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
  810. {
  811. var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
  812. if (!res)
  813. {
  814. return Ok(JsonView(false, "删除失败"));
  815. }
  816. return Ok(JsonView(true, "删除成功!"));
  817. }
  818. #endregion
  819. #region 物料信息、供应商维护
  820. #region 供应商
  821. /// <summary>
  822. /// 物料供应商查询
  823. /// </summary>
  824. /// <param name="paras">Json序列化</param>
  825. /// <returns></returns>
  826. [HttpPost]
  827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  828. public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
  829. {
  830. if (string.IsNullOrEmpty(_jsonDto.Paras))
  831. {
  832. return Ok(JsonView(false, "参数为空"));
  833. }
  834. Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
  835. if (_ItemVendorDto != null)
  836. {
  837. if (_ItemVendorDto.SearchType == 2) //获取列表
  838. {
  839. Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
  840. return Ok(rstList);
  841. }
  842. else
  843. {
  844. Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
  845. return Ok(rstInfo);
  846. }
  847. }
  848. else
  849. {
  850. return Ok(JsonView(false, "参数反序列化失败"));
  851. }
  852. return Ok(JsonView(false));
  853. }
  854. /// <summary>
  855. /// 创建/编辑/删除供应商信息
  856. /// </summary>
  857. /// <param name="_dto"></param>
  858. /// <returns></returns>
  859. [HttpPost]
  860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  861. public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
  862. {
  863. bool rst = false;
  864. if (_dto.EditType >= 0)
  865. {
  866. if (string.IsNullOrEmpty(_dto.VendorFullName))
  867. {
  868. return Ok(JsonView(false, "全称未填写"));
  869. }
  870. if (string.IsNullOrEmpty(_dto.VendorLinker))
  871. {
  872. return Ok(JsonView(false, "联系人未填写"));
  873. }
  874. if (string.IsNullOrEmpty(_dto.VendorMobile))
  875. {
  876. return Ok(JsonView(false, "联系人手机号未填写"));
  877. }
  878. if (string.IsNullOrEmpty(_dto.BusRange))
  879. {
  880. return Ok(JsonView(false, "经营范围未选择"));
  881. }
  882. if (_dto.EditType == 0)
  883. {
  884. var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
  885. if (checkEmpty != null)
  886. {
  887. return Ok(JsonView(false, "已存在同名供应商"));
  888. }
  889. rst = await _resItemInfoRep.addVendorInfo(_dto);
  890. }
  891. else if (_dto.EditType == 1)
  892. {
  893. if (_dto.VendorId > 0)
  894. {
  895. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  896. rst = await _resItemInfoRep.updVendorInfo(_entity);
  897. }
  898. else
  899. {
  900. return Ok(JsonView(false, "供应商不存在"));
  901. }
  902. }
  903. }
  904. else
  905. {
  906. if (_dto.VendorId < 1 || _dto.SysUserId < 1)
  907. {
  908. return Ok(JsonView(false, "用户Id或供应商Id不存在"));
  909. }
  910. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  911. rst = await _resItemInfoRep.delVendorInfo(_entity);
  912. }
  913. return Ok(JsonView(rst));
  914. }
  915. #endregion
  916. #region 物料信息
  917. /// <summary>
  918. /// 物料信息查询
  919. /// </summary>
  920. /// <param name="paras">Json序列化</param>
  921. /// <returns></returns>
  922. [HttpPost]
  923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  924. public async Task<IActionResult> PostSearchItemInfo(string paras)
  925. {
  926. if (string.IsNullOrEmpty(paras))
  927. {
  928. return Ok(JsonView(false, "参数为空"));
  929. }
  930. Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
  931. if (_ItemInfoDto != null)
  932. {
  933. if (_ItemInfoDto.SearchType == 2) //获取列表
  934. {
  935. Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
  936. return Ok(rstList);
  937. }
  938. else
  939. {
  940. Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
  941. return Ok(rstInfo);
  942. }
  943. }
  944. else
  945. {
  946. return Ok(JsonView(false, "参数反序列化失败"));
  947. }
  948. return Ok(JsonView(false));
  949. }
  950. /// <summary>
  951. /// 创建/编辑/删除物料信息
  952. /// </summary>
  953. ///
  954. /// <returns></returns>
  955. [HttpPost]
  956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  957. public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
  958. {
  959. bool rst = false;
  960. if (_dto.EditType >= 0)
  961. {
  962. if (_dto.VendorId < 1)
  963. {
  964. return Ok(JsonView(false, "未选择供应商"));
  965. }
  966. if (string.IsNullOrEmpty(_dto.ItemName))
  967. {
  968. return Ok(JsonView(false, "物料名称为空"));
  969. }
  970. if (_dto.ItemTypeId < 1)
  971. {
  972. return Ok(JsonView(false, "未选择物料类型"));
  973. }
  974. if (_dto.SysUserId < 1)
  975. {
  976. return Ok(JsonView(false, "当前操作用户Id为空"));
  977. }
  978. if (_dto.CurrRate <= 0)
  979. {
  980. return Ok(JsonView(false, "物料录入价格不能小于等于0"));
  981. }
  982. if (_dto.EditType == 0)
  983. {
  984. //判断物料名称、类型、供应商全部重复
  985. var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
  986. if (checkEmpty != null)
  987. {
  988. return Ok(JsonView(false, "已存在重复物料信息"));
  989. }
  990. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  991. DateTime dtNow = DateTime.Now;
  992. _entity.CreateUserId = _dto.SysUserId;
  993. _entity.IsDel = 0;
  994. _entity.MaxRate = _dto.CurrRate;
  995. _entity.MaxDt = dtNow;
  996. _entity.CurrRate = _dto.CurrRate;
  997. _entity.CurrDt = dtNow;
  998. _entity.MinRate = _dto.CurrRate;
  999. _entity.MinDt = dtNow;
  1000. rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
  1001. }
  1002. else if (_dto.EditType == 1)
  1003. {
  1004. if (_dto.ItemId > 0)
  1005. {
  1006. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1007. _entity.Id = _dto.ItemId;
  1008. rst = await _resItemInfoRep.updItemInfo(_entity);
  1009. }
  1010. else
  1011. {
  1012. return Ok(JsonView(false, "供应商不存在"));
  1013. }
  1014. }
  1015. }
  1016. else
  1017. {
  1018. if (_dto.ItemId < 1 || _dto.SysUserId < 1)
  1019. {
  1020. return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
  1021. }
  1022. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1023. rst = await _resItemInfoRep.delItemInfo(_entity);
  1024. }
  1025. return Ok(JsonView(rst));
  1026. }
  1027. #endregion
  1028. #region 物料类型获取
  1029. #endregion
  1030. #endregion
  1031. #region 备忘录
  1032. /// <summary>
  1033. /// 备忘录查询
  1034. /// </summary>
  1035. /// <param name="paras">Json序列化</param>
  1036. /// <returns></returns>
  1037. [HttpPost]
  1038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1039. public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
  1040. {
  1041. if (string.IsNullOrEmpty(_jsonDto.Paras))
  1042. {
  1043. return Ok(JsonView(false, "参数为空"));
  1044. }
  1045. Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
  1046. if (_memoDto != null)
  1047. {
  1048. if (_memoDto.SearchType == 2)
  1049. {
  1050. //获取列表
  1051. string sqlWhere = string.Format(" Where IsDel=0 ");
  1052. #region SqlWhere
  1053. if (!string.IsNullOrEmpty(_memoDto.Abstracts))
  1054. {
  1055. sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
  1056. }
  1057. if (!string.IsNullOrEmpty(_memoDto.Title))
  1058. {
  1059. sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
  1060. }
  1061. if (_memoDto.ReadLevel > 0)
  1062. {
  1063. sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
  1064. }
  1065. #endregion
  1066. int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
  1067. int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
  1068. string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
  1069. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1070. m.LastedEditDt,m.LastedEditorId
  1071. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1072. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
  1073. ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
  1074. Res_MemoListView rst = new Res_MemoListView();
  1075. rst.CurrPageIndex = currPIndex;
  1076. rst.CurrPageSize = currPSize;
  1077. List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
  1078. Dictionary<int, string> userDic = new Dictionary<int, string>();
  1079. foreach (var item in dataSource)
  1080. {
  1081. if (userDic.ContainsKey(item.LastedEditorId))
  1082. {
  1083. item.LastedEditor = userDic[item.LastedEditorId];
  1084. }
  1085. else
  1086. {
  1087. var _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
  1088. userDic[item.LastedEditorId] = _sysUser.CnName;
  1089. item.LastedEditor = _sysUser.CnName;
  1090. }
  1091. }
  1092. rst.DataList = new List<Res_MemoView>(dataSource);
  1093. if (rst.DataList.Count > 0)
  1094. {
  1095. string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
  1096. int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
  1097. rst.DataCount = dataCount;
  1098. }
  1099. return Ok(JsonView(rst));
  1100. }
  1101. else
  1102. {
  1103. //获取对象
  1104. string sqlSingle = string.Format(@" Select
  1105. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1106. m.LastedEditDt,m.LastedEditor,m.MDFilePath
  1107. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1108. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
  1109. Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
  1110. if (_result != null)
  1111. {
  1112. var _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
  1113. _result.LastedEditor = _sysUser.CnName;
  1114. _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
  1115. return Ok(JsonView(_result));
  1116. }
  1117. }
  1118. }
  1119. else
  1120. {
  1121. return Ok(JsonView(false, "参数反序列化失败"));
  1122. }
  1123. return Ok(JsonView(false));
  1124. }
  1125. /// <summary>
  1126. /// 创建/编辑/删除备忘录信息
  1127. /// </summary>
  1128. /// <param name="_dto"></param>
  1129. /// <returns></returns>
  1130. [HttpPost]
  1131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1132. public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
  1133. {
  1134. bool rst = false;
  1135. if (_dto.SysUserId < 1)
  1136. {
  1137. return Ok(JsonView(false, "操作人失效"));
  1138. }
  1139. var _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
  1140. if (_sysUser == null)
  1141. {
  1142. return Ok(JsonView(false, "操作人失效02"));
  1143. }
  1144. if (_dto.EditType >= 0)
  1145. {
  1146. if (_dto.ReadLevel < 1)
  1147. {
  1148. return Ok(JsonView(false, "未知的阅读等级"));
  1149. }
  1150. if (string.IsNullOrEmpty(_dto.Title.Trim()))
  1151. {
  1152. return Ok(JsonView(false, "标题不能为空"));
  1153. }
  1154. if (string.IsNullOrEmpty(_dto.Content.Trim()))
  1155. {
  1156. return Ok(JsonView(false, "正文内容不能为空"));
  1157. }
  1158. //新增备忘录
  1159. DateTime dtNow = DateTime.Now;
  1160. string dir = AppSettingsHelper.Get("MemoCurrPath");
  1161. string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
  1162. string content = JsonConvert.SerializeObject(_dto.Content);
  1163. if (_dto.EditType == 0)//新增
  1164. {
  1165. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1166. if (savePath.Length > 0)
  1167. {
  1168. Res_MemoInfo _insert = new Res_MemoInfo();
  1169. _insert.Abstracts = _dto.Abstracts;
  1170. _insert.Title = _dto.Title;
  1171. _insert.DepartmentId = _sysUser.DepId;
  1172. _insert.CreateUserId = _sysUser.Id;
  1173. _insert.LastedEditDt = dtNow;
  1174. _insert.LastedEditor = _sysUser.Id;
  1175. _insert.MDFilePath = savePath;
  1176. _insert.ReadLevel = _dto.ReadLevel;
  1177. _insert.Title = _dto.Title;
  1178. int result = await _resItemInfoRep.AddAsync(_insert);
  1179. return Ok(JsonView(result > 0));
  1180. }
  1181. else
  1182. {
  1183. return Ok(JsonView(false, "路径保存失败"));
  1184. }
  1185. }
  1186. else//修改
  1187. {
  1188. if (_dto.MemoId < 1)
  1189. {
  1190. return Ok(JsonView(false, "MemoId不存在"));
  1191. }
  1192. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1193. if (_source == null)
  1194. {
  1195. return Ok(JsonView(false, "MemoInfo不存在"));
  1196. }
  1197. //修改
  1198. string sourcePath = _source.MDFilePath;
  1199. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1200. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1201. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1202. if (savePath.Length > 0)
  1203. {
  1204. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1205. .SetColumns(it => it.LastedEditDt == DateTime.Now)
  1206. .SetColumns(it => it.LastedEditor == _sysUser.Id)
  1207. .SetColumns(it => it.Abstracts == _dto.Abstracts)
  1208. .SetColumns(it => it.MDFilePath == savePath)
  1209. .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
  1210. .SetColumns(it => it.Title == _dto.Title)
  1211. .Where(s => s.Id == _source.Id)
  1212. .ExecuteCommandAsync();
  1213. return Ok(JsonView(result > 0));
  1214. }
  1215. }
  1216. }
  1217. else
  1218. {
  1219. //删除
  1220. if (_dto.MemoId < 1)
  1221. {
  1222. return Ok(JsonView(false, "MemoId不存在"));
  1223. }
  1224. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1225. if (_source == null)
  1226. {
  1227. return Ok(JsonView(false, "MemoInfo不存在"));
  1228. }
  1229. //修改
  1230. string sourcePath = _source.MDFilePath;
  1231. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1232. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1233. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1234. .SetColumns(it => it.IsDel == 1)
  1235. .SetColumns(it => it.DeleteUserId == _sysUser.Id)
  1236. .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  1237. .Where(s => s.Id == _source.Id)
  1238. .ExecuteCommandAsync();
  1239. return Ok(JsonView(result > 0));
  1240. }
  1241. return Ok(JsonView(rst));
  1242. }
  1243. #endregion
  1244. #region 商邀资料
  1245. /// <summary>
  1246. /// 商邀资料 基础数据源
  1247. /// </summary>
  1248. /// <param name="dto"></param>
  1249. /// <returns></returns>
  1250. [HttpPost]
  1251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1252. public async Task<IActionResult> QueryIOAInitData(QueryIOAInitDataDto dto)
  1253. {
  1254. #region 参数验证
  1255. if (dto.PortType < 1) return Ok(JsonView(false, "请传入有效的PortType参数!"));
  1256. #endregion
  1257. var ExcludedKeyStr = new string[] { "快递费" };
  1258. var ClientKeyStr = new string[] { "邀请函翻译" };
  1259. List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.JietuanTime).ToList();
  1260. List<Res_InvitationOfficialActivityData> _ioaDatas = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1261. .Where(it => it.IsDel == 0)
  1262. .Select(x => new Res_InvitationOfficialActivityData
  1263. {
  1264. Country = x.Country,
  1265. UnitName = x.UnitName,
  1266. Contact = x.Contact,
  1267. Field = x.Field,
  1268. })
  1269. .ToList();
  1270. foreach (var item in _ioaDatas)
  1271. {
  1272. EncryptionProcessor.DecryptProperties(item);
  1273. }
  1274. foreach (var item in ExcludedKeyStr)
  1275. {
  1276. _ioaDatas = _ioaDatas.Where(x => string.IsNullOrWhiteSpace(x.UnitName) || !x.UnitName.Contains(item)).ToList();
  1277. }
  1278. foreach (var item in ClientKeyStr)
  1279. {
  1280. _ioaDatas = _ioaDatas.Where(x => string.IsNullOrWhiteSpace(x.Contact) || !x.Contact.Contains(item)).ToList();
  1281. }
  1282. List<Sys_Users> _Users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
  1283. var _countryData = _ioaDatas.Select(it => it.Country).Distinct().ToList(); _countryData.Remove("");
  1284. var _inviterData = _ioaDatas.Select(it => it.UnitName).Distinct().ToList(); _inviterData.Remove("");
  1285. var _contactData = _ioaDatas.Select(it => it.Contact).Distinct().ToList(); _contactData.Remove("");
  1286. var _domainData = _ioaDatas.Select(it => it.Field).Distinct().ToList(); _domainData.Remove("");
  1287. var _groupNameData = _DelegationInfos.Select(it => new { it.Id, it.TeamName }).ToList();
  1288. var _userNameData = _Users.Select(it => new { it.Id, it.CnName }).ToList();
  1289. var _data = new
  1290. {
  1291. CountryData = _countryData,
  1292. InviterData = _inviterData,
  1293. DomainData = _domainData,
  1294. ContactData = _contactData,
  1295. GroupNameData = _groupNameData,
  1296. UserNameData = _userNameData,
  1297. };
  1298. return Ok(JsonView(true, $"查询成功!", _data));
  1299. }
  1300. /// <summary>
  1301. /// 商邀资料查询
  1302. /// </summary>
  1303. /// <param name="dto"></param>
  1304. /// <returns></returns>
  1305. [HttpPost]
  1306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1307. public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
  1308. {
  1309. var ExcludedKeyStr = new string[] { "快递费" };
  1310. var ClientKeyStr = new string[] { "邀请函翻译" };
  1311. var columns = "Id,UnitName,Contact";
  1312. try
  1313. {
  1314. #region 参数验证
  1315. if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
  1316. if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
  1317. #endregion
  1318. //string sqlWhere = string.Empty;
  1319. if (!string.IsNullOrWhiteSpace(dto.Country)) { columns += ",Country"; }
  1320. //if (!string.IsNullOrWhiteSpace(dto.UnitName)) { columns += ",UnitName"; }
  1321. //if (!string.IsNullOrWhiteSpace(dto.Contact)) { columns += ",Contact"; }
  1322. if (!string.IsNullOrWhiteSpace(dto.Delegation)) { columns += ",Delegation"; }
  1323. if (!string.IsNullOrWhiteSpace(dto.Field)) { columns += ",Field"; }
  1324. //if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { columns += ",CreateUserId"; }
  1325. //if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
  1326. //{
  1327. // columns += ",CreateUserId";
  1328. //}
  1329. DateTime endTime = new DateTime();
  1330. var InvitationOfficialActivityDataList = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1331. .Where(x => x.IsDel == 0)
  1332. .WhereIF(dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString()), x => x.CreateUserId == dto.CreateUserId)
  1333. .WhereIF(DateTime.TryParse(dto.StartCreateTime , out DateTime startTime) && DateTime.TryParse(dto.EndCreateTime, out endTime), x => x.CreateTime >= startTime && x.CreateTime <= endTime )
  1334. .Select(columns)
  1335. .ToList();
  1336. foreach (var item in InvitationOfficialActivityDataList)
  1337. {
  1338. EncryptionProcessor.DecryptProperties(item);
  1339. }
  1340. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.WhereIF(!string.IsNullOrWhiteSpace(dto.Country), x => !string.IsNullOrWhiteSpace(x.Country) && x.Country.Contains(dto.Country))
  1341. .WhereIF(!string.IsNullOrWhiteSpace(dto.UnitName), x => !string.IsNullOrWhiteSpace(x.UnitName) && x.UnitName.Contains(dto.UnitName))
  1342. .WhereIF(!string.IsNullOrWhiteSpace(dto.Contact), x => !string.IsNullOrWhiteSpace(x.Contact) && x.Contact.Contains(dto.Contact))
  1343. .WhereIF(!string.IsNullOrWhiteSpace(dto.Delegation), x => !string.IsNullOrWhiteSpace(x.Delegation) && x.Delegation.Contains(dto.Delegation))
  1344. .WhereIF(!string.IsNullOrWhiteSpace(dto.Field), x => !string.IsNullOrWhiteSpace(x.Field) && x.Field.Contains(dto.Field))
  1345. .ToList();
  1346. foreach (var item in ExcludedKeyStr)
  1347. {
  1348. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.UnitName) || !x.UnitName.Contains(item)).ToList();
  1349. //sqlWhere += $" And i.UnitName not like '%{item}%' ";
  1350. }
  1351. foreach (var item in ClientKeyStr)
  1352. {
  1353. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.Contact) || !x.Contact.Contains(item)).ToList();
  1354. //sqlWhere += $" And i.Contact not like '%{item}%' ";
  1355. }
  1356. var ids = InvitationOfficialActivityDataList.Select(x => x.Id);
  1357. RefAsync<int> totalCount = 0;
  1358. var _ivitiesViews = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1359. .LeftJoin<Sys_Users>((a, b) => b.IsDel == 0 && a.CreateUserId == b.Id)
  1360. .Where((a, b) => ids.Contains(a.Id))
  1361. .OrderByDescending((a, b) => a.CreateTime)
  1362. .Select((a, b) => new InvitationOfficialActivityDataView
  1363. {
  1364. FaceBook = a.FaceBook,
  1365. Id = a.Id,
  1366. CreateUserId = a.CreateUserId,
  1367. IsDel = 0,
  1368. Address = a.Address,
  1369. Background = a.Background,
  1370. City = a.City,
  1371. Contact = a.Contact,
  1372. Country = a.Country,
  1373. CreateTime = a.CreateTime,
  1374. CreateUserName = b.CnName,
  1375. Delegation = a.Delegation,
  1376. Email = a.Email,
  1377. Fax = a.Fax,
  1378. Field = a.Field,
  1379. FilePath = a.FilePath,
  1380. Ins = a.Ins,
  1381. WeChat = a.WeChat,
  1382. UnitWeb = a.UnitWeb,
  1383. UnitName = a.UnitName,
  1384. UnitInfo = a.UnitInfo,
  1385. Tel = a.Tel,
  1386. SndFilePath = a.SndFilePath,
  1387. SndFileName = a.SndFileName,
  1388. Remark = a.Remark,
  1389. OtherInfo = a.OtherInfo,
  1390. Job = a.Job
  1391. })
  1392. .ToPageListAsync(dto.PageIndex, dto.PageSize, totalCount);
  1393. var allGroupIds = new HashSet<int>();
  1394. foreach (var item in _ivitiesViews)
  1395. {
  1396. EncryptionProcessor.DecryptProperties(item);
  1397. if (!string.IsNullOrEmpty(item.Delegation))
  1398. {
  1399. allGroupIds.UnionWith(item.Delegation.Split(',').Select(x =>
  1400. {
  1401. int id;
  1402. if (int.TryParse(x, out id)) return id;
  1403. return 0;
  1404. }).Where(id => id != 0));
  1405. }
  1406. }
  1407. var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  1408. .Where(x => allGroupIds.Contains(x.Id) && x.IsDel == 0)
  1409. .ToList()
  1410. .GroupBy(x => x.Id)
  1411. .ToDictionary(group => group.Key, group => group.Select(g => g.TeamName));
  1412. foreach (var item in _ivitiesViews)
  1413. {
  1414. string groupNameStr = "";
  1415. if (!string.IsNullOrEmpty(item.Delegation))
  1416. {
  1417. var groupIds = item.Delegation.Split(',').Select(x =>
  1418. {
  1419. int id;
  1420. if (int.TryParse(x, out id)) return id;
  1421. return 0;
  1422. })
  1423. .Where(id => id != 0)
  1424. .ToArray();
  1425. foreach (var id in groupIds)
  1426. {
  1427. if (_DelegationInfos.ContainsKey(id))
  1428. {
  1429. groupNameStr += string.Join("", _DelegationInfos[id]) + ",";
  1430. }
  1431. }
  1432. if (groupNameStr.Length > 1)
  1433. {
  1434. groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
  1435. }
  1436. }
  1437. item.DelegationStr = groupNameStr;
  1438. }
  1439. return Ok(JsonView(true, $"查询成功!", _ivitiesViews, totalCount));
  1440. }
  1441. catch (Exception ex)
  1442. {
  1443. return Ok(JsonView(false, ex.Message));
  1444. }
  1445. }
  1446. //[HttpPost]
  1447. //public IActionResult EncipherInvitationOfficialActivityData()
  1448. //{
  1449. // var jw = JsonView(false);
  1450. // var List_DB = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().ToList();
  1451. // try
  1452. // {
  1453. // //foreach (var item in List_DB)
  1454. // //{
  1455. // // EncryptionProcessor.DecryptProperties(item);
  1456. // //}
  1457. // _sqlSugar.BeginTran();
  1458. // foreach (var item in List_DB)
  1459. // {
  1460. // EncryptionProcessor.EncryptProperties(item);
  1461. // }
  1462. // var updateRow = _sqlSugar.Updateable<Res_InvitationOfficialActivityData>(List_DB).ExecuteCommand();
  1463. // jw = JsonView(true, "success", "修改行数:" + updateRow);
  1464. // _sqlSugar.CommitTran();
  1465. // }
  1466. // catch (Exception ex)
  1467. // {
  1468. // _sqlSugar.RollbackTran();
  1469. // jw.Msg = ex.Message;
  1470. // }
  1471. // return Ok(jw);
  1472. //}
  1473. /// <summary>
  1474. /// 根据商邀资料Id查询信息
  1475. /// </summary>
  1476. /// <param name="id"></param>
  1477. /// <returns></returns>
  1478. [HttpGet("{id}")]
  1479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1480. public async Task<IActionResult> QueryInvitationOfficialActivityById(int id)
  1481. {
  1482. if (id < 1) return Ok(JsonView(false, "Id参数错误!"));
  1483. return Ok(await _InvitationOfficialActivityDataRep.Info(id));
  1484. }
  1485. /// <summary>
  1486. /// 商邀资料操作(Status:1.新增,2.修改)
  1487. /// </summary>
  1488. /// <param name="dto"></param>
  1489. /// <returns></returns>
  1490. [HttpPost]
  1491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1492. public async Task<IActionResult> OpInvitationOfficialActivity([FromForm] OpInvitationOfficialActivityDto dto)
  1493. {
  1494. return Ok(await _InvitationOfficialActivityDataRep.IOA_OP(dto));
  1495. }
  1496. /// <summary>
  1497. /// 商邀资料 删除文件
  1498. /// </summary>
  1499. /// <param name="id"></param>
  1500. /// <param name="fileName"></param>
  1501. /// <returns></returns>
  1502. [HttpDelete("{id}")]
  1503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1504. public async Task<IActionResult> InvitationOfficialActivityDelFile(int id, string fileName)
  1505. {
  1506. if (id < 1) return Ok(JsonView(false, "请传入有效的Id"));
  1507. if (string.IsNullOrEmpty(fileName)) return Ok(JsonView(false, "文件名称不能为空!"));
  1508. var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == id);
  1509. if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
  1510. var files = new List<string>();
  1511. try
  1512. {
  1513. files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
  1514. }
  1515. catch (Exception) { }
  1516. if (files != null && files.Count > 0 && files.Contains(fileName))
  1517. {
  1518. var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
  1519. if (System.IO.File.Exists(filePath))
  1520. {
  1521. System.IO.File.Delete(filePath);
  1522. }
  1523. //更改文件值
  1524. files.Remove(fileName);
  1525. var fileUpd = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
  1526. .SetColumns(x => x.SndFileName == JsonConvert.SerializeObject(files))
  1527. .Where(x => x.Id == id)
  1528. .ExecuteCommandAsync();
  1529. if (fileUpd > 0) return Ok(JsonView(true, "操作成功!"));
  1530. }
  1531. return Ok(JsonView(false, "操作失败!"));
  1532. }
  1533. /// <summary>
  1534. /// 删除商邀资料信息
  1535. /// </summary>
  1536. /// <param name="dto"></param>
  1537. /// <returns></returns>
  1538. [HttpPost]
  1539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1540. public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
  1541. {
  1542. var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
  1543. if (!res) return Ok(JsonView(false, "删除失败"));
  1544. var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == dto.Id);
  1545. if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
  1546. var files = new List<string>();
  1547. try
  1548. {
  1549. files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
  1550. }
  1551. catch (Exception) { }
  1552. if (files != null && files.Count > 0)
  1553. {
  1554. foreach (var fileName in files)
  1555. {
  1556. var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
  1557. if (System.IO.File.Exists(filePath))
  1558. {
  1559. System.IO.File.Delete(filePath);
  1560. }
  1561. }
  1562. }
  1563. return Ok(JsonView(true, "删除成功!"));
  1564. }
  1565. /// <summary>
  1566. /// 商邀资料 ExcelExport
  1567. /// </summary>
  1568. /// <param name="dto"></param>
  1569. /// <returns></returns>
  1570. [HttpPost]
  1571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1572. public async Task<IActionResult> InvitationOfficialActivityExcelExport(QueryInvitationOfficialActivityDataDto dto)
  1573. {
  1574. var ExcludedKeyStr = new string[] { "快递费" };
  1575. var ClientKeyStr = new string[] { "邀请函翻译" };
  1576. var columns = "Id,UnitName,Contact";
  1577. #region 参数验证
  1578. if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
  1579. if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
  1580. #endregion
  1581. if (!string.IsNullOrWhiteSpace(dto.Country)) { columns += ",Country"; }
  1582. if (!string.IsNullOrWhiteSpace(dto.Delegation)) { columns += ",Delegation"; }
  1583. if (!string.IsNullOrWhiteSpace(dto.Field)) { columns += ",Field"; }
  1584. DateTime endTime = new DateTime();
  1585. var InvitationOfficialActivityDataList = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1586. .Where(x => x.IsDel == 0)
  1587. .WhereIF(dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString()), x => x.CreateUserId == dto.CreateUserId)
  1588. .WhereIF(DateTime.TryParse(dto.StartCreateTime, out DateTime startTime) && DateTime.TryParse(dto.EndCreateTime, out endTime), x => x.CreateTime >= startTime && x.CreateTime <= endTime)
  1589. .Select(columns)
  1590. .ToList();
  1591. foreach (var item in InvitationOfficialActivityDataList)
  1592. {
  1593. EncryptionProcessor.DecryptProperties(item);
  1594. }
  1595. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList
  1596. .WhereIF(!string.IsNullOrWhiteSpace(dto.Country), x => !string.IsNullOrWhiteSpace(x.Country) && x.Country.Contains(dto.Country))
  1597. .WhereIF(!string.IsNullOrWhiteSpace(dto.UnitName), x => !string.IsNullOrWhiteSpace(x.UnitName) && x.UnitName.Contains(dto.UnitName))
  1598. .WhereIF(!string.IsNullOrWhiteSpace(dto.Contact), x => !string.IsNullOrWhiteSpace(x.Contact) && x.Contact.Contains(dto.Contact))
  1599. .WhereIF(!string.IsNullOrWhiteSpace(dto.Delegation), x => !string.IsNullOrWhiteSpace(x.Delegation) && x.Delegation.Contains(dto.Delegation))
  1600. .WhereIF(!string.IsNullOrWhiteSpace(dto.Field), x => !string.IsNullOrWhiteSpace(x.Field) && x.Field.Contains(dto.Field))
  1601. .ToList();
  1602. foreach (var item in ExcludedKeyStr)
  1603. {
  1604. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.UnitName) || !x.UnitName.Contains(item)).ToList();
  1605. //sqlWhere += $" And i.UnitName not like '%{item}%' ";
  1606. }
  1607. foreach (var item in ClientKeyStr)
  1608. {
  1609. InvitationOfficialActivityDataList = InvitationOfficialActivityDataList.Where(x => string.IsNullOrWhiteSpace(x.Contact) || !x.Contact.Contains(item)).ToList();
  1610. //sqlWhere += $" And i.Contact not like '%{item}%' ";
  1611. }
  1612. var ids = InvitationOfficialActivityDataList.Select(x => x.Id);
  1613. var _ivitiesViews = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
  1614. .LeftJoin<Sys_Users>((a, b) => b.IsDel == 0 && a.CreateUserId == b.Id)
  1615. .Where((a, b) => ids.Contains(a.Id))
  1616. .OrderByDescending((a, b) => a.CreateTime)
  1617. .Select((a, b) => new IOAInfoView
  1618. {
  1619. FaceBook = a.FaceBook,
  1620. Id = a.Id,
  1621. Address = a.Address,
  1622. Background = a.Background,
  1623. City = a.City,
  1624. Contact = a.Contact,
  1625. Country = a.Country,
  1626. Delegation = a.Delegation,
  1627. Email = a.Email,
  1628. Fax = a.Fax,
  1629. Field = a.Field,
  1630. Ins = a.Ins,
  1631. WeChat = a.WeChat,
  1632. UnitWeb = a.UnitWeb,
  1633. UnitName = a.UnitName,
  1634. UnitInfo = a.UnitInfo,
  1635. Tel = a.Tel,
  1636. SndFileName = a.SndFileName,
  1637. Remark = a.Remark,
  1638. OtherInfo = a.OtherInfo,
  1639. Job = a.Job
  1640. })
  1641. .ToListAsync();
  1642. if (!_ivitiesViews.Any()) return Ok(JsonView(false, $"您查询的数据暂无内容,不可导出!"));
  1643. var allGroupIds = new HashSet<int>();
  1644. foreach (var item in _ivitiesViews)
  1645. {
  1646. EncryptionProcessor.DecryptProperties(item);
  1647. if (!string.IsNullOrEmpty(item.Delegation))
  1648. {
  1649. allGroupIds.UnionWith(
  1650. item.Delegation.Split(',')
  1651. .Select(x =>
  1652. {
  1653. int id;
  1654. if (int.TryParse(x, out id)) return id;
  1655. return 0;
  1656. })
  1657. .Where(id => id != 0)
  1658. );
  1659. }
  1660. }
  1661. var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  1662. .Where(x => allGroupIds.Contains(x.Id) && x.IsDel == 0)
  1663. .ToList()
  1664. .GroupBy(x => x.Id)
  1665. .ToDictionary(group => group.Key, group => group.Select(g => g.TeamName));
  1666. foreach (var item in _ivitiesViews)
  1667. {
  1668. string groupNameStr = "";
  1669. if (!string.IsNullOrEmpty(item.Delegation))
  1670. {
  1671. var groupIds = item.Delegation.Split(',').Select(x =>
  1672. {
  1673. int id;
  1674. if (int.TryParse(x, out id)) return id;
  1675. return 0;
  1676. })
  1677. .Where(id => id != 0)
  1678. .ToArray();
  1679. foreach (var id in groupIds)
  1680. {
  1681. if (_DelegationInfos.ContainsKey(id))
  1682. {
  1683. groupNameStr += string.Join("", _DelegationInfos[id]) + ",";
  1684. }
  1685. }
  1686. if (groupNameStr.Length > 1)
  1687. {
  1688. groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
  1689. }
  1690. }
  1691. item.DelegationStr = groupNameStr;
  1692. }
  1693. //获取模板
  1694. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/商邀资料模板.xls");
  1695. var designer = new WorkbookDesigner();
  1696. designer.Workbook = new Workbook(tempPath);
  1697. var dt = CommonFun.ToDataTableArray(_ivitiesViews);
  1698. dt.TableName = $"OADataView";
  1699. designer.SetDataSource(dt);
  1700. designer.Process();
  1701. //文件名
  1702. string fileName = $"商邀资料{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  1703. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "InvitationOfficialActivityExport/" + fileName);
  1704. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/InvitationOfficialActivityExport/" + fileName;
  1705. return Ok(JsonView(true, "成功", url));
  1706. }
  1707. /// <summary>
  1708. /// 商邀资料 导入文件(Excel)模板下载
  1709. /// </summary>
  1710. /// <param name="dto"></param>
  1711. /// <returns></returns>
  1712. [HttpGet]
  1713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1714. public async Task<IActionResult> InvitationOfficialActivityExcelTemplateExport()
  1715. {
  1716. //获取模板
  1717. string fileName = $"商邀资料上传文件模板.xls";
  1718. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/Template/" + fileName;
  1719. return Ok(JsonView(true, "成功", url));
  1720. }
  1721. /// <summary>
  1722. /// 商邀资料 上传Excel文件添加
  1723. /// </summary>
  1724. /// <param name="file"></param>
  1725. /// <param name="currUserId"></param>
  1726. /// <returns></returns>
  1727. [HttpPost]
  1728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1729. public async Task<IActionResult> InvitationOfficialActivityExcelUpload(IFormFile file,int currUserId)
  1730. {
  1731. var fileName = file.FileName;
  1732. var filePostfix = fileName.Split(".")[1].ToUpper();
  1733. if (!filePostfix.Contains("XLS")) return Ok(JsonView(false, $"请传入Excel文件"));
  1734. if (file.Length < 1) return Ok(JsonView(false, $"请传入有效的文件"));
  1735. if (currUserId < 1) return Ok(JsonView(false, $"请传入有效的UserId"));
  1736. //保存文件
  1737. string fileDirPath = string.Format(@"{0}InvitationOfficialActivityExcelUpload/", AppSettingsHelper.Get("ExcelBasePath"));
  1738. if (!Directory.Exists(fileDirPath))
  1739. {
  1740. Directory.CreateDirectory(fileDirPath);
  1741. }
  1742. var filePath = Path.Combine(fileDirPath, fileName);
  1743. await using var stream = new FileStream(filePath, FileMode.Create);
  1744. await file.CopyToAsync(stream);
  1745. //读取保存的文件
  1746. Workbook workbook = new Workbook(filePath);
  1747. if (workbook == null) return Ok(JsonView(false, $"Excel文件不存在!"));
  1748. Worksheet worksheet = workbook.Worksheets[0];
  1749. if (worksheet == null) return Ok(JsonView(false, $"Excel文件工作簿不存在!"));
  1750. var infos = new List<Res_InvitationOfficialActivityData>();
  1751. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName)).Select(x => new { x.Id, x.TeamName }).ToListAsync();
  1752. for (int row = 1; row < worksheet.Cells.MaxDataRow + 1; row++)
  1753. {
  1754. var groupIdsLabel = string.Empty;
  1755. var groupNames1 = worksheet.Cells[row, 14].StringValue ?? "-";
  1756. if (!string.IsNullOrEmpty(groupNames1))
  1757. {
  1758. if (groupNames1.Contains(";"))
  1759. {
  1760. var groupNameArray = groupNames1.Split(";").Where(x => !string.IsNullOrEmpty(x)).ToList();
  1761. var groupIds = groupNames.Where(x => groupNameArray.Contains(x.TeamName)).Select(x => x.Id).ToList();
  1762. if (groupIds.Any()) groupIdsLabel = string.Join(',', groupIds);
  1763. }
  1764. else groupIdsLabel = groupNames.Where(x => groupNames1.Equals(x.TeamName)).FirstOrDefault()?.Id.ToString() ?? string.Empty;
  1765. }
  1766. infos.Add(new Res_InvitationOfficialActivityData() {
  1767. Country = worksheet.Cells[row, 0].StringValue ?? "-",
  1768. City = worksheet.Cells[row, 1].StringValue ?? "-",
  1769. UnitName = worksheet.Cells[row, 2].StringValue ?? "-",
  1770. Field = worksheet.Cells[row, 3].StringValue ?? "-",
  1771. Address = worksheet.Cells[row, 4].StringValue ?? "-",
  1772. UnitInfo = worksheet.Cells[row, 5].StringValue ?? "-",
  1773. Contact = worksheet.Cells[row, 6].StringValue ?? "-",
  1774. Job = worksheet.Cells[row, 7].StringValue ?? "-",
  1775. Tel = worksheet.Cells[row, 8].StringValue ?? "-",
  1776. Email = worksheet.Cells[row, 9].StringValue ?? "-",
  1777. WeChat = worksheet.Cells[row, 10].StringValue ?? "-",
  1778. FaceBook = worksheet.Cells[row, 11].StringValue ?? "-",
  1779. Ins = worksheet.Cells[row, 12].StringValue ?? "-",
  1780. Fax = worksheet.Cells[row, 13].StringValue ?? "-",
  1781. Delegation = groupIdsLabel,
  1782. SndFilePath = worksheet.Cells[row, 15].StringValue ?? "-",
  1783. OtherInfo = worksheet.Cells[row, 16].StringValue ?? "-",
  1784. Remark = $"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}] Excel上传文件添加! 文件存储地址[{filePath}]",
  1785. CreateUserId = currUserId,
  1786. IsDel = 0
  1787. });
  1788. }
  1789. //加密
  1790. foreach (var item in infos) EncryptionProcessor.EncryptProperties(item);
  1791. var addCount = await _sqlSugar.Insertable(infos).ExecuteCommandAsync();
  1792. if (addCount < 1) return Ok(JsonView(false, "文件上传添加失败!"));
  1793. return Ok(JsonView(true, $"上传文件添加成功!共添加{addCount}条!"));
  1794. }
  1795. #endregion
  1796. #region 公务出访
  1797. /// <summary>
  1798. /// 获取团组所有信息,绑定下拉框
  1799. /// </summary>
  1800. /// <param name="dto"></param>
  1801. /// <returns></returns>
  1802. [HttpPost]
  1803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1804. public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
  1805. {
  1806. //string groupSql = string.Format("Select * From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By CreateTime Desc");
  1807. //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.SqlQueryable< Grp_DelegationInfo >(groupSql).ToList();
  1808. var _groupData = await _delegationInfoRep.PostShareGroupInfos(1);
  1809. dynamic groupInfos = null;
  1810. if (_groupData.Code == 0) groupInfos = _groupData.Data;
  1811. var data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0).ToList();
  1812. var data1 = data.Where(a => a.STid == 38).Select(x => new { x.Id,x.Name }).ToList();
  1813. var data2 = data.Where(a => a.STid == 101).Select(x => new { x.Id, x.Name }).ToList();
  1814. var data3 = data.Where(a => a.STid == 66).Select(x => new { x.Id, x.Name ,x.Remark}).ToList();
  1815. var _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
  1816. var translatorData = _sqlSugar.Queryable<Res_TranslatorLibrary>().Where(a => a.IsDel == 0).ToList();
  1817. var translatorData1 = _mapper.Map<List<TranslatorView>>(translatorData);
  1818. foreach (var item in translatorData1) EncryptionProcessor.DecryptProperties(item);
  1819. return Ok(JsonView(true, "查询成功!", new { Delegation = groupInfos, SetData = data1,DataSource = data2, currencyData = data3, DeleFile = _DeleFile , TranslatorData = translatorData1 }));
  1820. }
  1821. /// <summary>
  1822. /// 公务List
  1823. /// </summary>
  1824. /// <param name="dto"></param>
  1825. /// <returns></returns>
  1826. [HttpPost]
  1827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1828. public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
  1829. {
  1830. return Ok(await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto));
  1831. }
  1832. /// <summary>
  1833. /// 根据公务出访数据Id查询数据
  1834. /// </summary>
  1835. /// <param name="dto"></param>
  1836. /// <returns></returns>
  1837. [HttpPost]
  1838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1839. public async Task<IActionResult> QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
  1840. {
  1841. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
  1842. if (groupData.Code != 0)
  1843. {
  1844. return Ok(JsonView(false, groupData.Msg));
  1845. }
  1846. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1847. }
  1848. /// <summary>
  1849. /// 公务出访操作(Status:1.新增,2.修改)
  1850. /// </summary>
  1851. /// <param name="dto"></param>
  1852. /// <returns></returns>
  1853. [HttpPost]
  1854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1855. public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
  1856. {
  1857. Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
  1858. if (groupData.Code != 0)
  1859. {
  1860. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, new { Id = 0 }));
  1861. }
  1862. try
  1863. {
  1864. //公务出访变更发送通知
  1865. await AppNoticeLibrary.SendUserMsg_GroupShare_ToOP(dto.DiId, dto.CreateUserId);
  1866. }
  1867. catch (Exception ex)
  1868. {
  1869. //抄送日志
  1870. }
  1871. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1872. }
  1873. /// <summary>
  1874. /// 上传文件(邮件截图)
  1875. /// </summary>
  1876. /// <param name="file"></param>
  1877. /// <returns></returns>
  1878. [HttpPost]
  1879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1880. public async Task<IActionResult> OfficialActivitiesUploadFiles([FromForm] OfficialActivitiesUploadFilesDto dto)
  1881. {
  1882. string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1883. string localPath = AppSettingsHelper.Get("GrpFileBasePath");
  1884. string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
  1885. if (dto.diId < 1 || dto.currUserId < 1)
  1886. {
  1887. return Ok(JsonView(false, "参数有误,上传失败!"));
  1888. }
  1889. if (dto.files == null || dto.files.Count < 1)
  1890. {
  1891. return Ok(JsonView(false, "文件为空,上传失败!"));
  1892. }
  1893. string localFileDir = $"{localPath}{ptfPath}";
  1894. List<string> fileUrls = new List<string>();
  1895. string[] failFiles = new string[] { };
  1896. foreach (var file in dto.files)
  1897. {
  1898. //文件名称
  1899. string[] fileNameArray = file.FileName.Split(".");
  1900. string projectFileName = $"{fileNameArray[0].ToString().Replace("-", "_").Replace("/", "_")}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileNameArray[1].ToString()}";
  1901. //上传的文件的路径
  1902. string filePath = $@"{localPath}公务相关文件";
  1903. if (!Directory.Exists(filePath))
  1904. {
  1905. Directory.CreateDirectory(filePath);
  1906. }
  1907. var path = Path.Combine(filePath, projectFileName);
  1908. //using var stream = new FileStream(path, FileMode.Create);
  1909. //await file.CopyToAsync(stream);
  1910. try
  1911. {
  1912. using (FileStream fs = System.IO.File.Create(path))
  1913. {
  1914. file.CopyTo(fs);
  1915. fs.Flush();
  1916. }
  1917. fileUrls.Add($"/{ptfPath}公务相关文件/{projectFileName}");
  1918. }
  1919. catch (Exception ex)
  1920. {
  1921. failFiles.Append(file.FileName);
  1922. }
  1923. }
  1924. var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.id).FirstAsync();
  1925. List<string> files = new List<string>();
  1926. var status = false;
  1927. var _oaInfo = new Res_OfficialActivities()
  1928. {
  1929. DiId = dto.diId,
  1930. ScreenshotOfMailUrl = JsonConvert.SerializeObject(fileUrls),
  1931. IsDel = 0,
  1932. CreateUserId = dto.currUserId,
  1933. CreateTime = DateTime.Now
  1934. };
  1935. if (oaInfo == null)
  1936. {
  1937. var id = await _sqlSugar.Insertable<Res_OfficialActivities>(_oaInfo)
  1938. .ExecuteReturnIdentityAsync();
  1939. if (id > 0)
  1940. {
  1941. status = true;
  1942. dto.id = id;
  1943. }
  1944. }
  1945. else
  1946. {
  1947. var oldFiles = string.IsNullOrEmpty(oaInfo.ScreenshotOfMailUrl)
  1948. ? new List<string>()
  1949. : JsonConvert.DeserializeObject<List<string>>(oaInfo.ScreenshotOfMailUrl);
  1950. if (oldFiles.Count > 0)
  1951. {
  1952. fileUrls.AddRange(oldFiles);
  1953. }
  1954. fileUrls = fileUrls.Distinct().ToList();
  1955. if (fileUrls.Count() > 0)
  1956. {
  1957. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  1958. .SetColumns(x => x.ScreenshotOfMailUrl == JsonConvert.SerializeObject(fileUrls))
  1959. .Where(x => x.Id == dto.id)
  1960. .ExecuteCommandAsync();
  1961. if (upd > 0) status = true;
  1962. }
  1963. }
  1964. List<string> returnFileUrls = new List<string>();
  1965. fileUrls.ForEach(x =>
  1966. {
  1967. returnFileUrls.Add($"{networkPath}{x}");
  1968. });
  1969. if (status)
  1970. {
  1971. string msg = "操作成功!";
  1972. if (failFiles.Length > 1)
  1973. {
  1974. foreach (var item in failFiles)
  1975. {
  1976. msg += $"{failFiles}、";
  1977. }
  1978. msg = msg.Substring(0, msg.Length - 1);
  1979. msg += "等文件保存失败!";
  1980. }
  1981. return Ok(JsonView(true, msg, new { id = dto.id, fileUrls = returnFileUrls }));
  1982. }
  1983. return Ok(JsonView(false, "操作失败!"));
  1984. }
  1985. /// <summary>
  1986. /// 删除文件(邮件截图)
  1987. /// </summary>
  1988. /// <param name="file"></param>
  1989. /// <returns></returns>
  1990. [HttpPost]
  1991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1992. public async Task<IActionResult> OfficialActivitiesDelFile(OfficialActivitiesDelFileDto dto)
  1993. {
  1994. string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1995. string localPath = AppSettingsHelper.Get("GrpFileBasePath");
  1996. string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
  1997. if (dto.Id < 1 || string.IsNullOrEmpty(dto.FileName))
  1998. {
  1999. return Ok(JsonView(false, "参数有误,上传失败!"));
  2000. }
  2001. string localFileDir = $"{localPath}{ptfPath}";
  2002. List<string> fileUrls = new List<string>();
  2003. var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.Id).FirstAsync();
  2004. if (oaInfo != null)
  2005. {
  2006. string urlJson = oaInfo.ScreenshotOfMailUrl ?? "";
  2007. if (!string.IsNullOrEmpty(urlJson))
  2008. {
  2009. List<string> urls = JsonConvert.DeserializeObject<List<string>>(urlJson);
  2010. var filePath = urls.Find(x => x.Contains(dto.FileName));
  2011. if (string.IsNullOrEmpty(filePath)) return Ok(JsonView(false, "文件不存在!"));
  2012. var updFile = urls.Remove(filePath);
  2013. if (updFile)
  2014. {
  2015. //删除文件
  2016. string fileUrl = AppSettingsHelper.Get("GrpFileBasePath").Replace(@"/Office/GrpFile", "") + filePath;
  2017. if (System.IO.File.Exists(fileUrl))
  2018. {
  2019. System.IO.File.Delete(fileUrl);
  2020. }
  2021. string urlJsonstr = JsonConvert.SerializeObject(urls);
  2022. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  2023. .SetColumns(x => x.ScreenshotOfMailUrl == urlJsonstr)
  2024. .Where(x => x.Id == dto.Id)
  2025. .ExecuteCommandAsync();
  2026. if (upd > 0) return Ok(JsonView(true, "操作成功!"));
  2027. }
  2028. }
  2029. }
  2030. return Ok(JsonView(false, "操作失败!"));
  2031. }
  2032. /// <summary>
  2033. /// 公务出访 确认、取消邀请
  2034. /// </summary>
  2035. /// <param name="file"></param>
  2036. /// <returns></returns>
  2037. [HttpPost]
  2038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2039. public async Task<IActionResult> OfficialActivitiesInviteOperation(OfficialActivitiesInviteOperationDto dto)
  2040. {
  2041. if (dto.Id < 1) return Ok(JsonView(false, "Id参数有误!"));
  2042. if (dto.Type < 0 || dto.Type > 1) return Ok(JsonView(false, "Type参数有误!"));
  2043. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  2044. .SetColumns(x => x.ConfirmTheInvitation == dto.Type)
  2045. .Where(x => x.Id == dto.Id)
  2046. .ExecuteCommandAsync();
  2047. if (upd > 0) return Ok(JsonView(true, "操作成功!"));
  2048. return Ok(JsonView(false, "操作失败!"));
  2049. }
  2050. /// <summary>
  2051. /// 上传文件
  2052. /// </summary>
  2053. /// <param name="file"></param>
  2054. /// <returns></returns>
  2055. [HttpPost]
  2056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2057. public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
  2058. {
  2059. try
  2060. {
  2061. int Type = int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
  2062. int DiId = int.Parse(Request.Headers["DiId"]);
  2063. int CreateUserId = int.Parse(Request.Headers["CreateUserId"]);
  2064. if (file != null)
  2065. {
  2066. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2067. //文件名称
  2068. string projectFileName = file.FileName;
  2069. //上传的文件的路径
  2070. string filePath = "";
  2071. if (!Directory.Exists(fileDir))
  2072. {
  2073. Directory.CreateDirectory(fileDir);
  2074. }
  2075. //上传的文件的路径
  2076. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2077. using (FileStream fs = System.IO.File.Create(filePath))
  2078. {
  2079. file.CopyTo(fs);
  2080. fs.Flush();
  2081. }
  2082. Grp_DeleFile d = new Grp_DeleFile();
  2083. d.Diid = DiId;
  2084. d.Category = 970;
  2085. if (Type == 1) d.Kind = 1;
  2086. else if (Type == 2) d.Kind = 2;
  2087. else if (Type == 3) d.Kind = 3;
  2088. d.FileName = projectFileName;
  2089. d.FilePath = "";
  2090. d.CreateUserId = CreateUserId;
  2091. int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
  2092. return Ok(JsonView(true, "上传成功!", projectFileName));
  2093. }
  2094. else
  2095. {
  2096. return Ok(JsonView(false, "上传失败!"));
  2097. }
  2098. }
  2099. catch (Exception ex)
  2100. {
  2101. return Ok(JsonView(false, "程序错误!"));
  2102. throw;
  2103. }
  2104. }
  2105. /// <summary>
  2106. /// 删除文件
  2107. /// </summary>
  2108. /// <param name="dto"></param>
  2109. /// <returns></returns>
  2110. [HttpPost]
  2111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2112. public async Task<IActionResult> DelloadOfficialActivities(DelBaseDto dto)
  2113. {
  2114. try
  2115. {
  2116. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2117. Grp_DeleFile _DeleFile = await _sqlSugar.Queryable<Grp_DeleFile>().FirstAsync(a => a.Id == dto.Id);
  2118. if (_DeleFile != null)
  2119. {
  2120. string fileName = _DeleFile.FileName;
  2121. string filePath = fileDir + "/团组增减款项相关文件/" + fileName;
  2122. // 删除该文件
  2123. System.IO.File.Delete(filePath);
  2124. int id = await _sqlSugar.Updateable<Grp_DeleFile>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DeleFile { IsDel = 1, DeleteUserId = dto.DeleteUserId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }).ExecuteCommandAsync();
  2125. return Ok(JsonView(true, "取消文件成功!"));
  2126. }
  2127. else
  2128. {
  2129. return Ok(JsonView(false, "取消文件失败!"));
  2130. }
  2131. }
  2132. catch (Exception ex)
  2133. {
  2134. return Ok(JsonView(false, "程序错误!"));
  2135. throw;
  2136. }
  2137. }
  2138. /// <summary>
  2139. /// 删除公务出访信息
  2140. /// </summary>
  2141. /// <param name="dto"></param>
  2142. /// <returns></returns>
  2143. [HttpPost]
  2144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2145. public async Task<IActionResult> DelOfficialActivities(DelBaseDto dto)
  2146. {
  2147. _sqlSugar.BeginTran();
  2148. var res = await _officialActivitiesRep.SoftDeleteByIdAsync<Res_OfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  2149. if (!res)
  2150. {
  2151. _sqlSugar.RollbackTran();
  2152. return Ok(JsonView(false, "删除失败"));
  2153. }
  2154. #region 删除公务出访
  2155. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  2156. .SetColumns(x => new Grp_OfficialDutyLinkTranslator()
  2157. {
  2158. DeleteUserId = dto.DeleteUserId,
  2159. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  2160. IsDel = 1,
  2161. Remark = $"公务出访-->删除"
  2162. })
  2163. .Where(x => x.OfficialDutyId == dto.Id)
  2164. .ExecuteCommandAsync();
  2165. #endregion
  2166. _sqlSugar.CommitTran();
  2167. return Ok(JsonView(true, "删除成功!"));
  2168. }
  2169. /// <summary>
  2170. /// 公务出访
  2171. /// 请示范例提示
  2172. /// Add Time:2024-05-13 13:56:44
  2173. /// </summary>
  2174. /// <param name="dto"></param>
  2175. /// <returns></returns>
  2176. [HttpPost]
  2177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2178. public async Task<IActionResult> PostOfficialActivitiesReqReqSampleTips(PostOfficialActivitiesReqReqSampleTipsDto dto)
  2179. {
  2180. var res = await _officialActivitiesRep.PostReqReqSampleTips(dto.country, dto.area, dto.client);
  2181. if (res.Code == 0)
  2182. {
  2183. return Ok(JsonView(true, "操作成功!", res.Data));
  2184. }
  2185. return Ok(JsonView(false, res.Msg));
  2186. }
  2187. /// <summary>
  2188. /// 公务出访 (省外办,市外办) File Downlaod
  2189. /// </summary>
  2190. /// <param name="dto"></param>
  2191. /// <returns></returns>
  2192. [HttpPost]
  2193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2194. public async Task<IActionResult> OfficialActivitiesFileDownload(OfficialActivitiesFileDownload dto)
  2195. {
  2196. #region 参数验证
  2197. if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示", ""));
  2198. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数.", ""));
  2199. #endregion
  2200. //团组基础信息
  2201. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  2202. if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在", ""));
  2203. groupInfo.VisitCountry = groupInfo.VisitCountry.Replace("|", "、");
  2204. //团组公务信息
  2205. var obDatas = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderBy(it => it.Date).ToList();
  2206. //if (obDatas.Count < 1) return Ok(JsonView(false, "请先录入公务信息!"));
  2207. //团组客户名单
  2208. var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
  2209. List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
  2210. if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
  2211. string visitCountrys = ""; //××国家(或地区)×天,××国家(或地区)×天
  2212. string countryStayStr = ""; // xx、xx、xx
  2213. //出入境费用 住宿类型
  2214. var dayCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.Type == 1).ToList();
  2215. if (dayCostDatas.Count > 0)
  2216. {
  2217. List<int> nationalIds = dayCostDatas.Select(it => it.NationalTravelFeeId).ToList();
  2218. var nationalDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => nationalIds.Contains(it.Id)).ToList();
  2219. var nationalDataGroupByCountry = nationalDatas.GroupBy(it => it.Country);
  2220. foreach (var item in nationalDataGroupByCountry)
  2221. {
  2222. visitCountrys += $"{item.Key}、";
  2223. int stayDays = nationalIds.Where(it => it == item.ToList()[0].Id).Count();
  2224. countryStayStr += $"{item.Key}{stayDays}天,";
  2225. }
  2226. if (visitCountrys.Length > 0) visitCountrys = visitCountrys.Substring(0, visitCountrys.Length - 1);
  2227. if (countryStayStr.Length > 0) countryStayStr = countryStayStr.Substring(0, countryStayStr.Length - 1);
  2228. }
  2229. else
  2230. {
  2231. visitCountrys = groupInfo.VisitCountry;
  2232. countryStayStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
  2233. }
  2234. //出访人数
  2235. int visitPeopleNum = groupInfo.VisitPNumber;
  2236. int visitDaysNum = groupInfo.VisitDays;
  2237. //出访单位
  2238. string obInfoStr = "";
  2239. foreach (var ob in obDatas) obInfoStr += @$"{ob.Client.Trim()}{ob.Job.Trim()}{ob.Contact.Trim()}、";
  2240. if (obInfoStr.Length > 0) obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
  2241. obInfoStr = obInfoStr ?? "[公务出访未录入]";
  2242. //出访路线
  2243. string lineStr = GeneralMethod.GetGroupCityLine(groupInfo.Id, "—");
  2244. if (dto.FileType == 1)
  2245. {
  2246. //载入模板
  2247. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
  2248. var doc = new Document(tempPath);
  2249. DocumentBuilder builder = new DocumentBuilder(doc);
  2250. //键值对存放数据
  2251. Dictionary<string, string> dic = new Dictionary<string, string>();
  2252. //××(组团单位):接团客户信息团组
  2253. dic.Add("GroupClient", $"{groupInfo.ClientUnit}\r\n");
  2254. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  2255. string guestName = "";
  2256. string guestJob = "";
  2257. string guestInfoStr = "";
  2258. var guestFirstInfo = guestInfos.FirstOrDefault();
  2259. if (guestFirstInfo != null)
  2260. {
  2261. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  2262. guestJob = guestFirstInfo.Job.Trim();
  2263. guestInfoStr = $@"{guestJob}、{guestName}";
  2264. }
  2265. guestInfoStr = guestInfoStr ?? "[接团客户名单未录入]";
  2266. string askTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  2267. dic.Add("AskTitle", askTitle);
  2268. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
  2269. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  2270. string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。现请示如下。";
  2271. dic.Add("AskSubTitle", askSubTitle);
  2272. //出访目的
  2273. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  2274. //出访任务
  2275. //(一)××(国家或地区)
  2276. //1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  2277. //2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  2278. string obBackgroundStr = "";//出访背景
  2279. string taskStr = ""; ; //出访任务
  2280. var countrys = obDatas.GroupBy(it => it.Country);
  2281. int countryIndex = 1;
  2282. foreach (var item in countrys)
  2283. {
  2284. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item.Key}\r\n";
  2285. string taskContent = "";
  2286. string obBackgroundContent = "";
  2287. int obIndex = 1;
  2288. foreach (var obInfo in item.ToList())
  2289. {
  2290. string reqSmaple = "";
  2291. string settingStr = "";
  2292. if (!string.IsNullOrEmpty(obInfo.ReqSample)) reqSmaple = obInfo.ReqSample;
  2293. else reqSmaple = "[公务出访请示范例未录入]";
  2294. if (!string.IsNullOrEmpty(obInfo.Setting)) settingStr = obInfo.Setting;
  2295. else settingStr = "[公务方背景未录入]";
  2296. taskContent += $"{obIndex}. {reqSmaple}\r\n";
  2297. obBackgroundContent += $"{obIndex}. {obInfo.Client}:{settingStr}\r\n";
  2298. obIndex++;
  2299. }
  2300. taskStr += $"{taskTitle}{taskContent}";
  2301. obBackgroundStr += $"{taskTitle}{obBackgroundContent}";
  2302. countryIndex++;
  2303. }
  2304. //出访背景
  2305. if (obBackgroundStr.Length < 1) obBackgroundStr = "[公务出访背景未录入]";
  2306. dic.Add("OBSetting", obBackgroundStr);
  2307. //出访任务
  2308. if (taskStr.Length < 1) taskStr = "[公务出访任务未录入]";
  2309. dic.Add("TaskContent", taskStr);
  2310. //出访时间
  2311. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。
  2312. string visitTimeQuantumStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。";
  2313. //出访时间
  2314. dic.Add("TimeQuantum", visitTimeQuantumStr);
  2315. //出访路线
  2316. //成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)
  2317. dic.Add("Line", lineStr);
  2318. //scheduling //行程安排
  2319. string schedulingStr = $"[OP行程单暂未生成]";
  2320. #region op行程 根据黑屏代码录入
  2321. var opTripView = GeneralMethod.GetBriefStroke(groupInfo.Id);
  2322. if (opTripView.Code != 0) schedulingStr = $"[{opTripView.Msg}]";
  2323. schedulingStr = "";
  2324. List<Grp_TravelList> travelList = new List<Grp_TravelList>();
  2325. travelList = opTripView.Data as List<Grp_TravelList>;
  2326. if (travelList != null)
  2327. {
  2328. foreach (var item in travelList)
  2329. {
  2330. schedulingStr += $"{item.Date}({item.WeekDay})\r\n{item.Trip}\r\n";
  2331. }
  2332. }
  2333. #endregion
  2334. dic.Add("Scheduling", schedulingStr);
  2335. #region 填充word模板书签内容
  2336. foreach (var key in dic.Keys)
  2337. {
  2338. builder.MoveToBookmark(key);
  2339. builder.Write(dic[key]);
  2340. }
  2341. #endregion
  2342. //获取word里所有表格
  2343. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2344. //获取所填表格的序数
  2345. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2346. var rowStart = tableOne.Rows[0]; //获取第1行
  2347. //循环赋值
  2348. for (int i = 0; i < guestInfos.Count; i++)
  2349. {
  2350. var guestInfo = guestInfos[i];
  2351. builder.MoveToCell(0, i + 1, 0, 0);
  2352. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  2353. builder.MoveToCell(0, i + 1, 1, 0);
  2354. int sex = guestInfo.Sex;
  2355. string sexStr = string.Empty;
  2356. if (sex == 0) sexStr = "男";
  2357. else if (sex == 1) sexStr = "女";
  2358. else sexStr = "-";
  2359. builder.Write(sexStr);
  2360. builder.MoveToCell(0, i + 1, 2, 0);
  2361. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  2362. builder.MoveToCell(0, i + 1, 3, 0);
  2363. string birthDay = "";
  2364. string birthDayStr = string.Empty;
  2365. if (guestInfo.BirthDay != null)
  2366. {
  2367. birthDayStr = guestInfo.BirthDay.ToString("yyyy.MM");
  2368. }
  2369. builder.Write(birthDayStr);
  2370. }
  2371. //删除多余行
  2372. while (tableOne.Rows.Count > guestInfos.Count + 1)
  2373. {
  2374. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  2375. }
  2376. var fileDir = AppSettingsHelper.Get("WordBasePath");
  2377. string fileName = $"{groupInfo.TeamName}省外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  2378. string filePath = fileDir + $@"OfficialActivities/{fileName}";
  2379. doc.Save(filePath);
  2380. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  2381. return Ok(JsonView(true, "操作成功!", Url));
  2382. }
  2383. else if (dto.FileType == 2)
  2384. {
  2385. //载入模板
  2386. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示 - 模板.docx";
  2387. var doc = new Document(tempPath);
  2388. DocumentBuilder builder = new DocumentBuilder(doc);
  2389. //键值对存放数据
  2390. Dictionary<string, string> dic = new Dictionary<string, string>();
  2391. //××(组团单位):接团客户信息团组
  2392. dic.Add("GroupClient", $"{groupInfo.ClientUnit}");
  2393. dic.Add("GroupClient1", $"{groupInfo.ClientUnit}");
  2394. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  2395. string guestName = "";
  2396. string guestJob = "";
  2397. string guestInfoStr = "";
  2398. var guestFirstInfo = guestInfos.FirstOrDefault();
  2399. if (guestFirstInfo != null)
  2400. {
  2401. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  2402. guestJob = guestFirstInfo.Job;
  2403. guestInfoStr = $@"{guestJob}、{guestName.Trim()}";
  2404. }
  2405. string reqTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  2406. dic.Add("ReqTitle", reqTitle);
  2407. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。
  2408. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  2409. string reqSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。";
  2410. dic.Add("ReqSubTitle", reqSubTitle);
  2411. /*
  2412. * 出访任务
  2413. * (一)××(国家或地区)
  2414. * 1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:由×××总领馆联合×××市政府共同举办的“×××活动”将于今年6月在×××举行。)
  2415. * 2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研等)×××(项目或机构名称等)。(例:拜会友城×××市市长×××,巩固和发展两市传统友谊,商谈两市未来互动交流合作项目。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:×××年×月,×××市与×××市正式缔结友好城市关系。在此框架下,两市开展了一系列友好互访和商务交流。并于×××年×月共同举办了“×××活动”。)
  2416. *
  2417. */
  2418. string taskStr = string.Empty;
  2419. List<string> countrys = obDatas.Where(it => !string.IsNullOrEmpty(it.Country)).Select(it => it.Country).ToList();
  2420. int countryIndex = 1;
  2421. foreach (var item in countrys)
  2422. {
  2423. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item ?? "[公务出访国家未填写]"}\r\n";
  2424. string taskContent = "";
  2425. if (!string.IsNullOrEmpty(item))
  2426. {
  2427. var countryObDatas = obDatas.Where(it => !string.IsNullOrEmpty(it.Country) && it.Country.Contains(item)).OrderBy(it => it.Date).ToList();
  2428. int obIndex = 1;
  2429. if (countryObDatas.Count == 0) taskContent = "[公务出访未录入]\r\n";
  2430. else
  2431. {
  2432. foreach (var obInfo in countryObDatas)
  2433. {
  2434. taskContent += $"{obIndex}.{obInfo.ReqSample ?? "[公务出访请示范例未填写]"}\r\n背景:{obInfo.Setting ?? "[公务出访背景未填写]"}\r\n";
  2435. obIndex++;
  2436. }
  2437. }
  2438. }
  2439. taskStr += $"{taskTitle}{taskContent}";
  2440. countryIndex++;
  2441. }
  2442. if (string.IsNullOrEmpty(taskStr)) taskStr = "××××××";
  2443. //出访任务
  2444. dic.Add("TaskContent", taskStr);
  2445. //出访目的
  2446. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  2447. //出访信息
  2448. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。出访路线:成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)。
  2449. string tripInfoStr = "";
  2450. tripInfoStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。出访路线:{lineStr}。出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)";
  2451. dic.Add("TripInfo", tripInfoStr);
  2452. #region 填充word模板书签内容
  2453. foreach (var key in dic.Keys)
  2454. {
  2455. builder.MoveToBookmark(key);
  2456. builder.Write(dic[key]);
  2457. }
  2458. #endregion
  2459. //获取word里所有表格
  2460. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2461. //获取所填表格的序数
  2462. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2463. var rowStart = tableOne.Rows[0]; //获取第1行
  2464. //循环赋值
  2465. for (int i = 0; i < guestInfos.Count; i++)
  2466. {
  2467. var guestInfo = guestInfos[i];
  2468. builder.MoveToCell(0, i + 1, 0, 0);
  2469. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  2470. builder.MoveToCell(0, i + 1, 1, 0);
  2471. int sex = guestInfo.Sex;
  2472. string sexStr = string.Empty;
  2473. if (sex == 0) sexStr = "男";
  2474. else if (sex == 1) sexStr = "女";
  2475. else sexStr = "未设置";
  2476. builder.Write(sexStr);
  2477. builder.MoveToCell(0, i + 1, 2, 0);
  2478. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  2479. builder.MoveToCell(0, i + 1, 3, 0);
  2480. DateTime birthDay = guestInfo.BirthDay;
  2481. string birthDayStr = string.Empty;
  2482. if (birthDay != null)
  2483. {
  2484. birthDayStr = birthDay.ToString("yyyy.MM");
  2485. }
  2486. builder.Write(birthDayStr);
  2487. }
  2488. //删除多余行
  2489. while (tableOne.Rows.Count > guestInfos.Count + 1)
  2490. {
  2491. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  2492. }
  2493. var fileDir = AppSettingsHelper.Get("WordBasePath");
  2494. var fileName = $"{groupInfo.TeamName}市外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  2495. var filePath = fileDir + $@"OfficialActivities/{fileName}";
  2496. doc.Save(filePath);
  2497. var url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  2498. return Ok(JsonView(true, "操作成功!", url));
  2499. }
  2500. return Ok(JsonView(true, "操作失败!", ""));
  2501. }
  2502. private string GetToUpperNumber(int num)
  2503. {
  2504. string numStr = "";
  2505. if (num == 1) numStr = "一";
  2506. else if (num == 2) numStr = "二";
  2507. else if (num == 3) numStr = "三";
  2508. else if (num == 4) numStr = "四";
  2509. else if (num == 5) numStr = "五";
  2510. else if (num == 6) numStr = "六";
  2511. else if (num == 7) numStr = "七";
  2512. else if (num == 8) numStr = "八";
  2513. else if (num == 9) numStr = "九";
  2514. else if (num == 10) numStr = "十";
  2515. return numStr;
  2516. }
  2517. [HttpPost]
  2518. public IActionResult ExportOfficialActivitiesInfo(ExportOfficialActivitiesInfoDto dto)
  2519. {
  2520. var jw = JsonView(false);
  2521. if (!ModelState.IsValid)
  2522. {
  2523. jw.Data = ModelState;
  2524. return Ok(jw);
  2525. }
  2526. var startTime_bool = DateTime.TryParse(dto.StartTime, out DateTime startTime_parse);
  2527. var endTime_bool = DateTime.TryParse(dto.EndTime, out DateTime endTime_parse);
  2528. if(startTime_parse > endTime_parse)
  2529. {
  2530. jw.Msg = "开始实际不能大于结束时间!";
  2531. return Ok(jw);
  2532. }
  2533. if (startTime_bool && endTime_bool)
  2534. {
  2535. //处理时间模板
  2536. var Query_DB = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2537. .LeftJoin<Res_OfficialActivities>((a, b) => a.Id == b.DiId && b.IsDel == 0)
  2538. .LeftJoin<Sys_Users>((a, b, c) => b.CreateUserId == c.Id && c.IsDel == 0)
  2539. .Where((a, b, c) => a.IsDel == 0 && a.VisitDate >= startTime_parse && a.VisitDate <= endTime_parse)
  2540. .WhereIF(dto.State != -1, (a, b, c) => b.ConfirmTheInvitation == dto.State)
  2541. .Select((a, b, c) => new
  2542. {
  2543. a.TeamName,
  2544. b.Client,
  2545. b.ConfirmTheInvitation,
  2546. b.Contact,
  2547. ConfirmTheInvitationStr = b.ConfirmTheInvitation == 1 ? "是" : "否",
  2548. b.Date,
  2549. b.Nature,
  2550. c.CnName,
  2551. b.Address,
  2552. b.CreateTime
  2553. })
  2554. .ToList()
  2555. .Where(x=>!x.Client.IsNullOrWhiteSpace())
  2556. .ToList();
  2557. if (Query_DB.Count > 0)
  2558. {
  2559. //打开excel
  2560. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath");
  2561. var fileBasePath = AppSettingsHelper.Get("ExcelBasePath");
  2562. var fileName = "公务出访信息.docx";
  2563. //创建数据源Table
  2564. DataTable dtSource = new DataTable();
  2565. dtSource.TableName = "TB";
  2566. var firstElem = Query_DB.First();
  2567. //遍历firstElem所有属性
  2568. foreach (var item in firstElem.GetType().GetProperties())
  2569. {
  2570. dtSource.Columns.Add(item.Name, item.PropertyType);
  2571. }
  2572. foreach (var item in Query_DB)
  2573. {
  2574. DataRow dr = dtSource.NewRow();
  2575. //遍历dtSource所有列头
  2576. foreach (DataColumn column in dtSource.Columns)
  2577. {
  2578. dr[column.ColumnName] = item.GetType().GetProperty(column.ColumnName)?.GetValue(item)?.ToString();
  2579. }
  2580. dtSource.Rows.Add(dr);
  2581. }
  2582. WorkbookDesigner designer = new WorkbookDesigner();
  2583. designer.Workbook = new Workbook(fileBasePath + ("Template/公务出访信息.xlsx"));
  2584. var title = startTime_parse.ToString("yyyy年MM月dd日") + " - " + endTime_parse.ToString("yyyy年MM月dd日") + " 公务出访信息";
  2585. designer.SetDataSource("title", title);
  2586. designer.SetDataSource(dtSource);
  2587. designer.Process();
  2588. var exportSerevePath = fileBasePath + "ExportOfficialActivitiesInfo/" + title + ".xlsx";
  2589. var exportFtpPaht = ftpPath + "ExportOfficialActivitiesInfo/" + title + ".xlsx";
  2590. //保存文件
  2591. designer.Workbook.Save(exportSerevePath);
  2592. jw.Data = AppSettingsHelper.Get("ExcelBaseUrl") + exportFtpPaht;
  2593. jw.Code = 200;
  2594. jw.Msg = "获取成功!";
  2595. }
  2596. else
  2597. {
  2598. jw.Data = "无公务信息!";
  2599. }
  2600. }
  2601. else
  2602. {
  2603. jw.Data = "时间格式错误!";
  2604. }
  2605. return Ok(jw);
  2606. }
  2607. #endregion
  2608. #region 请示数据库
  2609. /// <summary>
  2610. /// 查询请示数据库初始化
  2611. /// </summary>
  2612. /// <param name="dto"></param>
  2613. /// <returns></returns>
  2614. [HttpPost]
  2615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2616. public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
  2617. {
  2618. Result groupData = await _askDataRep.QueryAskData(dto);
  2619. if (groupData.Code != 0)
  2620. {
  2621. return Ok(JsonView(false, groupData.Msg));
  2622. }
  2623. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2624. }
  2625. /// <summary>
  2626. /// 根据Id查询请示数据库单条数据
  2627. /// </summary>
  2628. /// <param name="dto"></param>
  2629. /// <returns></returns>
  2630. [HttpPost]
  2631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2632. public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
  2633. {
  2634. Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
  2635. if (_AskData == null)
  2636. {
  2637. return Ok(JsonView(true, "暂无数据!", _AskData));
  2638. }
  2639. return Ok(JsonView(true, "查询成功!", _AskData));
  2640. }
  2641. /// <summary>
  2642. /// 请示数据库操作(Status:1.新增,2.修改)
  2643. /// </summary>
  2644. /// <param name="dto"></param>
  2645. /// <returns></returns>
  2646. [HttpPost]
  2647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2648. public async Task<IActionResult> OpAskData(OpAskDataDto dto)
  2649. {
  2650. Result groupData = await _askDataRep.OpAskData(dto);
  2651. if (groupData.Code != 0)
  2652. {
  2653. return Ok(JsonView(false, groupData.Msg));
  2654. }
  2655. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2656. }
  2657. /// <summary>
  2658. /// 删除请示资料信息
  2659. /// </summary>
  2660. /// <param name="dto"></param>
  2661. /// <returns></returns>
  2662. [HttpPost]
  2663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2664. public async Task<IActionResult> DelAskData(DelBaseDto dto)
  2665. {
  2666. var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
  2667. if (!res)
  2668. {
  2669. return Ok(JsonView(false, "删除失败"));
  2670. }
  2671. return Ok(JsonView(true, "删除成功!"));
  2672. }
  2673. /// <summary>
  2674. /// 请示资料信息
  2675. /// 省外办下载
  2676. /// </summary>
  2677. /// <param name="dto"></param>
  2678. /// <returns></returns>
  2679. [HttpPost]
  2680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2681. public async Task<IActionResult> AskDataProvinceFAOPFile(AskDataProvinceFileDto dto)
  2682. {
  2683. if (dto.DataIdItem.Length < 1) return Ok(JsonView(false,$"请传入有效的数据Id集合!"));
  2684. if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
  2685. //大写数字序号
  2686. string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
  2687. "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
  2688. "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
  2689. "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
  2690. //数据源
  2691. var idItem = dto.DataIdItem.OrderBy(x => x);
  2692. var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
  2693. //书签名
  2694. string Area = "",
  2695. Official = "";
  2696. //表格数据源
  2697. DataTable dt = new DataTable();
  2698. dt.Columns.Add("Country", typeof(string));
  2699. dt.Columns.Add("TalkCase", typeof(string));
  2700. int id = 0;
  2701. int TalkcaseOrder = 0;
  2702. int RowOrder = 0;
  2703. //填充数据
  2704. for (int i = 0; i < askDatas.Count; i++)
  2705. {
  2706. var ad = askDatas[i];
  2707. Area = Area + ad.Country + ad.Area + "、";
  2708. Official = Official + ad.UnitName + "、";
  2709. //填充表格数据源
  2710. DataRow dr = dt.NewRow();
  2711. if (i > 0)
  2712. {
  2713. var adtemp = askDatas[i - 1];
  2714. if (ad.Country == adtemp.Country)
  2715. {
  2716. TalkcaseOrder++;
  2717. dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
  2718. }
  2719. else
  2720. {
  2721. RowOrder++;
  2722. dr = dt.NewRow();
  2723. dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
  2724. dr["TalkCase"] = "1、" + ad.TalkCase;
  2725. dt.Rows.Add(dr);
  2726. TalkcaseOrder = 0;
  2727. }
  2728. }
  2729. else
  2730. {
  2731. dr["Country"] = "(" + num[i] + ")" + ad.Country;
  2732. dr["TalkCase"] = "1、" + ad.TalkCase;
  2733. dt.Rows.Add(dr);
  2734. }
  2735. id = ad.Id;
  2736. }
  2737. //模板路径
  2738. var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示模板.doc";
  2739. //载入模板
  2740. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  2741. #region 填充word内容
  2742. #region 填充请示内容
  2743. //利用DocumentBuilder处理表格或是书签
  2744. Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
  2745. string bookmark = "";
  2746. try
  2747. {
  2748. for (int i = 0; i < dt.Rows.Count; i++)
  2749. {
  2750. bookmark = bookmark
  2751. + dt.Rows[i]["Country"].ToString() + "\r\n"
  2752. + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
  2753. }
  2754. }
  2755. catch
  2756. {
  2757. }
  2758. #endregion
  2759. #region 填充word模板书签内容
  2760. //团组信息
  2761. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
  2762. //接团客户名单实例
  2763. string client_sql = string.Format(@"
  2764. SELECT
  2765. tcl.Id,
  2766. tcl.DiId,
  2767. tcl.IsAccompany,
  2768. temp.*,
  2769. u.CnName AS Operator,
  2770. tcl.CreateTime AS OperatingTime
  2771. FROM
  2772. Grp_TourClientList tcl
  2773. LEFT JOIN (
  2774. SELECT
  2775. dc.Id AS DcId,
  2776. dc.LastName,
  2777. dc.FirstName,
  2778. ccom.CompanyFullName,
  2779. dc.Job,
  2780. cc.CertNo AS IDCardNo,
  2781. dc.Sex,
  2782. dc.BirthDay
  2783. FROM
  2784. Crm_DeleClient dc
  2785. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  2786. AND ccom.IsDel = 0
  2787. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  2788. AND cc.SdId = 773
  2789. AND cc.IsDel = 0
  2790. WHERE
  2791. dc.IsDel = 0
  2792. ) temp ON temp.DcId = tcl.ClientId
  2793. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  2794. WHERE
  2795. tcl.IsDel = 0
  2796. AND tcl.DiId = {0}", dto.DiId);
  2797. var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
  2798. //机票代码实例
  2799. DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
  2800. //三字码
  2801. var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0 ).ToListAsync();
  2802. //团名
  2803. if (doc.Range.Bookmarks["TeamName"] != null)
  2804. {
  2805. Bookmark mark = doc.Range.Bookmarks["TeamName"];
  2806. mark.Text = di.TeamName;
  2807. }
  2808. //团长名
  2809. if (doc.Range.Bookmarks["ClientName2"] != null)
  2810. {
  2811. Bookmark mark = doc.Range.Bookmarks["ClientName2"];
  2812. if (clientList == null || clientList.Count == 0)
  2813. {
  2814. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  2815. }
  2816. else
  2817. {
  2818. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  2819. }
  2820. }
  2821. if (doc.Range.Bookmarks["ClientName"] != null)
  2822. {
  2823. Bookmark mark = doc.Range.Bookmarks["ClientName"];
  2824. if (clientList == null || clientList.Count == 0)
  2825. {
  2826. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  2827. }
  2828. else
  2829. {
  2830. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  2831. }
  2832. }
  2833. //跟团人数
  2834. if (doc.Range.Bookmarks["ClientNumber2"] != null)
  2835. {
  2836. Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
  2837. mark.Text = di.VisitPNumber.ToString();
  2838. }
  2839. if (doc.Range.Bookmarks["ClientNumber"] != null)
  2840. {
  2841. Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
  2842. mark.Text = di.VisitPNumber.ToString();
  2843. }
  2844. //地区
  2845. if (doc.Range.Bookmarks["Area"] != null)
  2846. {
  2847. Bookmark mark = doc.Range.Bookmarks["Area"];
  2848. mark.Text = Area.TrimEnd('、');
  2849. }
  2850. if (doc.Range.Bookmarks["Area2"] != null)
  2851. {
  2852. Bookmark mark = doc.Range.Bookmarks["Area2"];
  2853. mark.Text = Area.TrimEnd('、');
  2854. }
  2855. //出访目的
  2856. if (doc.Range.Bookmarks["Destination2"] != null)
  2857. {
  2858. Bookmark mark = doc.Range.Bookmarks["Destination2"];
  2859. mark.Text = di.VisitPurpose;
  2860. }
  2861. if (doc.Range.Bookmarks["Destination"] != null)
  2862. {
  2863. Bookmark mark = doc.Range.Bookmarks["Destination"];
  2864. mark.Text = di.VisitPurpose;
  2865. }
  2866. //邀请方
  2867. if (doc.Range.Bookmarks["Official"] != null)
  2868. {
  2869. Bookmark mark = doc.Range.Bookmarks["Official"];
  2870. mark.Text = Official.TrimEnd('、');
  2871. }
  2872. //出访日期
  2873. if (doc.Range.Bookmarks["VisitDate"] != null)
  2874. {
  2875. Bookmark mark = doc.Range.Bookmarks["VisitDate"];
  2876. mark.Text = di.VisitStartDate.Year + "年"
  2877. + di.VisitStartDate.Month + "月"
  2878. + di.VisitStartDate.Day + "日"
  2879. + "至"
  2880. + di.VisitEndDate.Month + "月"
  2881. + di.VisitEndDate.Day + "日";
  2882. }
  2883. //请示范例
  2884. if (doc.Range.Bookmarks["Temp"] != null)
  2885. {
  2886. Bookmark mark = doc.Range.Bookmarks["Temp"];
  2887. mark.Text = bookmark;
  2888. }
  2889. //出访起止日期
  2890. if (doc.Range.Bookmarks["Duration"] != null)
  2891. {
  2892. Bookmark mark = doc.Range.Bookmarks["Duration"];
  2893. mark.Text = di.VisitStartDate.Year + "年"
  2894. + di.VisitStartDate.Month + "月"
  2895. + di.VisitStartDate.Day + "日"
  2896. + "至"
  2897. + di.VisitEndDate.Month + "月"
  2898. + di.VisitEndDate.Day + "日";
  2899. }
  2900. //出访天数
  2901. if (doc.Range.Bookmarks["Durationdays"] != null)
  2902. {
  2903. Bookmark mark = doc.Range.Bookmarks["Durationdays"];
  2904. mark.Text = di.VisitDays.ToString();
  2905. }
  2906. if (doc.Range.Bookmarks["Durationdays2"] != null)
  2907. {
  2908. Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
  2909. mark.Text = di.VisitDays.ToString();
  2910. }
  2911. #region 根据黑屏代码获取国家呆的天数;获取路线
  2912. string result_CountryAndDay = "", result_Air = "";
  2913. if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
  2914. {
  2915. result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
  2916. result_Air = result_CountryAndDay;
  2917. }
  2918. else
  2919. {
  2920. string place_start, place_end;
  2921. DateTime time_start, time_end;
  2922. Res_ThreeCode three = null;
  2923. for (int i = 0; i < airTable.Rows.Count; i++)
  2924. {
  2925. //三字码实例
  2926. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
  2927. if (three == null)
  2928. {
  2929. place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  2930. }
  2931. else
  2932. {
  2933. if (string.IsNullOrEmpty(three.Country))
  2934. {
  2935. place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  2936. }
  2937. else
  2938. {
  2939. place_start = three.City;
  2940. }
  2941. }
  2942. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
  2943. if (three == null)
  2944. {
  2945. place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  2946. }
  2947. else
  2948. {
  2949. if (string.IsNullOrEmpty(three.Country))
  2950. {
  2951. place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  2952. }
  2953. else
  2954. {
  2955. place_end = three.City;
  2956. }
  2957. }
  2958. result_Air += place_start + "一" + place_end + "一";
  2959. //获取国家和呆的天数
  2960. if (i > 0 && i < airTable.Rows.Count - 1)
  2961. {
  2962. time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
  2963. time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
  2964. TimeSpan daycount = time_end.Subtract(time_start);
  2965. result_CountryAndDay += place_start + daycount.Days + "天" + ",";
  2966. }
  2967. }
  2968. }
  2969. #endregion
  2970. //每个国家呆的天数
  2971. if (doc.Range.Bookmarks["CountryAndDay"] != null)
  2972. {
  2973. Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
  2974. mark.Text = result_CountryAndDay.TrimEnd(',');
  2975. }
  2976. #region 出访路线城市字符串去重
  2977. result_Air = result_Air.TrimEnd('一');
  2978. string[] airTemp = result_Air.Split('一');
  2979. airTemp = airTemp.Distinct().ToArray();
  2980. result_Air = "";
  2981. foreach (string str in airTemp)
  2982. {
  2983. result_Air += str + "一";
  2984. }
  2985. result_Air = result_Air + airTemp[0];
  2986. #endregion
  2987. //出访路线
  2988. if (doc.Range.Bookmarks["Air"] != null)
  2989. {
  2990. Bookmark mark = doc.Range.Bookmarks["Air"];
  2991. mark.Text = result_Air;
  2992. }
  2993. #endregion
  2994. #region 客户名单
  2995. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2996. Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
  2997. if (clientList == null || clientList.Count == 0)
  2998. {
  2999. builder.MoveToCell(0, 1, 0, 0);
  3000. builder.Write("【本团尚未录入客户名单,请联系主管!】");
  3001. }
  3002. else
  3003. {
  3004. for (int i = 0; i < clientList.Count(); i++)
  3005. {
  3006. builder.MoveToCell(0, i + 1, 0, 0);
  3007. builder.Write((i + 1).ToString());
  3008. builder.MoveToCell(0, i + 1, 1, 0);
  3009. builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
  3010. builder.MoveToCell(0, i + 1, 2, 0);
  3011. builder.Write(clientList[i].Sex.ToString());
  3012. builder.MoveToCell(0, i + 1, 3, 0);
  3013. builder.Write(clientList[i].BirthDay);
  3014. builder.MoveToCell(0, i + 1, 4, 0);
  3015. builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
  3016. }
  3017. }
  3018. while (tableClient.Rows.Count > clientList.Count + 1)
  3019. {
  3020. tableClient.Rows.RemoveAt(clientList.Count + 1);
  3021. }
  3022. #endregion
  3023. #region 商邀行程
  3024. string content = "", temp1 = "", temp2 = "";
  3025. //获取数据,放到datatable
  3026. var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
  3027. .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
  3028. .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
  3029. .Select((at, atd) => new
  3030. {
  3031. at.Id,
  3032. at.Date,
  3033. atd.Time,
  3034. atd.Details
  3035. })
  3036. .ToListAsync();
  3037. if (listapt == null || listapt.Count == 0)
  3038. {
  3039. content = "尚未生成商邀行程";
  3040. }
  3041. else
  3042. {
  3043. for (int i = 0; i < listapt.Count; i++)
  3044. {
  3045. content = content + " " + listapt[i].Date + "\r\n";
  3046. temp1 = listapt[i].Time;
  3047. temp2 = listapt[i].Details;
  3048. if (!string.IsNullOrEmpty(temp1))
  3049. {
  3050. string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3051. string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3052. for (int j = 0; j < str.Count(); j++)
  3053. {
  3054. content = content + " " + str[j] + str2[j] + "\r\n";
  3055. }
  3056. }
  3057. }
  3058. }
  3059. if (doc.Range.Bookmarks["Content"] != null)
  3060. {
  3061. Bookmark mark = doc.Range.Bookmarks["Content"];
  3062. mark.Text = content;
  3063. }
  3064. while (tableClient.Rows.Count > 1 + clientList.Count)
  3065. {
  3066. tableClient.Rows.RemoveAt(1 + clientList.Count);
  3067. }
  3068. #endregion
  3069. #endregion
  3070. string strFileName = $"/AskData/省外办出访请示{Guid.NewGuid().ToString()}.doc";
  3071. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  3072. var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  3073. return Ok(JsonView(true,"操作成功!",new { url = url }));
  3074. }
  3075. /// <summary>
  3076. /// 请示资料信息
  3077. /// 市外办下载
  3078. /// </summary>
  3079. /// <param name="dto"></param>
  3080. /// <returns></returns>
  3081. [HttpPost]
  3082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3083. public async Task<IActionResult> AskDataCityFAOPFile(AskDataProvinceFileDto dto)
  3084. {
  3085. if (dto.DataIdItem.Length < 1) return Ok(JsonView(false, $"请传入有效的数据Id集合!"));
  3086. if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
  3087. //大写数字序号
  3088. string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
  3089. "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
  3090. "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
  3091. "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
  3092. //数据源
  3093. var idItem = dto.DataIdItem.OrderBy(x => x);
  3094. var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
  3095. //书签名
  3096. string Area = "",
  3097. Official = "";
  3098. //表格数据源
  3099. DataTable dt = new DataTable();
  3100. dt.Columns.Add("Country", typeof(string));
  3101. dt.Columns.Add("TalkCase", typeof(string));
  3102. int id = 0;
  3103. int TalkcaseOrder = 0;
  3104. int RowOrder = 0;
  3105. //填充数据
  3106. for (int i = 0; i < askDatas.Count; i++)
  3107. {
  3108. var ad = askDatas[i];
  3109. Area = Area + ad.Country + ad.Area + "、";
  3110. Official = Official + ad.UnitName + "、";
  3111. //填充表格数据源
  3112. DataRow dr = dt.NewRow();
  3113. if (i > 0)
  3114. {
  3115. var adtemp = askDatas[i - 1];
  3116. if (ad.Country == adtemp.Country)
  3117. {
  3118. TalkcaseOrder++;
  3119. dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
  3120. }
  3121. else
  3122. {
  3123. RowOrder++;
  3124. dr = dt.NewRow();
  3125. dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
  3126. dr["TalkCase"] = "1、" + ad.TalkCase;
  3127. dt.Rows.Add(dr);
  3128. TalkcaseOrder = 0;
  3129. }
  3130. }
  3131. else
  3132. {
  3133. dr["Country"] = "(" + num[i] + ")" + ad.Country;
  3134. dr["TalkCase"] = "1、" + ad.TalkCase;
  3135. dt.Rows.Add(dr);
  3136. }
  3137. id = ad.Id;
  3138. }
  3139. //模板路径
  3140. var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示.doc";
  3141. //载入模板
  3142. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  3143. #region 填充word内容
  3144. #region 填充请示内容
  3145. //利用DocumentBuilder处理表格或是书签
  3146. Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
  3147. string bookmark = "";
  3148. try
  3149. {
  3150. for (int i = 0; i < dt.Rows.Count; i++)
  3151. {
  3152. bookmark = bookmark
  3153. + dt.Rows[i]["Country"].ToString() + "\r\n"
  3154. + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
  3155. }
  3156. }
  3157. catch
  3158. {
  3159. }
  3160. #endregion
  3161. #region 填充word模板书签内容
  3162. //团组信息
  3163. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
  3164. //接团客户名单实例
  3165. string client_sql = string.Format(@"
  3166. SELECT
  3167. tcl.Id,
  3168. tcl.DiId,
  3169. tcl.IsAccompany,
  3170. temp.*,
  3171. u.CnName AS Operator,
  3172. tcl.CreateTime AS OperatingTime
  3173. FROM
  3174. Grp_TourClientList tcl
  3175. LEFT JOIN (
  3176. SELECT
  3177. dc.Id AS DcId,
  3178. dc.LastName,
  3179. dc.FirstName,
  3180. ccom.CompanyFullName,
  3181. dc.Job,
  3182. cc.CertNo AS IDCardNo,
  3183. dc.Sex,
  3184. dc.BirthDay
  3185. FROM
  3186. Crm_DeleClient dc
  3187. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  3188. AND ccom.IsDel = 0
  3189. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  3190. AND cc.SdId = 773
  3191. AND cc.IsDel = 0
  3192. WHERE
  3193. dc.IsDel = 0
  3194. ) temp ON temp.DcId = tcl.ClientId
  3195. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  3196. WHERE
  3197. tcl.IsDel = 0
  3198. AND tcl.DiId = {0}", dto.DiId);
  3199. var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
  3200. //机票代码实例
  3201. DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
  3202. //三字码
  3203. var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
  3204. //团名
  3205. if (doc.Range.Bookmarks["TeamName"] != null)
  3206. {
  3207. Bookmark mark = doc.Range.Bookmarks["TeamName"];
  3208. mark.Text = di.TeamName;
  3209. }
  3210. //团长名
  3211. if (doc.Range.Bookmarks["ClientName2"] != null)
  3212. {
  3213. Bookmark mark = doc.Range.Bookmarks["ClientName2"];
  3214. if (clientList == null || clientList.Count == 0)
  3215. {
  3216. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  3217. }
  3218. else
  3219. {
  3220. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  3221. }
  3222. }
  3223. if (doc.Range.Bookmarks["ClientName"] != null)
  3224. {
  3225. Bookmark mark = doc.Range.Bookmarks["ClientName"];
  3226. if (clientList == null || clientList.Count == 0)
  3227. {
  3228. mark.Text = "【本团尚未录入客户名单,请联系主管!】";
  3229. }
  3230. else
  3231. {
  3232. mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
  3233. }
  3234. }
  3235. //跟团人数
  3236. if (doc.Range.Bookmarks["ClientNumber2"] != null)
  3237. {
  3238. Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
  3239. mark.Text = di.VisitPNumber.ToString();
  3240. }
  3241. if (doc.Range.Bookmarks["ClientNumber"] != null)
  3242. {
  3243. Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
  3244. mark.Text = di.VisitPNumber.ToString();
  3245. }
  3246. //地区
  3247. if (doc.Range.Bookmarks["Area"] != null)
  3248. {
  3249. Bookmark mark = doc.Range.Bookmarks["Area"];
  3250. mark.Text = Area.TrimEnd('、');
  3251. }
  3252. if (doc.Range.Bookmarks["Area2"] != null)
  3253. {
  3254. Bookmark mark = doc.Range.Bookmarks["Area2"];
  3255. mark.Text = Area.TrimEnd('、');
  3256. }
  3257. //出访目的
  3258. if (doc.Range.Bookmarks["Destination2"] != null)
  3259. {
  3260. Bookmark mark = doc.Range.Bookmarks["Destination2"];
  3261. mark.Text = di.VisitPurpose;
  3262. }
  3263. if (doc.Range.Bookmarks["Destination"] != null)
  3264. {
  3265. Bookmark mark = doc.Range.Bookmarks["Destination"];
  3266. mark.Text = di.VisitPurpose;
  3267. }
  3268. //邀请方
  3269. if (doc.Range.Bookmarks["Official"] != null)
  3270. {
  3271. Bookmark mark = doc.Range.Bookmarks["Official"];
  3272. mark.Text = Official.TrimEnd('、');
  3273. }
  3274. //出访日期
  3275. if (doc.Range.Bookmarks["VisitDate"] != null)
  3276. {
  3277. Bookmark mark = doc.Range.Bookmarks["VisitDate"];
  3278. mark.Text = di.VisitStartDate.Year + "年"
  3279. + di.VisitStartDate.Month + "月"
  3280. + di.VisitStartDate.Day + "日"
  3281. + "至"
  3282. + di.VisitEndDate.Month + "月"
  3283. + di.VisitEndDate.Day + "日";
  3284. }
  3285. //请示范例
  3286. if (doc.Range.Bookmarks["Temp"] != null)
  3287. {
  3288. Bookmark mark = doc.Range.Bookmarks["Temp"];
  3289. mark.Text = bookmark;
  3290. }
  3291. //出访起止日期
  3292. if (doc.Range.Bookmarks["Duration"] != null)
  3293. {
  3294. Bookmark mark = doc.Range.Bookmarks["Duration"];
  3295. mark.Text = di.VisitStartDate.Year + "年"
  3296. + di.VisitStartDate.Month + "月"
  3297. + di.VisitStartDate.Day + "日"
  3298. + "至"
  3299. + di.VisitEndDate.Month + "月"
  3300. + di.VisitEndDate.Day + "日";
  3301. }
  3302. //出访天数
  3303. if (doc.Range.Bookmarks["Durationdays"] != null)
  3304. {
  3305. Bookmark mark = doc.Range.Bookmarks["Durationdays"];
  3306. mark.Text = di.VisitDays.ToString();
  3307. }
  3308. if (doc.Range.Bookmarks["Durationdays2"] != null)
  3309. {
  3310. Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
  3311. mark.Text = di.VisitDays.ToString();
  3312. }
  3313. #region 根据黑屏代码获取国家呆的天数;获取路线
  3314. string result_CountryAndDay = "", result_Air = "";
  3315. if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
  3316. {
  3317. result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
  3318. result_Air = result_CountryAndDay;
  3319. }
  3320. else
  3321. {
  3322. string place_start, place_end;
  3323. DateTime time_start, time_end;
  3324. Res_ThreeCode three = null;
  3325. for (int i = 0; i < airTable.Rows.Count; i++)
  3326. {
  3327. //三字码实例
  3328. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
  3329. if (three == null)
  3330. {
  3331. place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  3332. }
  3333. else
  3334. {
  3335. if (string.IsNullOrEmpty(three.Country))
  3336. {
  3337. place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  3338. }
  3339. else
  3340. {
  3341. place_start = three.City;
  3342. }
  3343. }
  3344. three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
  3345. if (three == null)
  3346. {
  3347. place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
  3348. }
  3349. else
  3350. {
  3351. if (string.IsNullOrEmpty(three.Country))
  3352. {
  3353. place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
  3354. }
  3355. else
  3356. {
  3357. place_end = three.City;
  3358. }
  3359. }
  3360. result_Air += place_start + "一" + place_end + "一";
  3361. //获取国家和呆的天数
  3362. if (i > 0 && i < airTable.Rows.Count - 1)
  3363. {
  3364. time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
  3365. time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
  3366. TimeSpan daycount = time_end.Subtract(time_start);
  3367. result_CountryAndDay += place_start + daycount.Days + "天" + ",";
  3368. }
  3369. }
  3370. }
  3371. #endregion
  3372. //每个国家呆的天数
  3373. if (doc.Range.Bookmarks["CountryAndDay"] != null)
  3374. {
  3375. Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
  3376. mark.Text = result_CountryAndDay.TrimEnd(',');
  3377. }
  3378. #region 出访路线城市字符串去重
  3379. result_Air = result_Air.TrimEnd('一');
  3380. string[] airTemp = result_Air.Split('一');
  3381. airTemp = airTemp.Distinct().ToArray();
  3382. result_Air = "";
  3383. foreach (string str in airTemp)
  3384. {
  3385. result_Air += str + "一";
  3386. }
  3387. result_Air = result_Air + airTemp[0];
  3388. #endregion
  3389. //出访路线
  3390. if (doc.Range.Bookmarks["Air"] != null)
  3391. {
  3392. Bookmark mark = doc.Range.Bookmarks["Air"];
  3393. mark.Text = result_Air;
  3394. }
  3395. #endregion
  3396. #region 客户名单
  3397. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3398. Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
  3399. if (clientList == null || clientList.Count == 0)
  3400. {
  3401. builder.MoveToCell(0, 1, 0, 0);
  3402. builder.Write("【本团尚未录入客户名单,请联系主管!】");
  3403. }
  3404. else
  3405. {
  3406. for (int i = 0; i < clientList.Count(); i++)
  3407. {
  3408. builder.MoveToCell(0, i + 1, 0, 0);
  3409. builder.Write((i + 1).ToString());
  3410. builder.MoveToCell(0, i + 1, 1, 0);
  3411. builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
  3412. builder.MoveToCell(0, i + 1, 2, 0);
  3413. builder.Write(clientList[i].Sex.ToString());
  3414. builder.MoveToCell(0, i + 1, 3, 0);
  3415. builder.Write(clientList[i].BirthDay);
  3416. builder.MoveToCell(0, i + 1, 4, 0);
  3417. builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
  3418. }
  3419. }
  3420. while (tableClient.Rows.Count > clientList.Count + 1)
  3421. {
  3422. tableClient.Rows.RemoveAt(clientList.Count + 1);
  3423. }
  3424. #endregion
  3425. #region 商邀行程
  3426. string content = "", temp1 = "", temp2 = "";
  3427. //获取数据,放到datatable
  3428. var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
  3429. .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
  3430. .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
  3431. .Select((at, atd) => new
  3432. {
  3433. at.Id,
  3434. at.Date,
  3435. atd.Time,
  3436. atd.Details
  3437. })
  3438. .ToListAsync();
  3439. if (listapt == null || listapt.Count == 0)
  3440. {
  3441. content = "尚未生成商邀行程";
  3442. }
  3443. else
  3444. {
  3445. for (int i = 0; i < listapt.Count; i++)
  3446. {
  3447. content = content + " " + listapt[i].Date + "\r\n";
  3448. temp1 = listapt[i].Time;
  3449. temp2 = listapt[i].Details;
  3450. if (!string.IsNullOrEmpty(temp1))
  3451. {
  3452. string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3453. string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3454. for (int j = 0; j < str.Count(); j++)
  3455. {
  3456. content = content + " " + str[j] + str2[j] + "\r\n";
  3457. }
  3458. }
  3459. }
  3460. }
  3461. if (doc.Range.Bookmarks["Content"] != null)
  3462. {
  3463. Bookmark mark = doc.Range.Bookmarks["Content"];
  3464. mark.Text = content;
  3465. }
  3466. while (tableClient.Rows.Count > 1 + clientList.Count)
  3467. {
  3468. tableClient.Rows.RemoveAt(1 + clientList.Count);
  3469. }
  3470. #endregion
  3471. #endregion
  3472. string strFileName = $"/AskData/市外办出访请示{Guid.NewGuid().ToString()}.doc";
  3473. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  3474. var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  3475. return Ok(JsonView(true, "操作成功!", new { url = url }));
  3476. }
  3477. #endregion
  3478. #region 机票黑屏代码
  3479. /// <summary>
  3480. /// 根据团组Id查询黑屏代码列表
  3481. /// </summary>
  3482. /// <param name="dto"></param>
  3483. /// <returns></returns>
  3484. [HttpPost]
  3485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3486. public async Task<IActionResult> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
  3487. {
  3488. try
  3489. {
  3490. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(dto);
  3491. if (groupData.Code != 0)
  3492. {
  3493. return Ok(JsonView(false, groupData.Msg));
  3494. }
  3495. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3496. }
  3497. catch (Exception ex)
  3498. {
  3499. return Ok(JsonView(false, "程序错误!"));
  3500. throw;
  3501. }
  3502. }
  3503. /// <summary>
  3504. /// 根据黑屏代码数据Id查询信息
  3505. /// </summary>
  3506. /// <param name="dto"></param>
  3507. /// <returns></returns>
  3508. [HttpPost]
  3509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3510. public async Task<IActionResult> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
  3511. {
  3512. try
  3513. {
  3514. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(dto);
  3515. if (groupData.Code != 0)
  3516. {
  3517. return Ok(JsonView(false, groupData.Msg));
  3518. }
  3519. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3520. }
  3521. catch (Exception ex)
  3522. {
  3523. return Ok(JsonView(false, "程序错误!"));
  3524. throw;
  3525. }
  3526. }
  3527. /// <summary>
  3528. /// 黑屏代码操作(Status:1.新增,2.修改)
  3529. /// </summary>
  3530. /// <param name="dto"></param>
  3531. /// <returns></returns>
  3532. [HttpPost]
  3533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3534. public async Task<IActionResult> OpTicketBlackCode(OpTicketBlackCodeDto dto)
  3535. {
  3536. Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(dto);
  3537. if (groupData.Code != 0)
  3538. {
  3539. return Ok(JsonView(false, groupData.Msg));
  3540. }
  3541. try
  3542. {
  3543. var tongzhi = _ticketBlackCodeRep.DescBlackToVisa(dto.DiId);
  3544. if (tongzhi.Code == 0)
  3545. {
  3546. var info = tongzhi.Data.GetType().GetProperty("info").GetValue(tongzhi.Data) as List<string>;
  3547. var data = tongzhi.Data.GetType().GetProperty("data").GetValue(tongzhi.Data) as List<CountryDataTime>;
  3548. if (data != null)
  3549. await AppNoticeLibrary.SendUserMsg_blackAirInfo_ToVisaUser(dto.DiId, data);
  3550. }
  3551. //行程代码变更通知
  3552. await AppNoticeLibrary.SendUserMsg_GroupShare_ToDP(dto.DiId, dto.CreateUserId);
  3553. }
  3554. catch (Exception ex)
  3555. {
  3556. throw;
  3557. }
  3558. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3559. }
  3560. /// <summary>
  3561. /// 删除黑屏代码
  3562. /// </summary>
  3563. /// <param name="dto"></param>
  3564. /// <returns></returns>
  3565. [HttpPost]
  3566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3567. public async Task<IActionResult> DelTicketBlackCode(DelBaseDto dto)
  3568. {
  3569. try
  3570. {
  3571. var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync<Air_TicketBlackCode>(dto.Id.ToString(), dto.DeleteUserId);
  3572. if (!res)
  3573. {
  3574. return Ok(JsonView(false, "删除失败"));
  3575. }
  3576. return Ok(JsonView(true, "删除成功!"));
  3577. }
  3578. catch (Exception ex)
  3579. {
  3580. return Ok(JsonView(false, "程序错误!"));
  3581. throw;
  3582. }
  3583. }
  3584. #endregion
  3585. #region 翻译人员
  3586. /// <summary>
  3587. /// 翻译人员库
  3588. /// Init
  3589. /// </summary>
  3590. /// <param name="id"></param>
  3591. /// <returns></returns>
  3592. [HttpGet()]
  3593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3594. public async Task<IActionResult> TranslatorLibraryInit()
  3595. {
  3596. var currencyData = await _sqlSugar.Queryable<Sys_SetData>()
  3597. .Where(x => x.IsDel == 0 && x.STid == 66)
  3598. .Select(x => new {
  3599. x.Id,
  3600. x.Name,
  3601. })
  3602. .ToListAsync();
  3603. var officialDutyData = await _sqlSugar.Queryable<Res_OfficialActivities>()
  3604. .LeftJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  3605. .Where((oa, di) => oa.IsDel == 0)
  3606. .Select((oa, di) => new
  3607. {
  3608. oa.Id,
  3609. oa.Client,
  3610. oa.DiId,
  3611. di.TeamName
  3612. })
  3613. .ToListAsync();
  3614. var officialDutyData1 = officialDutyData.GroupBy(x => x.DiId)
  3615. .Select(g => new {
  3616. id = g.Key,
  3617. label = g.FirstOrDefault()?.TeamName ?? "-",
  3618. children = g.Select(g1 => new { id = g1.Id, label = g1.Client }).ToList()
  3619. })
  3620. .ToList();
  3621. var view = new {
  3622. currencyData = currencyData,
  3623. officialDutyData = officialDutyData1
  3624. };
  3625. return Ok(JsonView(view));
  3626. }
  3627. /// <summary>
  3628. /// 翻译人员库
  3629. /// 详情
  3630. /// </summary>
  3631. /// <param name="id"></param>
  3632. /// <returns></returns>
  3633. [HttpGet("id")]
  3634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3635. public async Task<IActionResult> TranslatorLibraryInfo(int id)
  3636. {
  3637. if (id <1 ) return Ok(JsonView(false,"请传入有效的Id!"));
  3638. var info = await _translatorRep.Query(x => x.Id == id).FirstAsync();
  3639. EncryptionProcessor.DecryptProperties(info);
  3640. var view = _mapper.Map<TranslatorLibraryInfoView>(info);
  3641. //var data1 = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>().Where(x => x.TranslatorId == id).Select(x => x.Id).ToArrayAsync();
  3642. view.OfficialDutyIdItem = await _sqlSugar
  3643. .Queryable<Grp_OfficialDutyLinkTranslator>()
  3644. .Where(x => x.IsDel == 0 && x.TranslatorId == id)
  3645. .Select(x => x.OfficialDutyId)
  3646. .ToArrayAsync();
  3647. return Ok(JsonView(view));
  3648. }
  3649. /// <summary>
  3650. /// 翻译人员库
  3651. /// Item
  3652. /// </summary>
  3653. /// <param name="dto"></param>
  3654. /// <returns></returns>
  3655. [HttpPost]
  3656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3657. public async Task<IActionResult> TranslatorLibraryItem(TranslatorLibraryItemDto dto)
  3658. {
  3659. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3660. var name = AesEncryptionHelper.Encrypt(dto.Name);
  3661. RefAsync<int> total = 0;
  3662. var view = await _sqlSugar.Queryable<Res_TranslatorLibrary>()
  3663. .Where(x => x.IsDel == 0)
  3664. .WhereIF(!string.IsNullOrEmpty(name), x => x.Name.Contains(name))
  3665. .Select(x => new TranslatorLibraryItemView()
  3666. {
  3667. Id = x.Id,
  3668. Area = x.Area,
  3669. Name = x.Name,
  3670. Sex = x.Sex == 0 ? "未设置" : x.Sex == 1 ? "男" : "女",
  3671. Tel = x.Tel,
  3672. Email = x.Email,
  3673. WechatNo = x.WechatNo,
  3674. Language = x.Language,
  3675. Price = x.Price,
  3676. Currency = SqlFunc.Subqueryable<Sys_SetData>().Where(x1 => x1.Id == x.Currency).Select(x1 => x1.Name) ?? "-",
  3677. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x1.Id == x.CreateUserId).Select(x1 => x1.CnName) ?? "-",
  3678. CreateTime = x.CreateTime,
  3679. Remark = x.Remark
  3680. })
  3681. .OrderByDescending(x => x.CreateTime)
  3682. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  3683. foreach (var item in view) EncryptionProcessor.DecryptProperties(item);
  3684. return Ok(JsonView(view, total));
  3685. }
  3686. /// <summary>
  3687. /// 翻译人员库
  3688. /// OP
  3689. /// </summary>
  3690. /// <param name="dto"></param>
  3691. /// <returns></returns>
  3692. [HttpPost]
  3693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3694. public async Task<IActionResult> TranslatorLibraryOp([FromForm]TranslatorLibraryOpDto dto)
  3695. {
  3696. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3697. if (dto.Status < 1 || dto.Status > 2) return Ok(JsonView(false, MsgTips.Status));
  3698. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  3699. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  3700. var fileNames = new List<string>();
  3701. //D:\FTP\File\OA2023\Office\GrpFile\TranslatorLibrary
  3702. var fileBasePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}TranslatorLibrary";
  3703. #region 保存文件
  3704. if (dto.Files != null)
  3705. {
  3706. if (!System.IO.Directory.Exists(fileBasePath))
  3707. {
  3708. System.IO.Directory.CreateDirectory(fileBasePath);
  3709. }
  3710. foreach (var item in dto.Files)
  3711. {
  3712. if (item.Length < 1) continue;
  3713. var file = item;
  3714. // 将文件保存到指定位置
  3715. var filePath = Path.Combine(fileBasePath, file.FileName);
  3716. using (var stream = new FileStream(filePath, FileMode.Create))
  3717. {
  3718. await file.CopyToAsync(stream);
  3719. }
  3720. //验证文件是否上传成功
  3721. if (!System.IO.File.Exists(filePath))
  3722. {
  3723. foreach (var filePathStr in fileNames)
  3724. {
  3725. System.IO.File.Delete(Path.Combine(fileBasePath, filePathStr));
  3726. }
  3727. return Ok(JsonView(false, "文件上传失败!"));
  3728. }
  3729. fileNames.Add(file.FileName);
  3730. }
  3731. }
  3732. #endregion
  3733. #region 参数处理
  3734. EncryptionProcessor.EncryptProperties(dto);
  3735. var translatorInfo = _mapper.Map<Res_TranslatorLibrary>(dto);
  3736. #endregion
  3737. _sqlSugar.BeginTran();
  3738. if (dto.Status == 1)
  3739. {
  3740. //验证重复
  3741. var info = await _translatorRep.Query(x => x.Area.Equals(dto.Area) && x.Name.Equals(dto.Name)).FirstAsync();
  3742. if (info != null) return Ok(JsonView(false, "该条数据已存在!"));
  3743. translatorInfo.CreateUserId = currUserInfo.UserId;
  3744. if (fileNames.Count > 0)
  3745. {
  3746. translatorInfo.Files = AesEncryptionHelper.Encrypt(JsonConvert.SerializeObject(fileNames));
  3747. }
  3748. var id = await _translatorRep.AddAsync(translatorInfo);
  3749. if (id > 0) {
  3750. #region 新增(公务信息关联翻译人员) 关联信息
  3751. if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
  3752. {
  3753. var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
  3754. foreach (var officialDutyId in dto.officialDutyIdItem)
  3755. {
  3756. officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
  3757. {
  3758. TranslatorId = id,
  3759. OfficialDutyId = officialDutyId,
  3760. CreateUserId = currUserInfo.UserId,
  3761. Remark = $"翻译人员库-->添加"
  3762. });
  3763. }
  3764. if (officialDutyLinkTranslators.Count > 0)
  3765. {
  3766. await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
  3767. }
  3768. }
  3769. #endregion
  3770. _sqlSugar.CommitTran();
  3771. return Ok(JsonView(true));
  3772. }
  3773. }
  3774. else if (dto.Status == 2)
  3775. {
  3776. var info = await _translatorRep.Query(x => x.Id == dto.Id).FirstAsync();
  3777. if (info != null)
  3778. {
  3779. if (!string.IsNullOrEmpty(info.Files))
  3780. {
  3781. try
  3782. {
  3783. var selectFiles = JsonConvert.DeserializeObject<List<string>>(info.Files);
  3784. fileNames.AddRange(selectFiles);
  3785. }
  3786. catch (Exception)
  3787. {
  3788. }
  3789. }
  3790. }
  3791. if (fileNames.Count > 0)
  3792. {
  3793. translatorInfo.Files = AesEncryptionHelper.Encrypt(JsonConvert.SerializeObject(fileNames));
  3794. }
  3795. var upd = await _translatorRep
  3796. .UpdateAsync(x => x.Id == dto.Id, x => new Res_TranslatorLibrary()
  3797. {
  3798. Area = translatorInfo.Area,
  3799. Name = translatorInfo.Name,
  3800. Sex = translatorInfo.Sex,
  3801. Photo = translatorInfo.Photo,
  3802. Tel = translatorInfo.Tel,
  3803. Email = translatorInfo.Email,
  3804. WechatNo = translatorInfo.WechatNo,
  3805. OtherSocialAccounts = translatorInfo.OtherSocialAccounts,
  3806. Language = translatorInfo.Language,
  3807. Price = translatorInfo.Price,
  3808. Currency = translatorInfo.Currency,
  3809. Remark = translatorInfo.Remark,
  3810. Files = translatorInfo.Files,
  3811. });
  3812. if (upd) {
  3813. #region 更新(公务信息关联翻译人员) 关联信息
  3814. var officialDutyLinkTranslators_select = await _sqlSugar.Queryable<Grp_OfficialDutyLinkTranslator>()
  3815. .Where(x => x.IsDel == 0 && x.TranslatorId == dto.Id)
  3816. .ToListAsync();
  3817. //删除
  3818. var officialDutyLinkTranslatorIds = officialDutyLinkTranslators_select.Select(x => x.Id).ToList();
  3819. if (officialDutyLinkTranslatorIds.Count > 0)
  3820. {
  3821. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  3822. .SetColumnsIF(officialDutyLinkTranslatorIds.Count > 0, x => new Grp_OfficialDutyLinkTranslator()
  3823. {
  3824. DeleteUserId = currUserInfo.UserId,
  3825. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  3826. IsDel = 1,
  3827. Remark = $"翻译人员库-->删除"
  3828. })
  3829. .Where(x => officialDutyLinkTranslatorIds.Contains(x.Id))
  3830. .ExecuteCommandAsync();
  3831. }
  3832. if (dto.officialDutyIdItem != null && dto.officialDutyIdItem.Length > 0)
  3833. {
  3834. //添加
  3835. var officialDutyLinkTranslators = new List<Grp_OfficialDutyLinkTranslator>();
  3836. foreach (var officialDutyId in dto.officialDutyIdItem)
  3837. {
  3838. officialDutyLinkTranslators.Add(new Grp_OfficialDutyLinkTranslator()
  3839. {
  3840. TranslatorId = dto.Id,
  3841. OfficialDutyId = officialDutyId,
  3842. CreateUserId = currUserInfo.UserId,
  3843. Remark = $"翻译人员库-->更新"
  3844. });
  3845. }
  3846. if (officialDutyLinkTranslators.Count > 0)
  3847. {
  3848. await _sqlSugar.Insertable(officialDutyLinkTranslators).ExecuteCommandAsync();
  3849. }
  3850. }
  3851. #endregion
  3852. _sqlSugar.CommitTran();
  3853. return Ok(JsonView(true));
  3854. }
  3855. }
  3856. _sqlSugar.RollbackTran();
  3857. return Ok(JsonView(false));
  3858. }
  3859. /// <summary>
  3860. /// 翻译人员库
  3861. /// Del
  3862. /// </summary>
  3863. /// <param name="id"></param>
  3864. /// <returns></returns>
  3865. [HttpDelete("id")]
  3866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3867. public async Task<IActionResult> TranslatorLibraryDel(int id)
  3868. {
  3869. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  3870. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  3871. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  3872. _sqlSugar.BeginTran();
  3873. var upd = await _translatorRep.SoftDeleteByIdAsync<Res_TranslatorLibrary>(id.ToString(), currUserInfo.UserId);
  3874. if (!upd) {
  3875. _sqlSugar.RollbackTran();
  3876. return Ok(JsonView(false));
  3877. }
  3878. #region 删除公务出访
  3879. await _sqlSugar.Updateable<Grp_OfficialDutyLinkTranslator>()
  3880. .SetColumns(x => new Grp_OfficialDutyLinkTranslator() {
  3881. DeleteUserId = currUserInfo.UserId,
  3882. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  3883. IsDel = 1,
  3884. Remark = $"翻译人员库-->删除"
  3885. })
  3886. .Where(x => x.TranslatorId == id)
  3887. .ExecuteCommandAsync();
  3888. #endregion
  3889. _sqlSugar.CommitTran();
  3890. return Ok(JsonView(true));
  3891. }
  3892. #endregion
  3893. #region 策划部供应商资料
  3894. /// <summary>
  3895. /// 策划部供应商资料
  3896. /// Init
  3897. /// </summary>
  3898. /// <returns></returns>
  3899. [HttpGet]
  3900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3901. public async Task<IActionResult> MediaSupplierInit()
  3902. {
  3903. return Ok(await _mediaSupplierRep.Init());
  3904. }
  3905. /// <summary>
  3906. /// 策划部供应商资料
  3907. /// Info
  3908. /// </summary>
  3909. /// <param name="dto"></param>
  3910. /// <returns></returns>
  3911. [HttpPost]
  3912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3913. public async Task<IActionResult> MediaSupplierInfo(MediaSupplierInfoDto dto)
  3914. {
  3915. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3916. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Port));
  3917. return Ok(await _mediaSupplierRep.Info(dto));
  3918. }
  3919. /// <summary>
  3920. /// 策划部供应商资料
  3921. /// 分页查询
  3922. /// </summary>
  3923. /// <param name="dto"></param>
  3924. /// <returns></returns>
  3925. [HttpPost]
  3926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3927. public async Task<IActionResult> MediaSupplierPageItem(MediaSupplierPageItemDto dto)
  3928. {
  3929. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3930. return Ok(await _mediaSupplierRep.PageItem(dto));
  3931. }
  3932. /// <summary>
  3933. /// 策划部供应商资料
  3934. /// 操作(添加 Or 编辑)
  3935. /// </summary>
  3936. /// <param name="dto"></param>
  3937. /// <returns></returns>
  3938. [HttpPost]
  3939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3940. public async Task<IActionResult> MediaSupplierOp(MediaSupplierAddOrEditDto dto)
  3941. {
  3942. var result = new JsonView() { Code = 400, Msg = "操作失败" };
  3943. var userId = dto.CurrUserId;
  3944. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3945. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  3946. return Ok(await _mediaSupplierRep.AddOrEdit(dto));
  3947. }
  3948. /// <summary>
  3949. /// 策划部供应商资料
  3950. /// 删除
  3951. /// </summary>
  3952. /// <param name="dto"></param>
  3953. /// <returns></returns>
  3954. [HttpPost]
  3955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3956. public async Task<IActionResult> MediaSupplierSoftDel(MediaSupplierSoftDelDto dto)
  3957. {
  3958. var result = new JsonView() { Code = 400, Msg = "操作失败" };
  3959. int userId = dto.CurrUserId, id = dto.Id;
  3960. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3961. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  3962. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  3963. return Ok(await _mediaSupplierRep.SoftDel(dto));
  3964. }
  3965. #endregion
  3966. #region 保险国家基础费用
  3967. /// <summary>
  3968. /// 保险国家基础费用
  3969. /// Info
  3970. /// </summary>
  3971. /// <param name="dto"></param>
  3972. /// <returns></returns>
  3973. [HttpPost]
  3974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3975. public async Task<IActionResult> InsuranceCostInfo(InsuranceCostInfoDto dto)
  3976. {
  3977. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  3978. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Port));
  3979. var id = dto.Id;
  3980. var info = await _sqlSugar.Queryable<Res_BasicInsuranceCost>()
  3981. .Where(x => x.Id == id && x.IsDel == 0)
  3982. .Select(x => new {
  3983. x.Id,
  3984. x.IsSchengen,
  3985. x.CountryName,
  3986. x.Cost,
  3987. x.Remark,
  3988. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(s => s.Id == x.CreateUserId).Select(s => s.CnName),
  3989. x.CreateTime
  3990. })
  3991. .FirstAsync();
  3992. return Ok(JsonView(info));
  3993. }
  3994. /// <summary>
  3995. /// 保险国家基础费用
  3996. /// 分页查询
  3997. /// </summary>
  3998. /// <param name="dto"></param>
  3999. /// <returns></returns>
  4000. [HttpPost]
  4001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4002. public async Task<IActionResult> InsuranceCostPageItem(InsuranceCostPageItemDto dto)
  4003. {
  4004. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4005. RefAsync<int> total = 0;
  4006. var data = await _sqlSugar.Queryable<Res_BasicInsuranceCost>()
  4007. .LeftJoin<Sys_Users>((bic,u) => bic.CreateUserId == u.Id)
  4008. .Where((bic, u) => bic.IsDel == 0)
  4009. .WhereIF(!string.IsNullOrEmpty(dto.Search), (bic, u) => bic.CountryName.Contains(dto.Search))
  4010. .OrderByDescending((bic, u) => bic.Id)
  4011. .Select((bic, u) => new {
  4012. bic.Id,
  4013. bic.IsSchengen,
  4014. bic.CountryName,
  4015. bic.Cost,
  4016. bic.Remark,
  4017. CreateUserName = u.CnName,
  4018. bic.CreateTime
  4019. })
  4020. .ToPageListAsync(dto.PageIndex,dto.PageSize,total);
  4021. return Ok(JsonView(data,total));
  4022. }
  4023. /// <summary>
  4024. /// 保险国家基础费用
  4025. /// 操作(添加 Or 编辑)
  4026. /// </summary>
  4027. /// <param name="dto"></param>
  4028. /// <returns></returns>
  4029. [HttpPost]
  4030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4031. public async Task<IActionResult> InsuranceCostOp(InsuranceCostOpDto dto)
  4032. {
  4033. var result = new JsonView() { Code = 400, Msg = "操作失败" };
  4034. var userId = dto.CurrUserId;
  4035. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4036. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4037. var countryName = dto.CountryName.Trim();
  4038. if (string.IsNullOrEmpty(countryName)) return Ok(JsonView(false,$"国家名称不能为空!"));
  4039. var info = _mapper.Map<Res_BasicInsuranceCost>(dto);
  4040. info.CreateUserId = dto.CurrUserId;
  4041. info.CountryName = countryName;
  4042. if (dto.Id < 1) //添加
  4043. {
  4044. var addInfo = await _insuranceCostRep.Query(x => x.CountryName.Equals(countryName)).FirstAsync();
  4045. if (addInfo != null) return Ok(JsonView(false, $"该国家信息已存在,不可添加!"));
  4046. var add = await _insuranceCostRep.AddAsync(info);
  4047. if (add < 1) return Ok(JsonView(false, "添加失败!"));
  4048. }
  4049. else //修改
  4050. {
  4051. var upd = await _insuranceCostRep.UpdateAsync(x => x.Id == dto.Id, x => new Res_BasicInsuranceCost
  4052. {
  4053. IsSchengen = dto.IsSchengen,
  4054. CountryName = dto.CountryName,
  4055. Cost = dto.Cost,
  4056. Remark = dto.Remark
  4057. });
  4058. if (!upd) return Ok(JsonView(false, "修改失败!"));
  4059. }
  4060. return Ok(JsonView(true));
  4061. }
  4062. /// <summary>
  4063. /// 保险国家基础费用
  4064. /// 删除
  4065. /// </summary>
  4066. /// <param name="dto"></param>
  4067. /// <returns></returns>
  4068. [HttpPost]
  4069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4070. public async Task<IActionResult> InsuranceCostSoftDel(InsuranceCostSoftDelDto dto)
  4071. {
  4072. int userId = dto.CurrUserId, id = dto.Id;
  4073. if (!_portIds.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  4074. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4075. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  4076. var del = await _insuranceCostRep.SoftDeleteAsync(x => x.Id == id, userId);
  4077. if (!del) return Ok(JsonView(false));
  4078. return Ok(JsonView(true));
  4079. }
  4080. #endregion
  4081. }
  4082. }