ResourceController.cs 168 KB

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