ResourceController.cs 211 KB

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