ResourceController.cs 194 KB

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