ResourceController.cs 123 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023
  1. using Aspose.Words;
  2. using EyeSoft.Extensions;
  3. using OASystem.API.OAMethodLib;
  4. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  5. using OASystem.Domain.Dtos.Groups;
  6. using OASystem.Domain.Entities.Groups;
  7. using OASystem.Domain.ViewModels.Groups;
  8. using OASystem.Infrastructure.Repositories.Groups;
  9. using Org.BouncyCastle.Utilities.Encoders;
  10. using static OASystem.API.OAMethodLib.JWTHelper;
  11. namespace OASystem.API.Controllers
  12. {
  13. /// <summary>
  14. /// 资料相关
  15. /// </summary>
  16. //[Authorize]
  17. [Route("api/[controller]/[action]")]
  18. public class ResourceController : ControllerBase
  19. {
  20. private readonly IMapper _mapper;
  21. private readonly SqlSugarClient _sqlSugar;
  22. private readonly IConfiguration _config;
  23. private readonly CarDataRepository _carDataRep;
  24. private readonly LocalGuideDataRepository _localGuideDataRep;
  25. private readonly ThreeCodeRepository _ThreeCodeRep;
  26. private readonly HotelDataRepository _hotelDataRep;
  27. private readonly ResItemInfoRepository _resItemInfoRep;
  28. private readonly SetDataRepository _setDataRepository;
  29. private readonly CountryFeeRepository _countryFeeRep;
  30. private readonly SetDataTypeRepository _setDataTypeRep;
  31. private readonly AirTicketAgentRepository _airTicketAgentRep;
  32. private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
  33. private readonly OfficialActivitiesRepository _officialActivitiesRep;
  34. private readonly AskDataRepository _askDataRep;
  35. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  36. private readonly TourClientListRepository _tourClientListRep;
  37. private readonly DelegationInfoRepository _delegationInfoRep;
  38. private readonly TranslatorLibraryRepository _translatorRep;
  39. public ResourceController(IMapper mapper,
  40. IConfiguration config,
  41. SqlSugarClient sqlSugar,
  42. CarDataRepository carDataRep,
  43. LocalGuideDataRepository localGuideDataRep,
  44. ThreeCodeRepository threeCodeRep,
  45. HotelDataRepository hotelDataRep,
  46. ResItemInfoRepository resItemInfoRep,
  47. SetDataRepository setDataRepository,
  48. CountryFeeRepository countryFeeRep,
  49. SetDataTypeRepository setDataTypeRep,
  50. AirTicketAgentRepository airTicketAgentRep,
  51. InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep,
  52. OfficialActivitiesRepository officialActivitiesRep,
  53. AskDataRepository askDataRep,
  54. TicketBlackCodeRepository ticketBlackCodeRep,
  55. TourClientListRepository tourClientListRep,
  56. DelegationInfoRepository delegationInfoRep,
  57. TranslatorLibraryRepository translatorRep)
  58. {
  59. _mapper = mapper;
  60. _config = config;
  61. _sqlSugar = sqlSugar;
  62. _carDataRep = carDataRep;
  63. _localGuideDataRep = localGuideDataRep;
  64. _ThreeCodeRep = threeCodeRep;
  65. _hotelDataRep = hotelDataRep;
  66. _resItemInfoRep = resItemInfoRep;
  67. _setDataRepository = setDataRepository;
  68. _countryFeeRep = countryFeeRep;
  69. _setDataTypeRep = setDataTypeRep;
  70. _airTicketAgentRep = airTicketAgentRep;
  71. _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
  72. _officialActivitiesRep = officialActivitiesRep;
  73. _askDataRep = askDataRep;
  74. _ticketBlackCodeRep = ticketBlackCodeRep;
  75. _tourClientListRep = tourClientListRep;
  76. _delegationInfoRep = delegationInfoRep;
  77. _translatorRep = translatorRep;
  78. }
  79. #region 车公司资料板块
  80. /// <summary>
  81. /// 车公司信息查询
  82. /// </summary>
  83. /// <returns></returns>
  84. [HttpPost]
  85. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  86. public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
  87. {
  88. try
  89. {
  90. Result LocalGuide = await _carDataRep.QueryCarData(dto);
  91. if (LocalGuide.Code == 0)
  92. {
  93. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  94. }
  95. else
  96. {
  97. return Ok(JsonView(false, LocalGuide.Msg));
  98. }
  99. }
  100. catch (Exception)
  101. {
  102. return Ok(JsonView(false, "程序错误!"));
  103. throw;
  104. }
  105. }
  106. /// <summary>
  107. /// 车公司资料下拉框数据
  108. /// </summary>
  109. /// <returns></returns>
  110. [HttpPost]
  111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  112. public async Task<IActionResult> QueryCarSelect()
  113. {
  114. try
  115. {
  116. var CarData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
  117. if (CarData.Count == 0)
  118. {
  119. return Ok(JsonView(false, "暂无数据!"));
  120. }
  121. CarData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
  122. CarData = CarData.Where((x, i) => CarData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
  123. CarData = CarData.OrderBy(x => x.Id).ToList();
  124. List<CarDataSelectView> data = new List<CarDataSelectView>();
  125. foreach (CarDataSelectView car in CarData)
  126. {
  127. if (!string.IsNullOrWhiteSpace(car.UnitArea))
  128. {
  129. data.Add(car);
  130. }
  131. }
  132. return Ok(JsonView(true, "查询成功", data));
  133. }
  134. catch (Exception)
  135. {
  136. return Ok(JsonView(false, "程序错误!"));
  137. throw;
  138. }
  139. }
  140. /// <summary>
  141. /// 根据Id查询车公司详细数据
  142. /// </summary>
  143. /// <returns></returns>
  144. [HttpPost]
  145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  146. public async Task<IActionResult> QuerCarDataDetailById(QueryCarDataDetailDto dto)
  147. {
  148. string sql = string.Format(@" Select * From Res_CarData With(Nolock) Where Id = {0} ", dto.Id);
  149. CarDataDetailDataView info = _resItemInfoRep._sqlSugar.SqlQueryable<CarDataDetailDataView>(sql).First();
  150. if (info == null)
  151. {
  152. return Ok(JsonView(false, "未找到相关数据!"));
  153. }
  154. return Ok(JsonView(true, "查询成功", info));
  155. }
  156. /// <summary>
  157. /// 车公司信息添加
  158. /// </summary>
  159. /// <returns></returns>
  160. [HttpPost]
  161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  162. public async Task<IActionResult> AddCarData(AddCarDataDto dto)
  163. {
  164. try
  165. {
  166. if (dto.UnitArea == "")
  167. {
  168. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  169. }
  170. if (dto.UnitName == "")
  171. {
  172. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  173. }
  174. if (dto.Contact == "")
  175. {
  176. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  177. }
  178. if (dto.ContactTel == "")
  179. {
  180. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  181. }
  182. 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();
  183. if (carDada.Count != 0)
  184. {
  185. return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
  186. }
  187. Res_CarData _CarData = _mapper.Map<Res_CarData>(dto);
  188. int id = await _carDataRep.AddAsyncReturnId(_CarData);
  189. if (id == 0)
  190. {
  191. return Ok(JsonView(false, "添加失败!"));
  192. }
  193. return Ok(JsonView(true, "添加成功", new { Id = id }));
  194. }
  195. catch (Exception ex)
  196. {
  197. return Ok(JsonView(false, "程序错误!"));
  198. throw;
  199. }
  200. }
  201. /// <summary>
  202. /// 车公司信息修改
  203. /// </summary>
  204. /// <returns></returns>
  205. [HttpPost]
  206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  207. public async Task<IActionResult> UpCarData(UpCarDataDto dto)
  208. {
  209. try
  210. {
  211. if (dto.UnitArea == "")
  212. {
  213. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  214. }
  215. if (dto.UnitName == "")
  216. {
  217. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  218. }
  219. if (dto.Contact == "")
  220. {
  221. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  222. }
  223. if (dto.ContactTel == "")
  224. {
  225. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  226. }
  227. bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
  228. {
  229. UnitArea = dto.UnitArea,
  230. UnitName = dto.UnitName,
  231. Address = dto.Address,
  232. Contact = dto.Contact,
  233. ContactTel = dto.ContactTel,
  234. ContactEmail = dto.ContactEmail,
  235. ContactFax = dto.ContactFax,
  236. CarDes = dto.CarDes,
  237. CarPicPaths = dto.CarPicPaths,
  238. OtherInfo = dto.OtherInfo,
  239. Score = dto.Score,
  240. QualificationScore = dto.QualificationScore,
  241. CarAgeScore = dto.CarAgeScore,
  242. CleanImgScore = dto.CleanImgScore,
  243. SmellScore = dto.SmellScore,
  244. WaterPaperScore = dto.WaterPaperScore,
  245. HardwareScore = dto.HardwareScore,
  246. TimeScore = dto.TimeScore,
  247. SafetyScore = dto.SafetyScore,
  248. DrivingAgeScore = dto.DrivingAgeScore,
  249. Remark = dto.Remark,
  250. });
  251. if (!res) { return Ok(JsonView(false, "修改失败!")); }
  252. return Ok(JsonView(true, "修改成功"));
  253. }
  254. catch (Exception ex)
  255. {
  256. return Ok(JsonView(false, "程序错误!"));
  257. throw;
  258. }
  259. }
  260. /// <summary>
  261. /// 车公司信息删除
  262. /// </summary>
  263. /// <returns></returns>
  264. [HttpPost]
  265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  266. public async Task<IActionResult> DelCarData(DelCarDataDto dto)
  267. {
  268. try
  269. {
  270. bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
  271. if (!res) { return Ok(JsonView(false, "删除失败!")); }
  272. return Ok(JsonView(true, "删除成功"));
  273. }
  274. catch (Exception ex)
  275. {
  276. return Ok(JsonView(false, "程序错误!"));
  277. throw;
  278. }
  279. }
  280. #endregion
  281. #region 导游地接资料板块
  282. /// <summary>
  283. /// 导游地接资料查询
  284. /// </summary>
  285. /// <param name="dto"></param>
  286. /// <returns></returns>
  287. [HttpPost]
  288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  289. public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
  290. {
  291. try
  292. {
  293. Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
  294. if (LocalGuide.Code == 0)
  295. {
  296. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  297. }
  298. else
  299. {
  300. return Ok(JsonView(false, LocalGuide.Msg));
  301. }
  302. }
  303. catch (Exception ex)
  304. {
  305. return Ok(JsonView(false, "程序错误!"));
  306. throw;
  307. }
  308. }
  309. /// <summary>
  310. /// 导游地接资料下拉框数据
  311. /// </summary>
  312. /// <returns></returns>
  313. [HttpPost]
  314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  315. public async Task<IActionResult> QueryLocalGuideSelect()
  316. {
  317. try
  318. {
  319. var LocalGuide = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
  320. if (LocalGuide.Count == 0)
  321. {
  322. return Ok(JsonView(false, "暂无数据!"));
  323. }
  324. LocalGuide.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
  325. LocalGuide = LocalGuide.Where((x, i) => LocalGuide.FindIndex(z => z.UnitArea == x.UnitArea && z.UnitArea != "") == i).ToList();
  326. LocalGuide = LocalGuide.OrderBy(x => x.Id).ToList();
  327. List<QueryLocalGuideSelectView> data = new List<QueryLocalGuideSelectView>();
  328. foreach (QueryLocalGuideSelectView Local in LocalGuide)
  329. {
  330. if (!string.IsNullOrWhiteSpace(Local.UnitArea))
  331. {
  332. data.Add(Local);
  333. }
  334. }
  335. return Ok(JsonView(true, "查询成功", data));
  336. }
  337. catch (Exception)
  338. {
  339. return Ok(JsonView(false, "程序错误!"));
  340. throw;
  341. }
  342. }
  343. /// <summary>
  344. /// 根据Id查询地接详细数据
  345. /// </summary>
  346. /// <returns></returns>
  347. [HttpPost]
  348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  349. public async Task<IActionResult> QueryLocalGuideDetailById(QueryLocalGuideDetailDto dto)
  350. {
  351. string sql = string.Format(@" Select * From Res_LocalGuideData With(Nolock) Where Id = {0} ", dto.Id);
  352. LocalGuideDetailDataView info = _resItemInfoRep._sqlSugar.SqlQueryable<LocalGuideDetailDataView>(sql).First();
  353. if (info == null)
  354. {
  355. return Ok(JsonView(false, "未找到相关数据!"));
  356. }
  357. return Ok(JsonView(true, "查询成功", info));
  358. }
  359. /// <summary>
  360. /// 导游地接信息操作(Status:1.新增,2.修改)
  361. /// </summary>
  362. /// <returns></returns>
  363. [HttpPost]
  364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  365. public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
  366. {
  367. try
  368. {
  369. if (dto.UnitArea == "")
  370. {
  371. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  372. }
  373. if (dto.UnitName == "")
  374. {
  375. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  376. }
  377. if (dto.Contact == "")
  378. {
  379. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  380. }
  381. if (dto.ContactTel == "")
  382. {
  383. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  384. }
  385. Result result = await _localGuideDataRep.LocalGuideOperation(dto);
  386. if (result.Code != 0)
  387. {
  388. return Ok(JsonView(false, result.Msg));
  389. }
  390. return Ok(JsonView(true, result.Msg));
  391. }
  392. catch (Exception ex)
  393. {
  394. return Ok(JsonView(false, "程序错误!"));
  395. throw;
  396. }
  397. }
  398. /// <summary>
  399. /// 导游地接信息操作(删除)
  400. /// </summary>
  401. /// <returns></returns>
  402. [HttpPost]
  403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  404. public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
  405. {
  406. try
  407. {
  408. var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
  409. if (!res)
  410. {
  411. return Ok(JsonView(false, "删除失败"));
  412. }
  413. return Ok(JsonView(true, "删除成功!"));
  414. }
  415. catch (Exception ex)
  416. {
  417. return Ok(JsonView(false, "程序错误!"));
  418. throw;
  419. }
  420. }
  421. #endregion
  422. #region 机场三字码信息
  423. /// <summary>
  424. /// 机场三字码查询
  425. /// </summary>
  426. /// <param name="dto"></param>
  427. /// <returns></returns>
  428. [HttpPost]
  429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  430. public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
  431. {
  432. try
  433. {
  434. Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
  435. if (LocalGuide.Code == 0)
  436. {
  437. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  438. }
  439. else
  440. {
  441. return Ok(JsonView(false, LocalGuide.Msg));
  442. }
  443. }
  444. catch (Exception ex)
  445. {
  446. return Ok(JsonView(false, "程序错误!"));
  447. throw;
  448. }
  449. }
  450. /// <summary>
  451. /// 机场三字码数据城市下拉框数据
  452. /// </summary>
  453. /// <returns></returns>
  454. [HttpPost]
  455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  456. public async Task<IActionResult> QueryThreeCodeSelect()
  457. {
  458. try
  459. {
  460. var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
  461. if (ThreeCode.Count == 0)
  462. {
  463. return Ok(JsonView(false, "暂无数据!"));
  464. }
  465. ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
  466. ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  467. ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
  468. List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
  469. foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
  470. {
  471. if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
  472. {
  473. data.Add(_ThreeCode);
  474. }
  475. }
  476. return Ok(JsonView(true, "查询成功", data));
  477. }
  478. catch (Exception)
  479. {
  480. return Ok(JsonView(false, "程序错误!"));
  481. throw;
  482. }
  483. }
  484. /// <summary>
  485. /// 机场三字码资料操作(Status:1.新增,2.修改)
  486. /// </summary>
  487. /// <param name="dto"></param>
  488. /// <returns></returns>
  489. [HttpPost]
  490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  491. public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
  492. {
  493. try
  494. {
  495. if (dto.Three == "")
  496. {
  497. return Ok(JsonView(false, "请检查三字码是否填写!"));
  498. }
  499. if (dto.Country == "")
  500. {
  501. return Ok(JsonView(false, "请检查国家是否填写!"));
  502. }
  503. if (dto.City == "")
  504. {
  505. return Ok(JsonView(false, "请检查城市是否填写正确!"));
  506. }
  507. if (dto.AirPort == "")
  508. {
  509. return Ok(JsonView(false, "请检查机场是否填写正确!"));
  510. }
  511. Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
  512. if (result.Code != 0)
  513. {
  514. return Ok(JsonView(false, result.Msg));
  515. }
  516. return Ok(JsonView(true, result.Msg));
  517. }
  518. catch (Exception ex)
  519. {
  520. return Ok(JsonView(false, "程序错误!"));
  521. throw;
  522. }
  523. }
  524. /// <summary>
  525. /// 机场三字码资料操作(删除)
  526. /// </summary>
  527. /// <returns></returns>
  528. [HttpPost]
  529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  530. public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
  531. {
  532. try
  533. {
  534. var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
  535. if (!res)
  536. {
  537. return Ok(JsonView(false, "删除失败"));
  538. }
  539. return Ok(JsonView(true, "删除成功!"));
  540. }
  541. catch (Exception ex)
  542. {
  543. return Ok(JsonView(false, "程序错误!"));
  544. throw;
  545. }
  546. }
  547. /// <summary>
  548. ///根据ID查询三字码信息
  549. /// </summary>
  550. /// <returns></returns>
  551. [HttpPost]
  552. public IActionResult QuerySingleThreeCode(QuerySingleThreeCode dto)
  553. {
  554. var jw = JsonView(false);
  555. var single = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Id == dto.ID && x.IsDel == 0);
  556. if (single != null)
  557. {
  558. jw = JsonView(true, "获取成功!", new
  559. {
  560. single.Three,
  561. Four = single.Four?.Trim(),
  562. single.AirPort,
  563. single.AirPort_En,
  564. single.City,
  565. single.Country,
  566. single.Remark
  567. });
  568. }
  569. else
  570. {
  571. jw.Msg = "暂无!";
  572. }
  573. return Ok(jw);
  574. }
  575. #endregion
  576. #region 代理出票合作方资料
  577. /// <summary>
  578. /// 代理出票合作方资料
  579. /// </summary>
  580. /// <param name="dto"></param>
  581. /// <returns></returns>
  582. [HttpPost]
  583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  584. public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
  585. {
  586. try
  587. {
  588. List<Res_AirTicketAgent> res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
  589. if (res_AirTicketAgents.Count != 0)
  590. {
  591. res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
  592. if (dto.PageSize == 0 && dto.PageIndex == 0)
  593. {
  594. return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
  595. }
  596. else
  597. {
  598. int count = res_AirTicketAgents.Count;
  599. float totalPage = (float)count / dto.PageSize;//总页数
  600. if (totalPage == 0) totalPage = 1;
  601. else totalPage = (int)Math.Ceiling((double)totalPage);
  602. List<Res_AirTicketAgent> _AirTicketAgent = new List<Res_AirTicketAgent>();
  603. for (int i = 0; i < dto.PageSize; i++)
  604. {
  605. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  606. if (RowIndex < res_AirTicketAgents.Count)
  607. {
  608. _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
  609. }
  610. else
  611. {
  612. break;
  613. }
  614. }
  615. return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
  616. }
  617. }
  618. else
  619. {
  620. return Ok(JsonView(false, "暂无数据!"));
  621. }
  622. }
  623. catch (Exception ex)
  624. {
  625. return Ok(JsonView(false, "程序错误!"));
  626. throw;
  627. }
  628. }
  629. /// <summary>
  630. /// 代理出票合作方资料操作(Status:1.新增,2.修改)
  631. /// </summary>
  632. /// <param name="dto"></param>
  633. /// <returns></returns>
  634. [HttpPost]
  635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  636. public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
  637. {
  638. try
  639. {
  640. if (dto.Account == "")
  641. {
  642. return Ok(JsonView(false, "请检查代理商账户是否填写!"));
  643. }
  644. if (dto.Bank == "")
  645. {
  646. return Ok(JsonView(false, "请检查代理商银行是否填写!"));
  647. }
  648. if (dto.Name == "")
  649. {
  650. return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
  651. }
  652. Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
  653. if (result.Code != 0)
  654. {
  655. return Ok(JsonView(false, result.Msg));
  656. }
  657. return Ok(JsonView(true, result.Msg));
  658. }
  659. catch (Exception ex)
  660. {
  661. return Ok(JsonView(false, "程序错误!"));
  662. throw;
  663. }
  664. }
  665. /// <summary>
  666. /// 代理出票合作方资料操作(删除)
  667. /// </summary>
  668. /// <returns></returns>
  669. [HttpPost]
  670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  671. public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
  672. {
  673. try
  674. {
  675. var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
  676. if (!res)
  677. {
  678. return Ok(JsonView(false, "删除失败"));
  679. }
  680. return Ok(JsonView(true, "删除成功!"));
  681. }
  682. catch (Exception ex)
  683. {
  684. return Ok(JsonView(false, "程序错误!"));
  685. throw;
  686. }
  687. }
  688. #endregion
  689. #region 酒店资料数据
  690. /// <summary>
  691. /// 酒店信息查询 Page
  692. /// </summary>
  693. /// <param name="dto"></param>
  694. /// <returns></returns>
  695. [HttpPost]
  696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  697. public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
  698. {
  699. string sqlWhere = string.Empty;
  700. if (!string.IsNullOrWhiteSpace(dto.Name))
  701. {
  702. sqlWhere += string.Format(@" And hd.Name like '%{0}%'", dto.Name);
  703. }
  704. if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
  705. {
  706. sqlWhere += string.Format(@" And hd.City like '%{0}%'", dto.City);
  707. }
  708. if (!string.IsNullOrWhiteSpace(dto.Contact))
  709. {
  710. sqlWhere += string.Format(@" And hd.Contact like '%{0}%'", dto.Contact);
  711. }
  712. if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
  713. {
  714. sqlWhere += string.Format(@" And hd.ContactPhone like '%{0}%'", dto.ContactPhone);
  715. }
  716. sqlWhere += string.Format(@" And hd.IsDel={0}", 0);
  717. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  718. {
  719. Regex r = new Regex("And");
  720. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  721. }
  722. string sql = string.Format(@"SELECT
  723. *
  724. FROM
  725. (
  726. SELECT
  727. ROW_NUMBER() OVER (
  728. ORDER BY
  729. hd.CreateTime DESC
  730. ) AS Row_Number,
  731. hd.Id,
  732. hd.City,
  733. hd.[Name],
  734. hd.Tel,
  735. hd.Fax,
  736. hd.Contact,
  737. hd.ContactPhone,
  738. u.CnName AS CreateUserName,
  739. hd.CreateTime
  740. FROM
  741. Res_HotelData hd
  742. WITH
  743. (NoLock)
  744. LEFT JOIN Sys_Users u
  745. WITH
  746. (NoLock) ON hd.CreateUserId = u.Id {0}
  747. ) Temp
  748. ", sqlWhere);
  749. if (dto.PortType == 1)
  750. {
  751. List<HotelDataItemView> HotelDataData = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToListAsync();
  752. if (HotelDataData.Count == 0)
  753. {
  754. return Ok(JsonView(false, "暂无数据"));
  755. }
  756. return Ok(JsonView(true, "操作成功", HotelDataData));
  757. }
  758. else if (dto.PortType == 2 || dto.PortType == 3)
  759. {
  760. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  761. var data = await _sqlSugar.SqlQueryable<HotelDataItemView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total); //ToPageAsync
  762. return Ok(JsonView(true, "操作成功", data, total));
  763. }
  764. else return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  765. }
  766. /// <summary>
  767. /// 酒店资料
  768. /// 详情
  769. /// add time:2024-05-14 11:57:10
  770. /// </summary>
  771. /// <returns></returns>
  772. [HttpPost]
  773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  774. public async Task<IActionResult> QueryHotelDataInfo(QueryHotelDataInfoDto dto)
  775. {
  776. var _view = await _hotelDataRep._Info(dto.PortType, dto.Id);
  777. if (_view.Code == 0)
  778. {
  779. return Ok(JsonView(true, _view.Msg, _view.Data));
  780. }
  781. return Ok(JsonView(false, _view.Msg));
  782. }
  783. /// <summary>
  784. /// 酒店资料下拉框数据
  785. /// </summary>
  786. /// <returns></returns>
  787. [HttpPost]
  788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  789. public async Task<IActionResult> QueryHotelDataSelect()
  790. {
  791. try
  792. {
  793. var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
  794. if (HotelData.Count == 0)
  795. {
  796. return Ok(JsonView(false, "暂无数据!"));
  797. }
  798. HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
  799. HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  800. HotelData = HotelData.OrderBy(x => x.Id).ToList();
  801. List<QueryHotelDataSelect> data = new List<QueryHotelDataSelect>();
  802. foreach (QueryHotelDataSelect Hotel in HotelData)
  803. {
  804. if (!string.IsNullOrWhiteSpace(Hotel.City))
  805. {
  806. data.Add(Hotel);
  807. }
  808. }
  809. return Ok(JsonView(true, "查询成功", data));
  810. }
  811. catch (Exception)
  812. {
  813. return Ok(JsonView(false, "程序错误!"));
  814. throw;
  815. }
  816. }
  817. /// <summary>
  818. /// 酒店资料操作(Status:1.新增,2.修改)
  819. /// </summary>
  820. /// <param name="dto"></param>
  821. /// <returns></returns>
  822. [HttpPost]
  823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  824. public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
  825. {
  826. if (string.IsNullOrEmpty(dto.City)) return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
  827. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "请检查酒店名称是否填写!"));
  828. if (string.IsNullOrEmpty(dto.Address)) return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
  829. if (string.IsNullOrEmpty(dto.Tel)) return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
  830. Result result = await _hotelDataRep.OperationHotelData(dto);
  831. if (result.Code != 0) return Ok(JsonView(false, result.Msg));
  832. return Ok(JsonView(true, result.Msg));
  833. }
  834. /// <summary>
  835. /// 酒店资料操作(删除)
  836. /// </summary>
  837. /// <returns></returns>
  838. [HttpPost]
  839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  840. public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
  841. {
  842. try
  843. {
  844. var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
  845. if (!res)
  846. {
  847. return Ok(JsonView(false, "删除失败"));
  848. }
  849. return Ok(JsonView(true, "删除成功!"));
  850. }
  851. catch (Exception ex)
  852. {
  853. return Ok(JsonView(false, "程序错误!"));
  854. throw;
  855. }
  856. }
  857. #endregion
  858. #region 签证费用资料
  859. /// <summary>
  860. /// 签证费用资料查询
  861. /// </summary>
  862. /// <param name="dto"></param>
  863. /// <returns></returns>
  864. [HttpPost]
  865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  866. public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
  867. {
  868. if (dto.PortType == 1)
  869. {
  870. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  871. if (CountryFee.Count == 0)
  872. {
  873. return Ok(JsonView(false, "暂无数据!"));
  874. }
  875. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  876. return Ok(JsonView(true, "查询成功", CountryFee));
  877. }
  878. else if (dto.PortType == 2)
  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
  889. {
  890. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  891. }
  892. }
  893. /// <summary>
  894. /// 签证费用资料操作(Status:1.新增,2.修改)
  895. /// </summary>
  896. /// <param name="dto"></param>
  897. /// <returns></returns>
  898. [HttpPost]
  899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  900. public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
  901. {
  902. if (string.IsNullOrWhiteSpace(dto.VisaContinent))
  903. {
  904. return Ok(JsonView(false, "请检查州名是否填写!"));
  905. }
  906. if (string.IsNullOrWhiteSpace(dto.VisaCountry))
  907. {
  908. return Ok(JsonView(false, "请检查国家名是否填写!"));
  909. }
  910. if (string.IsNullOrWhiteSpace(dto.VisaTime))
  911. {
  912. return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
  913. }
  914. if (string.IsNullOrWhiteSpace(dto.UrgentTime))
  915. {
  916. return Ok(JsonView(false, "请检加急时间是否填写正确!"));
  917. }
  918. Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
  919. if (result.Code == 0)
  920. {
  921. return Ok(JsonView(true, result.Msg));
  922. }
  923. return Ok(JsonView(false, result.Msg));
  924. }
  925. /// <summary>
  926. /// 签证费用资料操作(删除)
  927. /// </summary>
  928. /// <returns></returns>
  929. [HttpPost]
  930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  931. public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
  932. {
  933. var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
  934. if (!res)
  935. {
  936. return Ok(JsonView(false, "删除失败"));
  937. }
  938. return Ok(JsonView(true, "删除成功!"));
  939. }
  940. #endregion
  941. #region 物料信息、供应商维护
  942. #region 供应商
  943. /// <summary>
  944. /// 物料供应商查询
  945. /// </summary>
  946. /// <param name="paras">Json序列化</param>
  947. /// <returns></returns>
  948. [HttpPost]
  949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  950. public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
  951. {
  952. if (string.IsNullOrEmpty(_jsonDto.Paras))
  953. {
  954. return Ok(JsonView(false, "参数为空"));
  955. }
  956. Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
  957. if (_ItemVendorDto != null)
  958. {
  959. if (_ItemVendorDto.SearchType == 2) //获取列表
  960. {
  961. Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
  962. return Ok(rstList);
  963. }
  964. else
  965. {
  966. Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
  967. return Ok(rstInfo);
  968. }
  969. }
  970. else
  971. {
  972. return Ok(JsonView(false, "参数反序列化失败"));
  973. }
  974. return Ok(JsonView(false));
  975. }
  976. /// <summary>
  977. /// 创建/编辑/删除供应商信息
  978. /// </summary>
  979. /// <param name="_dto"></param>
  980. /// <returns></returns>
  981. [HttpPost]
  982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  983. public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
  984. {
  985. bool rst = false;
  986. if (_dto.EditType >= 0)
  987. {
  988. if (string.IsNullOrEmpty(_dto.VendorFullName))
  989. {
  990. return Ok(JsonView(false, "全称未填写"));
  991. }
  992. if (string.IsNullOrEmpty(_dto.VendorLinker))
  993. {
  994. return Ok(JsonView(false, "联系人未填写"));
  995. }
  996. if (string.IsNullOrEmpty(_dto.VendorMobile))
  997. {
  998. return Ok(JsonView(false, "联系人手机号未填写"));
  999. }
  1000. if (string.IsNullOrEmpty(_dto.BusRange))
  1001. {
  1002. return Ok(JsonView(false, "经营范围未选择"));
  1003. }
  1004. if (_dto.EditType == 0)
  1005. {
  1006. var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
  1007. if (checkEmpty != null)
  1008. {
  1009. return Ok(JsonView(false, "已存在同名供应商"));
  1010. }
  1011. rst = await _resItemInfoRep.addVendorInfo(_dto);
  1012. }
  1013. else if (_dto.EditType == 1)
  1014. {
  1015. if (_dto.VendorId > 0)
  1016. {
  1017. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  1018. rst = await _resItemInfoRep.updVendorInfo(_entity);
  1019. }
  1020. else
  1021. {
  1022. return Ok(JsonView(false, "供应商不存在"));
  1023. }
  1024. }
  1025. }
  1026. else
  1027. {
  1028. if (_dto.VendorId < 1 || _dto.SysUserId < 1)
  1029. {
  1030. return Ok(JsonView(false, "用户Id或供应商Id不存在"));
  1031. }
  1032. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  1033. rst = await _resItemInfoRep.delVendorInfo(_entity);
  1034. }
  1035. return Ok(JsonView(rst));
  1036. }
  1037. #endregion
  1038. #region 物料信息
  1039. /// <summary>
  1040. /// 物料信息查询
  1041. /// </summary>
  1042. /// <param name="paras">Json序列化</param>
  1043. /// <returns></returns>
  1044. [HttpPost]
  1045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1046. public async Task<IActionResult> PostSearchItemInfo(string paras)
  1047. {
  1048. if (string.IsNullOrEmpty(paras))
  1049. {
  1050. return Ok(JsonView(false, "参数为空"));
  1051. }
  1052. Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
  1053. if (_ItemInfoDto != null)
  1054. {
  1055. if (_ItemInfoDto.SearchType == 2) //获取列表
  1056. {
  1057. Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
  1058. return Ok(rstList);
  1059. }
  1060. else
  1061. {
  1062. Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
  1063. return Ok(rstInfo);
  1064. }
  1065. }
  1066. else
  1067. {
  1068. return Ok(JsonView(false, "参数反序列化失败"));
  1069. }
  1070. return Ok(JsonView(false));
  1071. }
  1072. /// <summary>
  1073. /// 创建/编辑/删除物料信息
  1074. /// </summary>
  1075. ///
  1076. /// <returns></returns>
  1077. [HttpPost]
  1078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1079. public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
  1080. {
  1081. bool rst = false;
  1082. if (_dto.EditType >= 0)
  1083. {
  1084. if (_dto.VendorId < 1)
  1085. {
  1086. return Ok(JsonView(false, "未选择供应商"));
  1087. }
  1088. if (string.IsNullOrEmpty(_dto.ItemName))
  1089. {
  1090. return Ok(JsonView(false, "物料名称为空"));
  1091. }
  1092. if (_dto.ItemTypeId < 1)
  1093. {
  1094. return Ok(JsonView(false, "未选择物料类型"));
  1095. }
  1096. if (_dto.SysUserId < 1)
  1097. {
  1098. return Ok(JsonView(false, "当前操作用户Id为空"));
  1099. }
  1100. if (_dto.CurrRate <= 0)
  1101. {
  1102. return Ok(JsonView(false, "物料录入价格不能小于等于0"));
  1103. }
  1104. if (_dto.EditType == 0)
  1105. {
  1106. //判断物料名称、类型、供应商全部重复
  1107. var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
  1108. if (checkEmpty != null)
  1109. {
  1110. return Ok(JsonView(false, "已存在重复物料信息"));
  1111. }
  1112. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1113. DateTime dtNow = DateTime.Now;
  1114. _entity.CreateUserId = _dto.SysUserId;
  1115. _entity.IsDel = 0;
  1116. _entity.MaxRate = _dto.CurrRate;
  1117. _entity.MaxDt = dtNow;
  1118. _entity.CurrRate = _dto.CurrRate;
  1119. _entity.CurrDt = dtNow;
  1120. _entity.MinRate = _dto.CurrRate;
  1121. _entity.MinDt = dtNow;
  1122. rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
  1123. }
  1124. else if (_dto.EditType == 1)
  1125. {
  1126. if (_dto.ItemId > 0)
  1127. {
  1128. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1129. _entity.Id = _dto.ItemId;
  1130. rst = await _resItemInfoRep.updItemInfo(_entity);
  1131. }
  1132. else
  1133. {
  1134. return Ok(JsonView(false, "供应商不存在"));
  1135. }
  1136. }
  1137. }
  1138. else
  1139. {
  1140. if (_dto.ItemId < 1 || _dto.SysUserId < 1)
  1141. {
  1142. return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
  1143. }
  1144. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1145. rst = await _resItemInfoRep.delItemInfo(_entity);
  1146. }
  1147. return Ok(JsonView(rst));
  1148. }
  1149. #endregion
  1150. #region 物料类型获取
  1151. #endregion
  1152. #endregion
  1153. #region 备忘录
  1154. /// <summary>
  1155. /// 备忘录查询
  1156. /// </summary>
  1157. /// <param name="paras">Json序列化</param>
  1158. /// <returns></returns>
  1159. [HttpPost]
  1160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1161. public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
  1162. {
  1163. if (string.IsNullOrEmpty(_jsonDto.Paras))
  1164. {
  1165. return Ok(JsonView(false, "参数为空"));
  1166. }
  1167. Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
  1168. if (_memoDto != null)
  1169. {
  1170. if (_memoDto.SearchType == 2)
  1171. {
  1172. //获取列表
  1173. string sqlWhere = string.Format(" Where IsDel=0 ");
  1174. #region SqlWhere
  1175. if (!string.IsNullOrEmpty(_memoDto.Abstracts))
  1176. {
  1177. sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
  1178. }
  1179. if (!string.IsNullOrEmpty(_memoDto.Title))
  1180. {
  1181. sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
  1182. }
  1183. if (_memoDto.ReadLevel > 0)
  1184. {
  1185. sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
  1186. }
  1187. #endregion
  1188. int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
  1189. int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
  1190. string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
  1191. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1192. m.LastedEditDt,m.LastedEditorId
  1193. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1194. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
  1195. ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
  1196. Res_MemoListView rst = new Res_MemoListView();
  1197. rst.CurrPageIndex = currPIndex;
  1198. rst.CurrPageSize = currPSize;
  1199. List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
  1200. Dictionary<int, string> userDic = new Dictionary<int, string>();
  1201. foreach (var item in dataSource)
  1202. {
  1203. if (userDic.ContainsKey(item.LastedEditorId))
  1204. {
  1205. item.LastedEditor = userDic[item.LastedEditorId];
  1206. }
  1207. else
  1208. {
  1209. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
  1210. userDic[item.LastedEditorId] = _sysUser.CnName;
  1211. item.LastedEditor = _sysUser.CnName;
  1212. }
  1213. }
  1214. rst.DataList = new List<Res_MemoView>(dataSource);
  1215. if (rst.DataList.Count > 0)
  1216. {
  1217. string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
  1218. int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
  1219. rst.DataCount = dataCount;
  1220. }
  1221. return Ok(JsonView(rst));
  1222. }
  1223. else
  1224. {
  1225. //获取对象
  1226. string sqlSingle = string.Format(@" Select
  1227. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1228. m.LastedEditDt,m.LastedEditor,m.MDFilePath
  1229. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1230. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
  1231. Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
  1232. if (_result != null)
  1233. {
  1234. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
  1235. _result.LastedEditor = _sysUser.CnName;
  1236. _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
  1237. return Ok(JsonView(_result));
  1238. }
  1239. }
  1240. }
  1241. else
  1242. {
  1243. return Ok(JsonView(false, "参数反序列化失败"));
  1244. }
  1245. return Ok(JsonView(false));
  1246. }
  1247. /// <summary>
  1248. /// 创建/编辑/删除备忘录信息
  1249. /// </summary>
  1250. /// <param name="_dto"></param>
  1251. /// <returns></returns>
  1252. [HttpPost]
  1253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1254. public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
  1255. {
  1256. bool rst = false;
  1257. if (_dto.SysUserId < 1)
  1258. {
  1259. return Ok(JsonView(false, "操作人失效"));
  1260. }
  1261. Sys_Users _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
  1262. if (_sysUser == null)
  1263. {
  1264. return Ok(JsonView(false, "操作人失效02"));
  1265. }
  1266. if (_dto.EditType >= 0)
  1267. {
  1268. if (_dto.ReadLevel < 1)
  1269. {
  1270. return Ok(JsonView(false, "未知的阅读等级"));
  1271. }
  1272. if (string.IsNullOrEmpty(_dto.Title.Trim()))
  1273. {
  1274. return Ok(JsonView(false, "标题不能为空"));
  1275. }
  1276. if (string.IsNullOrEmpty(_dto.Content.Trim()))
  1277. {
  1278. return Ok(JsonView(false, "正文内容不能为空"));
  1279. }
  1280. //新增备忘录
  1281. DateTime dtNow = DateTime.Now;
  1282. string dir = AppSettingsHelper.Get("MemoCurrPath");
  1283. string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
  1284. string content = JsonConvert.SerializeObject(_dto.Content);
  1285. if (_dto.EditType == 0)//新增
  1286. {
  1287. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1288. if (savePath.Length > 0)
  1289. {
  1290. Res_MemoInfo _insert = new Res_MemoInfo();
  1291. _insert.Abstracts = _dto.Abstracts;
  1292. _insert.Title = _dto.Title;
  1293. _insert.DepartmentId = _sysUser.DepId;
  1294. _insert.CreateUserId = _sysUser.Id;
  1295. _insert.LastedEditDt = dtNow;
  1296. _insert.LastedEditor = _sysUser.Id;
  1297. _insert.MDFilePath = savePath;
  1298. _insert.ReadLevel = _dto.ReadLevel;
  1299. _insert.Title = _dto.Title;
  1300. int result = await _resItemInfoRep.AddAsync(_insert);
  1301. return Ok(JsonView(result > 0));
  1302. }
  1303. else
  1304. {
  1305. return Ok(JsonView(false, "路径保存失败"));
  1306. }
  1307. }
  1308. else//修改
  1309. {
  1310. if (_dto.MemoId < 1)
  1311. {
  1312. return Ok(JsonView(false, "MemoId不存在"));
  1313. }
  1314. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1315. if (_source == null)
  1316. {
  1317. return Ok(JsonView(false, "MemoInfo不存在"));
  1318. }
  1319. //修改
  1320. string sourcePath = _source.MDFilePath;
  1321. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1322. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1323. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1324. if (savePath.Length > 0)
  1325. {
  1326. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1327. .SetColumns(it => it.LastedEditDt == DateTime.Now)
  1328. .SetColumns(it => it.LastedEditor == _sysUser.Id)
  1329. .SetColumns(it => it.Abstracts == _dto.Abstracts)
  1330. .SetColumns(it => it.MDFilePath == savePath)
  1331. .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
  1332. .SetColumns(it => it.Title == _dto.Title)
  1333. .Where(s => s.Id == _source.Id)
  1334. .ExecuteCommandAsync();
  1335. return Ok(JsonView(result > 0));
  1336. }
  1337. }
  1338. }
  1339. else
  1340. {
  1341. //删除
  1342. if (_dto.MemoId < 1)
  1343. {
  1344. return Ok(JsonView(false, "MemoId不存在"));
  1345. }
  1346. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1347. if (_source == null)
  1348. {
  1349. return Ok(JsonView(false, "MemoInfo不存在"));
  1350. }
  1351. //修改
  1352. string sourcePath = _source.MDFilePath;
  1353. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1354. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1355. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1356. .SetColumns(it => it.IsDel == 1)
  1357. .SetColumns(it => it.DeleteUserId == _sysUser.Id)
  1358. .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  1359. .Where(s => s.Id == _source.Id)
  1360. .ExecuteCommandAsync();
  1361. return Ok(JsonView(result > 0));
  1362. }
  1363. return Ok(JsonView(rst));
  1364. }
  1365. #endregion
  1366. #region 商邀资料
  1367. /// <summary>
  1368. /// 商邀资料 基础数据源
  1369. /// </summary>
  1370. /// <param name="dto"></param>
  1371. /// <returns></returns>
  1372. [HttpPost]
  1373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1374. public async Task<IActionResult> QueryIOAInitData(QueryIOAInitDataDto dto)
  1375. {
  1376. try
  1377. {
  1378. #region 参数验证
  1379. if (dto.PortType < 1) return Ok(JsonView(false, "请传入有效的PortType参数!"));
  1380. #endregion
  1381. List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.JietuanTime).ToList();
  1382. List<Res_InvitationOfficialActivityData> _ioaDatas = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().Where(it => it.IsDel == 0).ToList();
  1383. List<Sys_Users> _Users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
  1384. var _countryData = _ioaDatas.Select(it => it.Country).Distinct().ToList(); _countryData.Remove("");
  1385. var _inviterData = _ioaDatas.Select(it => it.UnitName).Distinct().ToList(); _inviterData.Remove("");
  1386. var _contactData = _ioaDatas.Select(it => it.Contact).Distinct().ToList(); _contactData.Remove("");
  1387. var _domainData = _ioaDatas.Select(it => it.Field).Distinct().ToList(); _domainData.Remove("");
  1388. var _groupNameData = _DelegationInfos.Select(it => new { it.Id, it.TeamName }).ToList();
  1389. var _userNameData = _Users.Select(it => new { it.Id, it.CnName }).ToList();
  1390. var _data = new
  1391. {
  1392. CountryData = _countryData,
  1393. InviterData = _inviterData,
  1394. DomainData = _domainData,
  1395. ContactData = _contactData,
  1396. GroupNameData = _groupNameData,
  1397. UserNameData = _userNameData,
  1398. };
  1399. return Ok(JsonView(true, $"查询成功!", _data));
  1400. }
  1401. catch (Exception ex)
  1402. {
  1403. return Ok(JsonView(false, ex.Message));
  1404. }
  1405. }
  1406. /// <summary>
  1407. /// 商邀资料查询
  1408. /// </summary>
  1409. /// <param name="dto"></param>
  1410. /// <returns></returns>
  1411. [HttpPost]
  1412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1413. public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
  1414. {
  1415. var ExcludedKeyStr = new string[] { "快递费" };
  1416. var ClientKeyStr = new string[] { "邀请函翻译" };
  1417. try
  1418. {
  1419. #region 参数验证
  1420. if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
  1421. if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
  1422. #endregion
  1423. string sqlWhere = string.Empty;
  1424. if (!string.IsNullOrWhiteSpace(dto.Country)) { sqlWhere += string.Format(@" And i.Country like '%{0}%'", dto.Country); }
  1425. if (!string.IsNullOrWhiteSpace(dto.UnitName)) { sqlWhere += string.Format(@" And i.UnitName like '%{0}%'", dto.UnitName); }
  1426. if (!string.IsNullOrWhiteSpace(dto.Contact)) { sqlWhere += string.Format(@" And i.Contact like '%{0}%'", dto.Contact); }
  1427. if (!string.IsNullOrWhiteSpace(dto.Delegation)) { sqlWhere += string.Format(@" And i.Delegation like '%{0}%'", dto.Delegation); }
  1428. if (!string.IsNullOrWhiteSpace(dto.Field)) { sqlWhere += string.Format(@" And i.Field like '%{0}%'", dto.Field); }
  1429. if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { sqlWhere += string.Format(@" And i.CreateUserId={0}", dto.CreateUserId); }
  1430. if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
  1431. {
  1432. sqlWhere += string.Format(@" And i.CreateTime between '{0}' and '{1}'", dto.StartCreateTime, dto.EndCreateTime);
  1433. }
  1434. sqlWhere += string.Format(@"And i.Isdel={0}", 0);
  1435. foreach (var item in ExcludedKeyStr)
  1436. {
  1437. sqlWhere += $" And i.UnitName not like '%{item}%' ";
  1438. }
  1439. foreach (var item in ClientKeyStr)
  1440. {
  1441. sqlWhere += $" And i.Contact not like '%{item}%' ";
  1442. }
  1443. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  1444. {
  1445. Regex r = new Regex("And");
  1446. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  1447. }
  1448. string sql = string.Format(@"Select ROW_NUMBER() Over(Order By i.CreateTime Desc) As Row_Number,
  1449. i.*,u.CnName As CreateUserName
  1450. From Res_InvitationOfficialActivityData i
  1451. Left Join Sys_Users u On i.CreateUserId = u.Id {0}", sqlWhere);
  1452. RefAsync<int> totalCount = 0;
  1453. var _ivitiesViews = await _sqlSugar.SqlQueryable<InvitationOfficialActivityDataView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, totalCount);
  1454. //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().ToList();
  1455. foreach (var item in _ivitiesViews)
  1456. {
  1457. string groupNameStr = "";
  1458. if (!string.IsNullOrEmpty(item.Delegation))
  1459. {
  1460. int[] groupIds = item.Delegation.Split(',').Select(x =>
  1461. {
  1462. int id;
  1463. if (int.TryParse(x, out id)) return id;
  1464. else return id;
  1465. }).ToArray();
  1466. var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => groupIds.Contains(x.Id)).ToList();
  1467. foreach (var group in _DelegationInfos)
  1468. {
  1469. groupNameStr += $"{group.TeamName},";
  1470. }
  1471. if (groupNameStr.Length > 1)
  1472. {
  1473. groupNameStr = groupNameStr.Substring(0, groupNameStr.Length - 1);
  1474. }
  1475. }
  1476. }
  1477. return Ok(JsonView(true, $"查询成功!", _ivitiesViews, totalCount));
  1478. }
  1479. catch (Exception ex)
  1480. {
  1481. return Ok(JsonView(false, ex.Message));
  1482. }
  1483. }
  1484. /// <summary>
  1485. /// 根据商邀资料Id查询信息
  1486. /// </summary>
  1487. /// <param name="id"></param>
  1488. /// <returns></returns>
  1489. [HttpGet("{id}")]
  1490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1491. public async Task<IActionResult> QueryInvitationOfficialActivityById(int id)
  1492. {
  1493. if (id < 1) return Ok(JsonView(false, "Id参数错误!"));
  1494. return Ok(await _InvitationOfficialActivityDataRep.Info(id));
  1495. }
  1496. /// <summary>
  1497. /// 商邀资料操作(Status:1.新增,2.修改)
  1498. /// </summary>
  1499. /// <param name="dto"></param>
  1500. /// <returns></returns>
  1501. [HttpPost]
  1502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1503. public async Task<IActionResult> OpInvitationOfficialActivity([FromForm] OpInvitationOfficialActivityDto dto)
  1504. {
  1505. return Ok(await _InvitationOfficialActivityDataRep.IOA_OP(dto));
  1506. }
  1507. /// <summary>
  1508. /// 商邀资料 删除文件
  1509. /// </summary>
  1510. /// <param name="id"></param>
  1511. /// <param name="fileName"></param>
  1512. /// <returns></returns>
  1513. [HttpDelete("{id}")]
  1514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1515. public async Task<IActionResult> InvitationOfficialActivityDelFile(int id, string fileName)
  1516. {
  1517. if (id < 1) return Ok(JsonView(false, "请传入有效的Id"));
  1518. if (string.IsNullOrEmpty(fileName)) return Ok(JsonView(false, "文件名称不能为空!"));
  1519. var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == id);
  1520. if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
  1521. var files = new List<string>();
  1522. try
  1523. {
  1524. files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
  1525. }
  1526. catch (Exception) { }
  1527. if (files != null && files.Count > 0 && files.Contains(fileName))
  1528. {
  1529. var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
  1530. if (System.IO.File.Exists(filePath))
  1531. {
  1532. System.IO.File.Delete(filePath);
  1533. }
  1534. //更改文件值
  1535. files.Remove(fileName);
  1536. var fileUpd = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
  1537. .SetColumns(x => x.SndFileName == JsonConvert.SerializeObject(files))
  1538. .Where(x => x.Id == id)
  1539. .ExecuteCommandAsync();
  1540. if (fileUpd > 0) return Ok(JsonView(true, "操作成功!"));
  1541. }
  1542. return Ok(JsonView(false, "操作失败!"));
  1543. }
  1544. /// <summary>
  1545. /// 删除商邀资料信息
  1546. /// </summary>
  1547. /// <param name="dto"></param>
  1548. /// <returns></returns>
  1549. [HttpPost]
  1550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1551. public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
  1552. {
  1553. var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
  1554. if (!res) return Ok(JsonView(false, "删除失败"));
  1555. var info = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync(x => x.Id == dto.Id);
  1556. if (info == null) return Ok(JsonView(false, "该条数据不存在!"));
  1557. var files = new List<string>();
  1558. try
  1559. {
  1560. files = JsonConvert.DeserializeObject<List<string>>(info.SndFileName);
  1561. }
  1562. catch (Exception) { }
  1563. if (files != null && files.Count > 0)
  1564. {
  1565. foreach (var fileName in files)
  1566. {
  1567. var filePath = $@"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{fileName}";
  1568. if (System.IO.File.Exists(filePath))
  1569. {
  1570. System.IO.File.Delete(filePath);
  1571. }
  1572. }
  1573. }
  1574. return Ok(JsonView(true, "删除成功!"));
  1575. }
  1576. #endregion
  1577. #region 公务出访
  1578. /// <summary>
  1579. /// 获取团组所有信息,绑定下拉框
  1580. /// </summary>
  1581. /// <param name="dto"></param>
  1582. /// <returns></returns>
  1583. [HttpPost]
  1584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1585. public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
  1586. {
  1587. //string groupSql = string.Format("Select * From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By CreateTime Desc");
  1588. //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.SqlQueryable< Grp_DelegationInfo >(groupSql).ToList();
  1589. var _groupData = await _delegationInfoRep.PostShareGroupInfos(1);
  1590. dynamic groupInfos = null;
  1591. if (_groupData.Code == 0) groupInfos = _groupData.Data;
  1592. var data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 38).ToList();
  1593. var _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
  1594. return Ok(JsonView(true, "查询成功!", new { Delegation = groupInfos, SetData = data, DeleFile = _DeleFile }));
  1595. }
  1596. /// <summary>
  1597. /// 公务List
  1598. /// </summary>
  1599. /// <param name="dto"></param>
  1600. /// <returns></returns>
  1601. [HttpPost]
  1602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1603. public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
  1604. {
  1605. return Ok(await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto));
  1606. }
  1607. /// <summary>
  1608. /// 根据公务出访数据Id查询数据
  1609. /// </summary>
  1610. /// <param name="dto"></param>
  1611. /// <returns></returns>
  1612. [HttpPost]
  1613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1614. public async Task<IActionResult> QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
  1615. {
  1616. try
  1617. {
  1618. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
  1619. if (groupData.Code != 0)
  1620. {
  1621. return Ok(JsonView(false, groupData.Msg));
  1622. }
  1623. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1624. }
  1625. catch (Exception ex)
  1626. {
  1627. return Ok(JsonView(false, "程序错误!"));
  1628. throw;
  1629. }
  1630. }
  1631. /// <summary>
  1632. /// 公务出访操作(Status:1.新增,2.修改)
  1633. /// </summary>
  1634. /// <param name="dto"></param>
  1635. /// <returns></returns>
  1636. [HttpPost]
  1637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1638. public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
  1639. {
  1640. Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
  1641. if (groupData.Code != 0)
  1642. {
  1643. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, new { Id = 0 }));
  1644. }
  1645. try
  1646. {
  1647. //公务出访变更发送通知
  1648. await AppNoticeLibrary.SendUserMsg_GroupShare_ToOP(dto.DiId, dto.CreateUserId);
  1649. }
  1650. catch (Exception ex)
  1651. {
  1652. //抄送日志
  1653. }
  1654. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1655. }
  1656. /// <summary>
  1657. /// 上传文件(邮件截图)
  1658. /// </summary>
  1659. /// <param name="file"></param>
  1660. /// <returns></returns>
  1661. [HttpPost]
  1662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1663. public async Task<IActionResult> OfficialActivitiesUploadFiles([FromForm] OfficialActivitiesUploadFilesDto dto)
  1664. {
  1665. string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1666. string localPath = AppSettingsHelper.Get("GrpFileBasePath");
  1667. string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
  1668. if (dto.diId < 1 || dto.currUserId < 1)
  1669. {
  1670. return Ok(JsonView(false, "参数有误,上传失败!"));
  1671. }
  1672. if (dto.files == null || dto.files.Count < 1)
  1673. {
  1674. return Ok(JsonView(false, "文件为空,上传失败!"));
  1675. }
  1676. string localFileDir = $"{localPath}{ptfPath}";
  1677. List<string> fileUrls = new List<string>();
  1678. string[] failFiles = new string[] { };
  1679. foreach (var file in dto.files)
  1680. {
  1681. //文件名称
  1682. string[] fileNameArray = file.FileName.Split(".");
  1683. string projectFileName = $"{fileNameArray[0].ToString().Replace("-", "_").Replace("/", "_")}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileNameArray[1].ToString()}";
  1684. //上传的文件的路径
  1685. string filePath = $@"{localPath}公务相关文件";
  1686. if (!Directory.Exists(filePath))
  1687. {
  1688. Directory.CreateDirectory(filePath);
  1689. }
  1690. var path = Path.Combine(filePath, projectFileName);
  1691. //using var stream = new FileStream(path, FileMode.Create);
  1692. //await file.CopyToAsync(stream);
  1693. try
  1694. {
  1695. using (FileStream fs = System.IO.File.Create(path))
  1696. {
  1697. file.CopyTo(fs);
  1698. fs.Flush();
  1699. }
  1700. fileUrls.Add($"/{ptfPath}公务相关文件/{projectFileName}");
  1701. }
  1702. catch (Exception ex)
  1703. {
  1704. failFiles.Append(file.FileName);
  1705. }
  1706. }
  1707. var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.id).FirstAsync();
  1708. List<string> files = new List<string>();
  1709. var status = false;
  1710. var _oaInfo = new Res_OfficialActivities()
  1711. {
  1712. DiId = dto.diId,
  1713. ScreenshotOfMailUrl = JsonConvert.SerializeObject(fileUrls),
  1714. IsDel = 0,
  1715. CreateUserId = dto.currUserId,
  1716. CreateTime = DateTime.Now
  1717. };
  1718. if (oaInfo == null)
  1719. {
  1720. var id = await _sqlSugar.Insertable<Res_OfficialActivities>(_oaInfo)
  1721. .ExecuteReturnIdentityAsync();
  1722. if (id > 0)
  1723. {
  1724. status = true;
  1725. dto.id = id;
  1726. }
  1727. }
  1728. else
  1729. {
  1730. var oldFiles = string.IsNullOrEmpty(oaInfo.ScreenshotOfMailUrl)
  1731. ? new List<string>()
  1732. : JsonConvert.DeserializeObject<List<string>>(oaInfo.ScreenshotOfMailUrl);
  1733. if (oldFiles.Count > 0)
  1734. {
  1735. fileUrls.AddRange(oldFiles);
  1736. }
  1737. fileUrls = fileUrls.Distinct().ToList();
  1738. if (fileUrls.Count() > 0)
  1739. {
  1740. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  1741. .SetColumns(x => x.ScreenshotOfMailUrl == JsonConvert.SerializeObject(fileUrls))
  1742. .Where(x => x.Id == dto.id)
  1743. .ExecuteCommandAsync();
  1744. if (upd > 0) status = true;
  1745. }
  1746. }
  1747. List<string> returnFileUrls = new List<string>();
  1748. fileUrls.ForEach(x =>
  1749. {
  1750. returnFileUrls.Add($"{networkPath}{x}");
  1751. });
  1752. if (status)
  1753. {
  1754. string msg = "操作成功!";
  1755. if (failFiles.Length > 1)
  1756. {
  1757. foreach (var item in failFiles)
  1758. {
  1759. msg += $"{failFiles}、";
  1760. }
  1761. msg = msg.Substring(0, msg.Length - 1);
  1762. msg += "等文件保存失败!";
  1763. }
  1764. return Ok(JsonView(true, msg, new { id = dto.id, fileUrls = returnFileUrls }));
  1765. }
  1766. return Ok(JsonView(false, "操作失败!"));
  1767. }
  1768. /// <summary>
  1769. /// 删除文件(邮件截图)
  1770. /// </summary>
  1771. /// <param name="file"></param>
  1772. /// <returns></returns>
  1773. [HttpPost]
  1774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1775. public async Task<IActionResult> OfficialActivitiesDelFile(OfficialActivitiesDelFileDto dto)
  1776. {
  1777. string networkPath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1778. string localPath = AppSettingsHelper.Get("GrpFileBasePath");
  1779. string ptfPath = AppSettingsHelper.Get("GrpFileFtpPath");
  1780. if (dto.Id < 1 || string.IsNullOrEmpty(dto.FileName))
  1781. {
  1782. return Ok(JsonView(false, "参数有误,上传失败!"));
  1783. }
  1784. string localFileDir = $"{localPath}{ptfPath}";
  1785. List<string> fileUrls = new List<string>();
  1786. var oaInfo = await _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.Id == dto.Id).FirstAsync();
  1787. if (oaInfo != null)
  1788. {
  1789. string urlJson = oaInfo.ScreenshotOfMailUrl ?? "";
  1790. if (!string.IsNullOrEmpty(urlJson))
  1791. {
  1792. List<string> urls = JsonConvert.DeserializeObject<List<string>>(urlJson);
  1793. var filePath = urls.Find(x => x.Contains(dto.FileName));
  1794. if (string.IsNullOrEmpty(filePath)) return Ok(JsonView(false, "文件不存在!"));
  1795. var updFile = urls.Remove(filePath);
  1796. if (updFile)
  1797. {
  1798. //删除文件
  1799. string fileUrl = AppSettingsHelper.Get("GrpFileBasePath").Replace(@"/Office/GrpFile", "") + filePath;
  1800. if (System.IO.File.Exists(fileUrl))
  1801. {
  1802. System.IO.File.Delete(fileUrl);
  1803. }
  1804. string urlJsonstr = JsonConvert.SerializeObject(urls);
  1805. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  1806. .SetColumns(x => x.ScreenshotOfMailUrl == urlJsonstr)
  1807. .Where(x => x.Id == dto.Id)
  1808. .ExecuteCommandAsync();
  1809. if (upd > 0) return Ok(JsonView(true, "操作成功!"));
  1810. }
  1811. }
  1812. }
  1813. return Ok(JsonView(false, "操作失败!"));
  1814. }
  1815. /// <summary>
  1816. /// 公务出访 确认、取消邀请
  1817. /// </summary>
  1818. /// <param name="file"></param>
  1819. /// <returns></returns>
  1820. [HttpPost]
  1821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1822. public async Task<IActionResult> OfficialActivitiesInviteOperation(OfficialActivitiesInviteOperationDto dto)
  1823. {
  1824. if (dto.Id < 1) return Ok(JsonView(false, "Id参数有误!"));
  1825. if (dto.Type < 0 || dto.Type > 1) return Ok(JsonView(false, "Type参数有误!"));
  1826. var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
  1827. .SetColumns(x => x.ConfirmTheInvitation == dto.Type)
  1828. .Where(x => x.Id == dto.Id)
  1829. .ExecuteCommandAsync();
  1830. if (upd > 0) return Ok(JsonView(true, "操作成功!"));
  1831. return Ok(JsonView(false, "操作失败!"));
  1832. }
  1833. /// <summary>
  1834. /// 上传文件
  1835. /// </summary>
  1836. /// <param name="file"></param>
  1837. /// <returns></returns>
  1838. [HttpPost]
  1839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1840. public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
  1841. {
  1842. try
  1843. {
  1844. int Type = int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
  1845. int DiId = int.Parse(Request.Headers["DiId"]);
  1846. int CreateUserId = int.Parse(Request.Headers["CreateUserId"]);
  1847. if (file != null)
  1848. {
  1849. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1850. //文件名称
  1851. string projectFileName = file.FileName;
  1852. //上传的文件的路径
  1853. string filePath = "";
  1854. if (!Directory.Exists(fileDir))
  1855. {
  1856. Directory.CreateDirectory(fileDir);
  1857. }
  1858. //上传的文件的路径
  1859. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1860. using (FileStream fs = System.IO.File.Create(filePath))
  1861. {
  1862. file.CopyTo(fs);
  1863. fs.Flush();
  1864. }
  1865. Grp_DeleFile d = new Grp_DeleFile();
  1866. d.Diid = DiId;
  1867. d.Category = 970;
  1868. if (Type == 1) d.Kind = 1;
  1869. else if (Type == 2) d.Kind = 2;
  1870. else if (Type == 3) d.Kind = 3;
  1871. d.FileName = projectFileName;
  1872. d.FilePath = "";
  1873. d.CreateUserId = CreateUserId;
  1874. int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
  1875. return Ok(JsonView(true, "上传成功!", projectFileName));
  1876. }
  1877. else
  1878. {
  1879. return Ok(JsonView(false, "上传失败!"));
  1880. }
  1881. }
  1882. catch (Exception ex)
  1883. {
  1884. return Ok(JsonView(false, "程序错误!"));
  1885. throw;
  1886. }
  1887. }
  1888. /// <summary>
  1889. /// 删除文件
  1890. /// </summary>
  1891. /// <param name="dto"></param>
  1892. /// <returns></returns>
  1893. [HttpPost]
  1894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1895. public async Task<IActionResult> DelloadOfficialActivities(DelBaseDto dto)
  1896. {
  1897. try
  1898. {
  1899. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1900. Grp_DeleFile _DeleFile = await _sqlSugar.Queryable<Grp_DeleFile>().FirstAsync(a => a.Id == dto.Id);
  1901. if (_DeleFile != null)
  1902. {
  1903. string fileName = _DeleFile.FileName;
  1904. string filePath = fileDir + "/团组增减款项相关文件/" + fileName;
  1905. // 删除该文件
  1906. System.IO.File.Delete(filePath);
  1907. 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();
  1908. return Ok(JsonView(true, "取消文件成功!"));
  1909. }
  1910. else
  1911. {
  1912. return Ok(JsonView(false, "取消文件失败!"));
  1913. }
  1914. }
  1915. catch (Exception ex)
  1916. {
  1917. return Ok(JsonView(false, "程序错误!"));
  1918. throw;
  1919. }
  1920. }
  1921. /// <summary>
  1922. /// 删除公务出访信息
  1923. /// </summary>
  1924. /// <param name="dto"></param>
  1925. /// <returns></returns>
  1926. [HttpPost]
  1927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1928. public async Task<IActionResult> DelOfficialActivities(DelBaseDto dto)
  1929. {
  1930. try
  1931. {
  1932. var res = await _officialActivitiesRep.SoftDeleteByIdAsync<Res_OfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  1933. if (!res)
  1934. {
  1935. return Ok(JsonView(false, "删除失败"));
  1936. }
  1937. return Ok(JsonView(true, "删除成功!"));
  1938. }
  1939. catch (Exception ex)
  1940. {
  1941. return Ok(JsonView(false, "程序错误!"));
  1942. throw;
  1943. }
  1944. }
  1945. /// <summary>
  1946. /// 公务出访
  1947. /// 请示范例提示
  1948. /// Add Time:2024-05-13 13:56:44
  1949. /// </summary>
  1950. /// <param name="dto"></param>
  1951. /// <returns></returns>
  1952. [HttpPost]
  1953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1954. public async Task<IActionResult> PostOfficialActivitiesReqReqSampleTips(PostOfficialActivitiesReqReqSampleTipsDto dto)
  1955. {
  1956. var res = await _officialActivitiesRep.PostReqReqSampleTips(dto.country, dto.area, dto.client);
  1957. if (res.Code == 0)
  1958. {
  1959. return Ok(JsonView(true, "操作成功!", res.Data));
  1960. }
  1961. return Ok(JsonView(false, res.Msg));
  1962. }
  1963. /// <summary>
  1964. /// 公务出访 (省外办,市外办) File Downlaod
  1965. /// </summary>
  1966. /// <param name="dto"></param>
  1967. /// <returns></returns>
  1968. [HttpPost]
  1969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1970. public async Task<IActionResult> OfficialActivitiesFileDownload(OfficialActivitiesFileDownload dto)
  1971. {
  1972. #region 参数验证
  1973. if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示", ""));
  1974. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数.", ""));
  1975. #endregion
  1976. //团组基础信息
  1977. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  1978. if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在", ""));
  1979. groupInfo.VisitCountry = groupInfo.VisitCountry.Replace("|", "、");
  1980. //团组公务信息
  1981. var obDatas = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderBy(it => it.Date).ToList();
  1982. //if (obDatas.Count < 1) return Ok(JsonView(false, "请先录入公务信息!"));
  1983. //团组客户名单
  1984. var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
  1985. List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
  1986. if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
  1987. string visitCountrys = ""; //××国家(或地区)×天,××国家(或地区)×天
  1988. string countryStayStr = ""; // xx、xx、xx
  1989. //出入境费用 住宿类型
  1990. var dayCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId && it.Type == 1).ToList();
  1991. if (dayCostDatas.Count > 0)
  1992. {
  1993. List<int> nationalIds = dayCostDatas.Select(it => it.NationalTravelFeeId).ToList();
  1994. var nationalDatas = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => nationalIds.Contains(it.Id)).ToList();
  1995. var nationalDataGroupByCountry = nationalDatas.GroupBy(it => it.Country);
  1996. foreach (var item in nationalDataGroupByCountry)
  1997. {
  1998. visitCountrys += $"{item.Key}、";
  1999. int stayDays = nationalIds.Where(it => it == item.ToList()[0].Id).Count();
  2000. countryStayStr += $"{item.Key}{stayDays}天,";
  2001. }
  2002. if (visitCountrys.Length > 0) visitCountrys = visitCountrys.Substring(0, visitCountrys.Length - 1);
  2003. if (countryStayStr.Length > 0) countryStayStr = countryStayStr.Substring(0, countryStayStr.Length - 1);
  2004. }
  2005. else
  2006. {
  2007. visitCountrys = groupInfo.VisitCountry;
  2008. countryStayStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
  2009. }
  2010. //出访人数
  2011. int visitPeopleNum = groupInfo.VisitPNumber;
  2012. int visitDaysNum = groupInfo.VisitDays;
  2013. //出访单位
  2014. string obInfoStr = "";
  2015. foreach (var ob in obDatas) obInfoStr += @$"{ob.Client.Trim()}{ob.Job.Trim()}{ob.Contact.Trim()}、";
  2016. if (obInfoStr.Length > 0) obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
  2017. obInfoStr = obInfoStr ?? "[公务出访未录入]";
  2018. //出访路线
  2019. string lineStr = GeneralMethod.GetGroupCityLine(groupInfo.Id, "—");
  2020. if (dto.FileType == 1)
  2021. {
  2022. //载入模板
  2023. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
  2024. var doc = new Document(tempPath);
  2025. DocumentBuilder builder = new DocumentBuilder(doc);
  2026. //键值对存放数据
  2027. Dictionary<string, string> dic = new Dictionary<string, string>();
  2028. //××(组团单位):接团客户信息团组
  2029. dic.Add("GroupClient", $"{groupInfo.ClientUnit}\r\n");
  2030. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  2031. string guestName = "";
  2032. string guestJob = "";
  2033. string guestInfoStr = "";
  2034. var guestFirstInfo = guestInfos.FirstOrDefault();
  2035. if (guestFirstInfo != null)
  2036. {
  2037. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  2038. guestJob = guestFirstInfo.Job.Trim();
  2039. guestInfoStr = $@"{guestJob}、{guestName}";
  2040. }
  2041. guestInfoStr = guestInfoStr ?? "[接团客户名单未录入]";
  2042. string askTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  2043. dic.Add("AskTitle", askTitle);
  2044. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
  2045. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  2046. string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。现请示如下。";
  2047. dic.Add("AskSubTitle", askSubTitle);
  2048. //出访目的
  2049. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  2050. //出访任务
  2051. //(一)××(国家或地区)
  2052. //1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  2053. //2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  2054. string obBackgroundStr = "";//出访背景
  2055. string taskStr = ""; ; //出访任务
  2056. var countrys = obDatas.GroupBy(it => it.Country);
  2057. int countryIndex = 1;
  2058. foreach (var item in countrys)
  2059. {
  2060. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item.Key}\r\n";
  2061. string taskContent = "";
  2062. string obBackgroundContent = "";
  2063. int obIndex = 1;
  2064. foreach (var obInfo in item.ToList())
  2065. {
  2066. string reqSmaple = "";
  2067. string settingStr = "";
  2068. if (!string.IsNullOrEmpty(obInfo.ReqSample)) reqSmaple = obInfo.ReqSample;
  2069. else reqSmaple = "[公务出访请示范例未录入]";
  2070. if (!string.IsNullOrEmpty(obInfo.Setting)) settingStr = obInfo.Setting;
  2071. else settingStr = "[公务方背景未录入]";
  2072. taskContent += $"{obIndex}. {reqSmaple}\r\n";
  2073. obBackgroundContent += $"{obIndex}. {obInfo.Client}:{settingStr}\r\n";
  2074. obIndex++;
  2075. }
  2076. taskStr += $"{taskTitle}{taskContent}";
  2077. obBackgroundStr += $"{taskTitle}{obBackgroundContent}";
  2078. countryIndex++;
  2079. }
  2080. //出访背景
  2081. if (obBackgroundStr.Length < 1) obBackgroundStr = "[公务出访背景未录入]";
  2082. dic.Add("OBSetting", obBackgroundStr);
  2083. //出访任务
  2084. if (taskStr.Length < 1) taskStr = "[公务出访任务未录入]";
  2085. dic.Add("TaskContent", taskStr);
  2086. //出访时间
  2087. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。
  2088. string visitTimeQuantumStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。";
  2089. //出访时间
  2090. dic.Add("TimeQuantum", visitTimeQuantumStr);
  2091. //出访路线
  2092. //成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)
  2093. dic.Add("Line", lineStr);
  2094. //scheduling //行程安排
  2095. string schedulingStr = $"[OP行程单暂未生成]";
  2096. #region op行程 根据黑屏代码录入
  2097. var opTripView = GeneralMethod.GetBriefStroke(groupInfo.Id);
  2098. if (opTripView.Code != 0) schedulingStr = $"[{opTripView.Msg}]";
  2099. schedulingStr = "";
  2100. List<Grp_TravelList> travelList = new List<Grp_TravelList>();
  2101. travelList = opTripView.Data as List<Grp_TravelList>;
  2102. if (travelList != null)
  2103. {
  2104. foreach (var item in travelList)
  2105. {
  2106. schedulingStr += $"{item.Date}({item.WeekDay})\r\n{item.Trip}\r\n";
  2107. }
  2108. }
  2109. #endregion
  2110. dic.Add("Scheduling", schedulingStr);
  2111. #region 填充word模板书签内容
  2112. foreach (var key in dic.Keys)
  2113. {
  2114. builder.MoveToBookmark(key);
  2115. builder.Write(dic[key]);
  2116. }
  2117. #endregion
  2118. //获取word里所有表格
  2119. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2120. //获取所填表格的序数
  2121. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2122. var rowStart = tableOne.Rows[0]; //获取第1行
  2123. //循环赋值
  2124. for (int i = 0; i < guestInfos.Count; i++)
  2125. {
  2126. var guestInfo = guestInfos[i];
  2127. builder.MoveToCell(0, i + 1, 0, 0);
  2128. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  2129. builder.MoveToCell(0, i + 1, 1, 0);
  2130. int sex = guestInfo.Sex;
  2131. string sexStr = string.Empty;
  2132. if (sex == 0) sexStr = "男";
  2133. else if (sex == 1) sexStr = "女";
  2134. else sexStr = "-";
  2135. builder.Write(sexStr);
  2136. builder.MoveToCell(0, i + 1, 2, 0);
  2137. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  2138. builder.MoveToCell(0, i + 1, 3, 0);
  2139. string birthDay = "";
  2140. string birthDayStr = string.Empty;
  2141. if (guestInfo.BirthDay != null)
  2142. {
  2143. birthDayStr = guestInfo.BirthDay.ToString("yyyy.MM");
  2144. }
  2145. builder.Write(birthDayStr);
  2146. }
  2147. //删除多余行
  2148. while (tableOne.Rows.Count > guestInfos.Count + 1)
  2149. {
  2150. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  2151. }
  2152. var fileDir = AppSettingsHelper.Get("WordBasePath");
  2153. string fileName = $"{groupInfo.TeamName}省外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  2154. string filePath = fileDir + $@"OfficialActivities/{fileName}";
  2155. doc.Save(filePath);
  2156. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  2157. return Ok(JsonView(true, "操作成功!", Url));
  2158. }
  2159. else if (dto.FileType == 2)
  2160. {
  2161. //载入模板
  2162. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示 - 模板.docx";
  2163. var doc = new Document(tempPath);
  2164. DocumentBuilder builder = new DocumentBuilder(doc);
  2165. //键值对存放数据
  2166. Dictionary<string, string> dic = new Dictionary<string, string>();
  2167. //××(组团单位):接团客户信息团组
  2168. dic.Add("GroupClient", $"{groupInfo.ClientUnit}");
  2169. dic.Add("GroupClient1", $"{groupInfo.ClientUnit}");
  2170. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  2171. string guestName = "";
  2172. string guestJob = "";
  2173. string guestInfoStr = "";
  2174. var guestFirstInfo = guestInfos.FirstOrDefault();
  2175. if (guestFirstInfo != null)
  2176. {
  2177. guestName = guestFirstInfo.LastName.Trim() + guestFirstInfo.FirstName.Trim();
  2178. guestJob = guestFirstInfo.Job;
  2179. guestInfoStr = $@"{guestJob}、{guestName.Trim()}";
  2180. }
  2181. string reqTitle = $@"关于{guestInfoStr}等{visitPeopleNum}人赴{visitCountrys}进行{groupInfo.VisitPurpose}的请示";
  2182. dic.Add("ReqTitle", reqTitle);
  2183. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。
  2184. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  2185. string reqSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{visitPeopleNum}人于{visitDateStr}赴{visitCountrys}进行{groupInfo.VisitPurpose}。";
  2186. dic.Add("ReqSubTitle", reqSubTitle);
  2187. /*
  2188. * 出访任务
  2189. * (一)××(国家或地区)
  2190. * 1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:由×××总领馆联合×××市政府共同举办的“×××活动”将于今年6月在×××举行。)
  2191. * 2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研等)×××(项目或机构名称等)。(例:拜会友城×××市市长×××,巩固和发展两市传统友谊,商谈两市未来互动交流合作项目。)背景:拟拜访机构的优势、拟洽谈项目的前期进展情况等。(例:背景:×××年×月,×××市与×××市正式缔结友好城市关系。在此框架下,两市开展了一系列友好互访和商务交流。并于×××年×月共同举办了“×××活动”。)
  2192. *
  2193. */
  2194. string taskStr = string.Empty;
  2195. List<string> countrys = obDatas.Where(it => !string.IsNullOrEmpty(it.Country)).Select(it => it.Country).ToList();
  2196. int countryIndex = 1;
  2197. foreach (var item in countrys)
  2198. {
  2199. string taskTitle = $"({GetToUpperNumber(countryIndex)}){item ?? "[公务出访国家未填写]"}\r\n";
  2200. string taskContent = "";
  2201. if (!string.IsNullOrEmpty(item))
  2202. {
  2203. var countryObDatas = obDatas.Where(it => !string.IsNullOrEmpty(it.Country) && it.Country.Contains(item)).OrderBy(it => it.Date).ToList();
  2204. int obIndex = 1;
  2205. if (countryObDatas.Count == 0) taskContent = "[公务出访未录入]\r\n";
  2206. else
  2207. {
  2208. foreach (var obInfo in countryObDatas)
  2209. {
  2210. taskContent += $"{obIndex}.{obInfo.ReqSample ?? "[公务出访请示范例未填写]"}\r\n背景:{obInfo.Setting ?? "[公务出访背景未填写]"}\r\n";
  2211. obIndex++;
  2212. }
  2213. }
  2214. }
  2215. taskStr += $"{taskTitle}{taskContent}";
  2216. countryIndex++;
  2217. }
  2218. if (string.IsNullOrEmpty(taskStr)) taskStr = "××××××";
  2219. //出访任务
  2220. dic.Add("TaskContent", taskStr);
  2221. //出访目的
  2222. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  2223. //出访信息
  2224. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。出访路线:成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)。
  2225. string tripInfoStr = "";
  2226. tripInfoStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{visitDaysNum}天。其中,{countryStayStr}。出访路线:{lineStr}。出访费用:由××承担(注明由外方或上级机关承担,还是由派员单位在年度安排的预算经费中列支)";
  2227. dic.Add("TripInfo", tripInfoStr);
  2228. #region 填充word模板书签内容
  2229. foreach (var key in dic.Keys)
  2230. {
  2231. builder.MoveToBookmark(key);
  2232. builder.Write(dic[key]);
  2233. }
  2234. #endregion
  2235. //获取word里所有表格
  2236. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2237. //获取所填表格的序数
  2238. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2239. var rowStart = tableOne.Rows[0]; //获取第1行
  2240. //循环赋值
  2241. for (int i = 0; i < guestInfos.Count; i++)
  2242. {
  2243. var guestInfo = guestInfos[i];
  2244. builder.MoveToCell(0, i + 1, 0, 0);
  2245. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  2246. builder.MoveToCell(0, i + 1, 1, 0);
  2247. int sex = guestInfo.Sex;
  2248. string sexStr = string.Empty;
  2249. if (sex == 0) sexStr = "男";
  2250. else if (sex == 1) sexStr = "女";
  2251. else sexStr = "未设置";
  2252. builder.Write(sexStr);
  2253. builder.MoveToCell(0, i + 1, 2, 0);
  2254. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  2255. builder.MoveToCell(0, i + 1, 3, 0);
  2256. DateTime birthDay = guestInfo.BirthDay;
  2257. string birthDayStr = string.Empty;
  2258. if (birthDay != null)
  2259. {
  2260. birthDayStr = birthDay.ToString("yyyy.MM");
  2261. }
  2262. builder.Write(birthDayStr);
  2263. }
  2264. //删除多余行
  2265. while (tableOne.Rows.Count > guestInfos.Count + 1)
  2266. {
  2267. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  2268. }
  2269. var fileDir = AppSettingsHelper.Get("WordBasePath");
  2270. var fileName = $"{groupInfo.TeamName}市外办出访请示{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx";
  2271. var filePath = fileDir + $@"OfficialActivities/{fileName}";
  2272. doc.Save(filePath);
  2273. var url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  2274. return Ok(JsonView(true, "操作成功!", url));
  2275. }
  2276. return Ok(JsonView(true, "操作失败!", ""));
  2277. }
  2278. private string GetToUpperNumber(int num)
  2279. {
  2280. string numStr = "";
  2281. if (num == 1) numStr = "一";
  2282. else if (num == 2) numStr = "二";
  2283. else if (num == 3) numStr = "三";
  2284. else if (num == 4) numStr = "四";
  2285. else if (num == 5) numStr = "五";
  2286. else if (num == 6) numStr = "六";
  2287. else if (num == 7) numStr = "七";
  2288. else if (num == 8) numStr = "八";
  2289. else if (num == 9) numStr = "九";
  2290. else if (num == 10) numStr = "十";
  2291. return numStr;
  2292. }
  2293. #endregion
  2294. #region 请示数据库
  2295. /// <summary>
  2296. /// 查询请示数据库初始化
  2297. /// </summary>
  2298. /// <param name="dto"></param>
  2299. /// <returns></returns>
  2300. [HttpPost]
  2301. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2302. public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
  2303. {
  2304. try
  2305. {
  2306. Result groupData = await _askDataRep.QueryAskData(dto);
  2307. if (groupData.Code != 0)
  2308. {
  2309. return Ok(JsonView(false, groupData.Msg));
  2310. }
  2311. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2312. }
  2313. catch (Exception ex)
  2314. {
  2315. return Ok(JsonView(false, "程序错误!"));
  2316. throw;
  2317. }
  2318. }
  2319. /// <summary>
  2320. /// 根据Id查询请示数据库单挑数据
  2321. /// </summary>
  2322. /// <param name="dto"></param>
  2323. /// <returns></returns>
  2324. [HttpPost]
  2325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2326. public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
  2327. {
  2328. try
  2329. {
  2330. Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
  2331. if (_AskData == null)
  2332. {
  2333. return Ok(JsonView(true, "暂无数据!", _AskData));
  2334. }
  2335. return Ok(JsonView(true, "查询成功!", _AskData));
  2336. }
  2337. catch (Exception ex)
  2338. {
  2339. return Ok(JsonView(false, "程序错误!"));
  2340. throw;
  2341. }
  2342. }
  2343. /// <summary>
  2344. /// 请示数据库操作(Status:1.新增,2.修改)
  2345. /// </summary>
  2346. /// <param name="dto"></param>
  2347. /// <returns></returns>
  2348. [HttpPost]
  2349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2350. public async Task<IActionResult> OpAskData(OpAskDataDto dto)
  2351. {
  2352. try
  2353. {
  2354. Result groupData = await _askDataRep.OpAskData(dto);
  2355. if (groupData.Code != 0)
  2356. {
  2357. return Ok(JsonView(false, groupData.Msg));
  2358. }
  2359. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2360. }
  2361. catch (Exception ex)
  2362. {
  2363. return Ok(JsonView(false, "程序错误!"));
  2364. throw;
  2365. }
  2366. }
  2367. /// <summary>
  2368. /// 删除请示资料信息
  2369. /// </summary>
  2370. /// <param name="dto"></param>
  2371. /// <returns></returns>
  2372. [HttpPost]
  2373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2374. public async Task<IActionResult> DelAskData(DelBaseDto dto)
  2375. {
  2376. try
  2377. {
  2378. var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
  2379. if (!res)
  2380. {
  2381. return Ok(JsonView(false, "删除失败"));
  2382. }
  2383. return Ok(JsonView(true, "删除成功!"));
  2384. }
  2385. catch (Exception ex)
  2386. {
  2387. return Ok(JsonView(false, "程序错误!"));
  2388. throw;
  2389. }
  2390. }
  2391. #endregion
  2392. #region 机票黑屏代码
  2393. /// <summary>
  2394. /// 根据团组Id查询黑屏代码列表
  2395. /// </summary>
  2396. /// <param name="dto"></param>
  2397. /// <returns></returns>
  2398. [HttpPost]
  2399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2400. public async Task<IActionResult> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
  2401. {
  2402. try
  2403. {
  2404. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(dto);
  2405. if (groupData.Code != 0)
  2406. {
  2407. return Ok(JsonView(false, groupData.Msg));
  2408. }
  2409. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2410. }
  2411. catch (Exception ex)
  2412. {
  2413. return Ok(JsonView(false, "程序错误!"));
  2414. throw;
  2415. }
  2416. }
  2417. /// <summary>
  2418. /// 根据黑屏代码数据Id查询信息
  2419. /// </summary>
  2420. /// <param name="dto"></param>
  2421. /// <returns></returns>
  2422. [HttpPost]
  2423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2424. public async Task<IActionResult> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
  2425. {
  2426. try
  2427. {
  2428. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(dto);
  2429. if (groupData.Code != 0)
  2430. {
  2431. return Ok(JsonView(false, groupData.Msg));
  2432. }
  2433. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2434. }
  2435. catch (Exception ex)
  2436. {
  2437. return Ok(JsonView(false, "程序错误!"));
  2438. throw;
  2439. }
  2440. }
  2441. /// <summary>
  2442. /// 黑屏代码操作(Status:1.新增,2.修改)
  2443. /// </summary>
  2444. /// <param name="dto"></param>
  2445. /// <returns></returns>
  2446. [HttpPost]
  2447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2448. public async Task<IActionResult> OpTicketBlackCode(OpTicketBlackCodeDto dto)
  2449. {
  2450. Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(dto);
  2451. if (groupData.Code != 0)
  2452. {
  2453. return Ok(JsonView(false, groupData.Msg));
  2454. }
  2455. try
  2456. {
  2457. var tongzhi = _ticketBlackCodeRep.DescBlackToVisa(dto.DiId);
  2458. if (tongzhi.Code == 0)
  2459. {
  2460. var info = tongzhi.Data.GetType().GetProperty("info").GetValue(tongzhi.Data) as List<string>;
  2461. var data = tongzhi.Data.GetType().GetProperty("data").GetValue(tongzhi.Data) as List<CountryDataTime>;
  2462. if (data != null)
  2463. await AppNoticeLibrary.SendUserMsg_blackAirInfo_ToVisaUser(dto.DiId, data);
  2464. }
  2465. //行程代码变更通知
  2466. await AppNoticeLibrary.SendUserMsg_GroupShare_ToDP(dto.DiId, dto.CreateUserId);
  2467. }
  2468. catch (Exception ex)
  2469. {
  2470. throw;
  2471. }
  2472. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2473. }
  2474. /// <summary>
  2475. /// 删除黑屏代码
  2476. /// </summary>
  2477. /// <param name="dto"></param>
  2478. /// <returns></returns>
  2479. [HttpPost]
  2480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2481. public async Task<IActionResult> DelTicketBlackCode(DelBaseDto dto)
  2482. {
  2483. try
  2484. {
  2485. var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync<Air_TicketBlackCode>(dto.Id.ToString(), dto.DeleteUserId);
  2486. if (!res)
  2487. {
  2488. return Ok(JsonView(false, "删除失败"));
  2489. }
  2490. return Ok(JsonView(true, "删除成功!"));
  2491. }
  2492. catch (Exception ex)
  2493. {
  2494. return Ok(JsonView(false, "程序错误!"));
  2495. throw;
  2496. }
  2497. }
  2498. #endregion
  2499. #region 翻译人员
  2500. /// <summary>
  2501. /// 翻译人员库
  2502. /// Init
  2503. /// </summary>
  2504. /// <param name="id"></param>
  2505. /// <returns></returns>
  2506. [HttpGet()]
  2507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2508. public async Task<IActionResult> TranslatorLibraryInit()
  2509. {
  2510. var view = await _sqlSugar.Queryable<Sys_SetData>()
  2511. .Where(x => x.IsDel == 0 && x.STid == 66)
  2512. .Select(x => new {
  2513. x.Id,
  2514. x.Name,
  2515. })
  2516. .ToListAsync();
  2517. return Ok(JsonView(view));
  2518. }
  2519. /// <summary>
  2520. /// 翻译人员库
  2521. /// 详情
  2522. /// </summary>
  2523. /// <param name="id"></param>
  2524. /// <returns></returns>
  2525. [HttpGet("id")]
  2526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2527. public async Task<IActionResult> TranslatorLibraryInfo(int id)
  2528. {
  2529. if (id <1 ) return Ok(JsonView(false,"请传入有效的Id!"));
  2530. var view = await _translatorRep.Query(x => x.Id == id)
  2531. .Select(x => new {
  2532. x.Id,
  2533. x.Name,
  2534. x.Sex,
  2535. x.Photo,
  2536. x.Tel,
  2537. x.Email,
  2538. x.WechatNo,
  2539. x.OtherSocialAccounts,
  2540. x.Language,
  2541. x.Price,
  2542. x.Currency,
  2543. x.Files
  2544. })
  2545. .FirstAsync();
  2546. return Ok(JsonView(view));
  2547. }
  2548. /// <summary>
  2549. /// 翻译人员库
  2550. /// Item
  2551. /// </summary>
  2552. /// <param name="dto"></param>
  2553. /// <returns></returns>
  2554. [HttpPost]
  2555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2556. public async Task<IActionResult> TranslatorLibraryItem(TranslatorLibraryItemDto dto)
  2557. {
  2558. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2559. RefAsync<int> total = 0;
  2560. var view = await _sqlSugar.Queryable<Res_TranslatorLibrary>()
  2561. .Where(x => x.IsDel == 0)
  2562. .WhereIF(!string.IsNullOrEmpty(dto.Name), x => x.Name.Contains(dto.Name))
  2563. .Select(x => new
  2564. {
  2565. x.Id,
  2566. x.Area,
  2567. x.Name,
  2568. Sex = x.Sex == 0 ? "未设置" : x.Sex == 1 ? "男" : "女",
  2569. x.Tel,
  2570. x.Email,
  2571. x.WechatNo,
  2572. x.Language,
  2573. x.Price,
  2574. x.Currency,
  2575. //Currency = SqlFunc.Subqueryable<Sys_SetData>().Where(x1 => x1.Id == x.Currency).Select(x1 => x1.Name) ?? "-",
  2576. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x1.Id == x.CreateUserId).Select(x1 => x1.CnName) ?? "-",
  2577. x.CreateTime
  2578. })
  2579. .OrderByDescending(x => x.CreateTime)
  2580. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  2581. return Ok(JsonView(view, total));
  2582. }
  2583. /// <summary>
  2584. /// 翻译人员库
  2585. /// OP
  2586. /// </summary>
  2587. /// <param name="dto"></param>
  2588. /// <returns></returns>
  2589. [HttpPost]
  2590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2591. public async Task<IActionResult> TranslatorLibraryOp(TranslatorLibraryOpDto dto)
  2592. {
  2593. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2594. if (dto.OpStatus < 1 || dto.OpStatus > 2) return Ok(JsonView(false, MsgTips.Status));
  2595. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  2596. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  2597. var fileNames = new List<string>();
  2598. //D:\FTP\File\OA2023\Office\GrpFile\TranslatorLibrary
  2599. var fileBasePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}TranslatorLibrary";
  2600. #region 保存文件
  2601. foreach (var item in dto.Files)
  2602. {
  2603. if (item.Length < 1) continue;
  2604. if (!System.IO.Directory.Exists(fileBasePath))
  2605. {
  2606. System.IO.Directory.CreateDirectory(fileBasePath);
  2607. }
  2608. var file = item;
  2609. // 将文件保存到指定位置
  2610. var filePath = Path.Combine(fileBasePath, file.FileName);
  2611. using (var stream = new FileStream(filePath, FileMode.Create))
  2612. {
  2613. await file.CopyToAsync(stream);
  2614. }
  2615. //验证文件是否上传成功
  2616. if (!System.IO.File.Exists(filePath))
  2617. {
  2618. foreach (var filePathStr in fileNames)
  2619. {
  2620. System.IO.File.Delete(Path.Combine(fileBasePath, filePathStr));
  2621. }
  2622. return Ok(JsonView(false, "文件上传失败!"));
  2623. }
  2624. fileNames.Add(file.Name);
  2625. }
  2626. #endregion
  2627. #region 参数处理
  2628. var translatorInfo = _mapper.Map<Res_TranslatorLibrary>(dto);
  2629. #endregion
  2630. if (dto.OpStatus == 1)
  2631. {
  2632. translatorInfo.CreateUserId = currUserInfo.UserId;
  2633. if (fileNames.Count > 0)
  2634. {
  2635. translatorInfo.Files = JsonConvert.SerializeObject(fileNames);
  2636. }
  2637. var add = await _translatorRep.AddAsync(translatorInfo);
  2638. if (add > 0) return Ok(JsonView(true));
  2639. }
  2640. else if (dto.OpStatus == 2)
  2641. {
  2642. var info = await _translatorRep.Query(x => x.Id == dto.Id).FirstAsync();
  2643. if (info != null)
  2644. {
  2645. if (!string.IsNullOrEmpty(info.Files))
  2646. {
  2647. try
  2648. {
  2649. var selectFiles = JsonConvert.DeserializeObject<List<string>>(info.Files);
  2650. fileNames.AddRange(selectFiles);
  2651. }
  2652. catch (Exception)
  2653. {
  2654. }
  2655. }
  2656. }
  2657. if (fileNames.Count > 0)
  2658. {
  2659. translatorInfo.Files = JsonConvert.SerializeObject(fileNames);
  2660. }
  2661. var upd = await _translatorRep
  2662. .UpdateAsync(x => x.Id == dto.Id, x => new Res_TranslatorLibrary()
  2663. {
  2664. Area = translatorInfo.Area,
  2665. Name = translatorInfo.Name,
  2666. Sex = translatorInfo.Sex,
  2667. Photo = translatorInfo.Photo,
  2668. Tel = translatorInfo.Tel,
  2669. Email = translatorInfo.Email,
  2670. WechatNo = translatorInfo.WechatNo,
  2671. OtherSocialAccounts = translatorInfo.OtherSocialAccounts,
  2672. Language = translatorInfo.Language,
  2673. Price = translatorInfo.Price,
  2674. Currency = translatorInfo.Currency,
  2675. Remark = translatorInfo.Remark,
  2676. Files = translatorInfo.Files,
  2677. });
  2678. if (upd) Ok(JsonView(true));
  2679. }
  2680. return Ok(JsonView(false));
  2681. }
  2682. /// <summary>
  2683. /// 翻译人员库
  2684. /// Del
  2685. /// </summary>
  2686. /// <param name="id"></param>
  2687. /// <returns></returns>
  2688. [HttpDelete("id")]
  2689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2690. public async Task<IActionResult> TranslatorLibraryDel(int id)
  2691. {
  2692. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  2693. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  2694. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  2695. var upd = await _translatorRep.SoftDeleteByIdAsync<Res_TranslatorLibrary>(id.ToString(), currUserInfo.UserId);
  2696. if (!upd) return Ok(JsonView(false));
  2697. return Ok(JsonView(true));
  2698. }
  2699. #endregion
  2700. }
  2701. }