ResourceController.cs 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189
  1. using Aspose.Words;
  2. using NPOI.HPSF;
  3. using OASystem.API.OAMethodLib;
  4. using OASystem.Domain.Dtos.Resource;
  5. using OASystem.Domain.Entities.Groups;
  6. using OASystem.Domain.ViewModels.Groups;
  7. using OASystem.Infrastructure.Repositories.Groups;
  8. using Org.BouncyCastle.Utilities;
  9. using Quartz.Util;
  10. using System.Collections.Generic;
  11. using System.Diagnostics;
  12. using System.Net.Http.Headers;
  13. using static QRCoder.PayloadGenerator.SwissQrCode;
  14. namespace OASystem.API.Controllers
  15. {
  16. /// <summary>
  17. /// 资料相关
  18. /// </summary>
  19. //[Authorize]
  20. [Route("api/[controller]/[action]")]
  21. public class ResourceController : ControllerBase
  22. {
  23. private readonly IMapper _mapper;
  24. private readonly SqlSugarClient _sqlSugar;
  25. private readonly IConfiguration _config;
  26. private readonly CarDataRepository _carDataRep;
  27. private readonly LocalGuideDataRepository _localGuideDataRep;
  28. private readonly ThreeCodeRepository _ThreeCodeRep;
  29. private readonly HotelDataRepository _hotelDataRep;
  30. private readonly ResItemInfoRepository _resItemInfoRep;
  31. private readonly SetDataRepository _setDataRepository;
  32. private readonly CountryFeeRepository _countryFeeRep;
  33. private readonly SetDataTypeRepository _setDataTypeRep;
  34. private readonly AirTicketAgentRepository _airTicketAgentRep;
  35. private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
  36. private readonly OfficialActivitiesRepository _officialActivitiesRep;
  37. private readonly AskDataRepository _askDataRep;
  38. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  39. private readonly TourClientListRepository _tourClientListRep;
  40. private readonly DelegationInfoRepository _delegationInfoRep;
  41. public ResourceController(IMapper mapper, IConfiguration config, SqlSugarClient sqlSugar, CarDataRepository carDataRep, LocalGuideDataRepository localGuideDataRep,
  42. ThreeCodeRepository threeCodeRep, HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
  43. CountryFeeRepository countryFeeRep, SetDataTypeRepository setDataTypeRep, AirTicketAgentRepository airTicketAgentRep,
  44. InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep, OfficialActivitiesRepository officialActivitiesRep, AskDataRepository askDataRep,
  45. TicketBlackCodeRepository ticketBlackCodeRep, TourClientListRepository tourClientListRep, DelegationInfoRepository delegationInfoRep)
  46. {
  47. _mapper = mapper;
  48. _config = config;
  49. _sqlSugar = sqlSugar;
  50. _carDataRep = carDataRep;
  51. _localGuideDataRep = localGuideDataRep;
  52. _ThreeCodeRep = threeCodeRep;
  53. _hotelDataRep = hotelDataRep;
  54. _resItemInfoRep = resItemInfoRep;
  55. _setDataRepository = setDataRepository;
  56. _countryFeeRep = countryFeeRep;
  57. _setDataTypeRep = setDataTypeRep;
  58. _airTicketAgentRep = airTicketAgentRep;
  59. _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
  60. _officialActivitiesRep = officialActivitiesRep;
  61. _askDataRep = askDataRep;
  62. _ticketBlackCodeRep = ticketBlackCodeRep;
  63. _tourClientListRep = tourClientListRep;
  64. _delegationInfoRep = delegationInfoRep;
  65. }
  66. #region 车公司资料板块
  67. /// <summary>
  68. /// 车公司信息查询
  69. /// </summary>
  70. /// <returns></returns>
  71. [HttpPost]
  72. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  73. public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
  74. {
  75. try
  76. {
  77. Result LocalGuide = await _carDataRep.QueryCarData(dto);
  78. if (LocalGuide.Code == 0)
  79. {
  80. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  81. }
  82. else
  83. {
  84. return Ok(JsonView(false, LocalGuide.Msg));
  85. }
  86. }
  87. catch (Exception)
  88. {
  89. return Ok(JsonView(false, "程序错误!"));
  90. throw;
  91. }
  92. }
  93. /// <summary>
  94. /// 车公司资料下拉框数据
  95. /// </summary>
  96. /// <returns></returns>
  97. [HttpPost]
  98. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  99. public async Task<IActionResult> QueryCarSelect()
  100. {
  101. try
  102. {
  103. var CarData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
  104. if (CarData.Count == 0)
  105. {
  106. return Ok(JsonView(false, "暂无数据!"));
  107. }
  108. CarData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
  109. CarData = CarData.Where((x, i) => CarData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
  110. CarData = CarData.OrderBy(x => x.Id).ToList();
  111. List<CarDataSelectView> data = new List<CarDataSelectView>();
  112. foreach (CarDataSelectView car in CarData)
  113. {
  114. if (!string.IsNullOrWhiteSpace(car.UnitArea))
  115. {
  116. data.Add(car);
  117. }
  118. }
  119. return Ok(JsonView(true, "查询成功", data));
  120. }
  121. catch (Exception)
  122. {
  123. return Ok(JsonView(false, "程序错误!"));
  124. throw;
  125. }
  126. }
  127. /// <summary>
  128. /// 车公司信息添加
  129. /// </summary>
  130. /// <returns></returns>
  131. [HttpPost]
  132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  133. public async Task<IActionResult> AddCarData(AddCarDataDto dto)
  134. {
  135. try
  136. {
  137. if (dto.UnitArea == "")
  138. {
  139. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  140. }
  141. if (dto.UnitName == "")
  142. {
  143. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  144. }
  145. if (dto.Contact == "")
  146. {
  147. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  148. }
  149. if (dto.ContactTel == "")
  150. {
  151. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  152. }
  153. 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();
  154. if (carDada.Count != 0)
  155. {
  156. return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
  157. }
  158. Res_CarData _CarData = _mapper.Map<Res_CarData>(dto);
  159. int id = await _carDataRep.AddAsyncReturnId(_CarData);
  160. if (id == 0)
  161. {
  162. return Ok(JsonView(false, "添加失败!"));
  163. }
  164. return Ok(JsonView(true, "添加成功", new { Id = id }));
  165. }
  166. catch (Exception ex)
  167. {
  168. return Ok(JsonView(false, "程序错误!"));
  169. throw;
  170. }
  171. }
  172. /// <summary>
  173. /// 车公司信息修改
  174. /// </summary>
  175. /// <returns></returns>
  176. [HttpPost]
  177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  178. public async Task<IActionResult> UpCarData(UpCarDataDto dto)
  179. {
  180. try
  181. {
  182. if (dto.UnitArea == "")
  183. {
  184. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  185. }
  186. if (dto.UnitName == "")
  187. {
  188. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  189. }
  190. if (dto.Contact == "")
  191. {
  192. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  193. }
  194. if (dto.ContactTel == "")
  195. {
  196. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  197. }
  198. bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
  199. {
  200. UnitArea = dto.UnitArea,
  201. UnitName = dto.UnitName,
  202. Address = dto.Address,
  203. Contact = dto.Contact,
  204. ContactTel = dto.ContactTel,
  205. ContactEmail = dto.ContactEmail,
  206. ContactFax = dto.ContactFax,
  207. CarDes = dto.CarDes,
  208. CarPicPaths = dto.CarPicPaths,
  209. OtherInfo = dto.OtherInfo,
  210. Score = dto.Score,
  211. QualificationScore = dto.QualificationScore,
  212. CarAgeScore = dto.CarAgeScore,
  213. CleanImgScore = dto.CleanImgScore,
  214. SmellScore = dto.SmellScore,
  215. WaterPaperScore = dto.WaterPaperScore,
  216. HardwareScore = dto.HardwareScore,
  217. TimeScore = dto.TimeScore,
  218. SafetyScore = dto.SafetyScore,
  219. DrivingAgeScore = dto.DrivingAgeScore,
  220. Remark = dto.Remark,
  221. });
  222. if (!res) { return Ok(JsonView(false, "修改失败!")); }
  223. return Ok(JsonView(true, "修改成功"));
  224. }
  225. catch (Exception ex)
  226. {
  227. return Ok(JsonView(false, "程序错误!"));
  228. throw;
  229. }
  230. }
  231. /// <summary>
  232. /// 车公司信息删除
  233. /// </summary>
  234. /// <returns></returns>
  235. [HttpPost]
  236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  237. public async Task<IActionResult> DelCarData(DelCarDataDto dto)
  238. {
  239. try
  240. {
  241. bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
  242. if (!res) { return Ok(JsonView(false, "删除失败!")); }
  243. return Ok(JsonView(true, "删除成功"));
  244. }
  245. catch (Exception ex)
  246. {
  247. return Ok(JsonView(false, "程序错误!"));
  248. throw;
  249. }
  250. }
  251. #endregion
  252. #region 导游地接资料板块
  253. /// <summary>
  254. /// 导游地接资料查询
  255. /// </summary>
  256. /// <param name="dto"></param>
  257. /// <returns></returns>
  258. [HttpPost]
  259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  260. public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
  261. {
  262. try
  263. {
  264. Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
  265. if (LocalGuide.Code == 0)
  266. {
  267. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  268. }
  269. else
  270. {
  271. return Ok(JsonView(false, LocalGuide.Msg));
  272. }
  273. }
  274. catch (Exception ex)
  275. {
  276. return Ok(JsonView(false, "程序错误!"));
  277. throw;
  278. }
  279. }
  280. /// <summary>
  281. /// 导游地接资料下拉框数据
  282. /// </summary>
  283. /// <returns></returns>
  284. [HttpPost]
  285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  286. public async Task<IActionResult> QueryLocalGuideSelect()
  287. {
  288. try
  289. {
  290. var LocalGuide = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
  291. if (LocalGuide.Count == 0)
  292. {
  293. return Ok(JsonView(false, "暂无数据!"));
  294. }
  295. LocalGuide.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
  296. LocalGuide = LocalGuide.Where((x, i) => LocalGuide.FindIndex(z => z.UnitArea == x.UnitArea && z.UnitArea != "") == i).ToList();
  297. LocalGuide = LocalGuide.OrderBy(x => x.Id).ToList();
  298. List<QueryLocalGuideSelectView> data = new List<QueryLocalGuideSelectView>();
  299. foreach (QueryLocalGuideSelectView Local in LocalGuide)
  300. {
  301. if (!string.IsNullOrWhiteSpace(Local.UnitArea))
  302. {
  303. data.Add(Local);
  304. }
  305. }
  306. return Ok(JsonView(true, "查询成功", data));
  307. }
  308. catch (Exception)
  309. {
  310. return Ok(JsonView(false, "程序错误!"));
  311. throw;
  312. }
  313. }
  314. /// <summary>
  315. /// 导游地接信息操作(Status:1.新增,2.修改)
  316. /// </summary>
  317. /// <returns></returns>
  318. [HttpPost]
  319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  320. public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
  321. {
  322. try
  323. {
  324. if (dto.UnitArea == "")
  325. {
  326. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  327. }
  328. if (dto.UnitName == "")
  329. {
  330. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  331. }
  332. if (dto.Contact == "")
  333. {
  334. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  335. }
  336. if (dto.ContactTel == "")
  337. {
  338. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  339. }
  340. Result result = await _localGuideDataRep.LocalGuideOperation(dto);
  341. if (result.Code != 0)
  342. {
  343. return Ok(JsonView(false, result.Msg));
  344. }
  345. return Ok(JsonView(true, result.Msg));
  346. }
  347. catch (Exception ex)
  348. {
  349. return Ok(JsonView(false, "程序错误!"));
  350. throw;
  351. }
  352. }
  353. /// <summary>
  354. /// 导游地接信息操作(删除)
  355. /// </summary>
  356. /// <returns></returns>
  357. [HttpPost]
  358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  359. public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
  360. {
  361. try
  362. {
  363. var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
  364. if (!res)
  365. {
  366. return Ok(JsonView(false, "删除失败"));
  367. }
  368. return Ok(JsonView(true, "删除成功!"));
  369. }
  370. catch (Exception ex)
  371. {
  372. return Ok(JsonView(false, "程序错误!"));
  373. throw;
  374. }
  375. }
  376. #endregion
  377. #region 机场三字码信息
  378. /// <summary>
  379. /// 机场三字码查询
  380. /// </summary>
  381. /// <param name="dto"></param>
  382. /// <returns></returns>
  383. [HttpPost]
  384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  385. public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
  386. {
  387. try
  388. {
  389. Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
  390. if (LocalGuide.Code == 0)
  391. {
  392. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  393. }
  394. else
  395. {
  396. return Ok(JsonView(false, LocalGuide.Msg));
  397. }
  398. }
  399. catch (Exception ex)
  400. {
  401. return Ok(JsonView(false, "程序错误!"));
  402. throw;
  403. }
  404. }
  405. /// <summary>
  406. /// 机场三字码数据城市下拉框数据
  407. /// </summary>
  408. /// <returns></returns>
  409. [HttpPost]
  410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  411. public async Task<IActionResult> QueryThreeCodeSelect()
  412. {
  413. try
  414. {
  415. var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
  416. if (ThreeCode.Count == 0)
  417. {
  418. return Ok(JsonView(false, "暂无数据!"));
  419. }
  420. ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
  421. ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  422. ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
  423. List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
  424. foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
  425. {
  426. if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
  427. {
  428. data.Add(_ThreeCode);
  429. }
  430. }
  431. return Ok(JsonView(true, "查询成功", data));
  432. }
  433. catch (Exception)
  434. {
  435. return Ok(JsonView(false, "程序错误!"));
  436. throw;
  437. }
  438. }
  439. /// <summary>
  440. /// 机场三字码资料操作(Status:1.新增,2.修改)
  441. /// </summary>
  442. /// <param name="dto"></param>
  443. /// <returns></returns>
  444. [HttpPost]
  445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  446. public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
  447. {
  448. try
  449. {
  450. if (dto.Three == "")
  451. {
  452. return Ok(JsonView(false, "请检查三字码是否填写!"));
  453. }
  454. if (dto.Country == "")
  455. {
  456. return Ok(JsonView(false, "请检查国家是否填写!"));
  457. }
  458. if (dto.City == "")
  459. {
  460. return Ok(JsonView(false, "请检查城市是否填写正确!"));
  461. }
  462. if (dto.AirPort == "")
  463. {
  464. return Ok(JsonView(false, "请检查机场是否填写正确!"));
  465. }
  466. Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
  467. if (result.Code != 0)
  468. {
  469. return Ok(JsonView(false, result.Msg));
  470. }
  471. return Ok(JsonView(true, result.Msg));
  472. }
  473. catch (Exception ex)
  474. {
  475. return Ok(JsonView(false, "程序错误!"));
  476. throw;
  477. }
  478. }
  479. /// <summary>
  480. /// 机场三字码资料操作(删除)
  481. /// </summary>
  482. /// <returns></returns>
  483. [HttpPost]
  484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  485. public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
  486. {
  487. try
  488. {
  489. var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
  490. if (!res)
  491. {
  492. return Ok(JsonView(false, "删除失败"));
  493. }
  494. return Ok(JsonView(true, "删除成功!"));
  495. }
  496. catch (Exception ex)
  497. {
  498. return Ok(JsonView(false, "程序错误!"));
  499. throw;
  500. }
  501. }
  502. #endregion
  503. #region 代理出票合作方资料
  504. /// <summary>
  505. /// 代理出票合作方资料
  506. /// </summary>
  507. /// <param name="dto"></param>
  508. /// <returns></returns>
  509. [HttpPost]
  510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  511. public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
  512. {
  513. try
  514. {
  515. List<Res_AirTicketAgent> res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
  516. if (res_AirTicketAgents.Count != 0)
  517. {
  518. res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
  519. if (dto.PageSize == 0 && dto.PageIndex == 0)
  520. {
  521. return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
  522. }
  523. else
  524. {
  525. int count = res_AirTicketAgents.Count;
  526. float totalPage = (float)count / dto.PageSize;//总页数
  527. if (totalPage == 0) totalPage = 1;
  528. else totalPage = (int)Math.Ceiling((double)totalPage);
  529. List<Res_AirTicketAgent> _AirTicketAgent = new List<Res_AirTicketAgent>();
  530. for (int i = 0; i < dto.PageSize; i++)
  531. {
  532. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  533. if (RowIndex < res_AirTicketAgents.Count)
  534. {
  535. _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
  536. }
  537. else
  538. {
  539. break;
  540. }
  541. }
  542. return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
  543. }
  544. }
  545. else
  546. {
  547. return Ok(JsonView(false, "暂无数据!"));
  548. }
  549. }
  550. catch (Exception ex)
  551. {
  552. return Ok(JsonView(false, "程序错误!"));
  553. throw;
  554. }
  555. }
  556. /// <summary>
  557. /// 代理出票合作方资料操作(Status:1.新增,2.修改)
  558. /// </summary>
  559. /// <param name="dto"></param>
  560. /// <returns></returns>
  561. [HttpPost]
  562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  563. public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
  564. {
  565. try
  566. {
  567. if (dto.Account == "")
  568. {
  569. return Ok(JsonView(false, "请检查代理商账户是否填写!"));
  570. }
  571. if (dto.Bank == "")
  572. {
  573. return Ok(JsonView(false, "请检查代理商银行是否填写!"));
  574. }
  575. if (dto.Name == "")
  576. {
  577. return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
  578. }
  579. Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
  580. if (result.Code != 0)
  581. {
  582. return Ok(JsonView(false, result.Msg));
  583. }
  584. return Ok(JsonView(true, result.Msg));
  585. }
  586. catch (Exception ex)
  587. {
  588. return Ok(JsonView(false, "程序错误!"));
  589. throw;
  590. }
  591. }
  592. /// <summary>
  593. /// 代理出票合作方资料操作(删除)
  594. /// </summary>
  595. /// <returns></returns>
  596. [HttpPost]
  597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  598. public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
  599. {
  600. try
  601. {
  602. var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
  603. if (!res)
  604. {
  605. return Ok(JsonView(false, "删除失败"));
  606. }
  607. return Ok(JsonView(true, "删除成功!"));
  608. }
  609. catch (Exception ex)
  610. {
  611. return Ok(JsonView(false, "程序错误!"));
  612. throw;
  613. }
  614. }
  615. #endregion
  616. #region 酒店资料数据
  617. /// <summary>
  618. /// 酒店信息查询
  619. /// </summary>
  620. /// <param name="dto"></param>
  621. /// <returns></returns>
  622. [HttpPost]
  623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  624. public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
  625. {
  626. try
  627. {
  628. Result hotelData = await _hotelDataRep.QueryHotelData(dto);
  629. if (hotelData.Code == 0)
  630. {
  631. return Ok(JsonView(true, "查询成功", hotelData.Data));
  632. }
  633. else
  634. {
  635. return Ok(JsonView(false, hotelData.Msg));
  636. }
  637. }
  638. catch (Exception ex)
  639. {
  640. return Ok(JsonView(false, "程序错误!"));
  641. throw;
  642. }
  643. }
  644. /// <summary>
  645. /// 酒店资料下拉框数据
  646. /// </summary>
  647. /// <returns></returns>
  648. [HttpPost]
  649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  650. public async Task<IActionResult> QueryHotelDataSelect()
  651. {
  652. try
  653. {
  654. var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
  655. if (HotelData.Count == 0)
  656. {
  657. return Ok(JsonView(false, "暂无数据!"));
  658. }
  659. HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
  660. HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  661. HotelData = HotelData.OrderBy(x => x.Id).ToList();
  662. List<QueryHotelDataSelect> data = new List<QueryHotelDataSelect>();
  663. foreach (QueryHotelDataSelect Hotel in HotelData)
  664. {
  665. if (!string.IsNullOrWhiteSpace(Hotel.City))
  666. {
  667. data.Add(Hotel);
  668. }
  669. }
  670. return Ok(JsonView(true, "查询成功", data));
  671. }
  672. catch (Exception)
  673. {
  674. return Ok(JsonView(false, "程序错误!"));
  675. throw;
  676. }
  677. }
  678. /// <summary>
  679. /// 酒店资料操作(Status:1.新增,2.修改)
  680. /// </summary>
  681. /// <param name="dto"></param>
  682. /// <returns></returns>
  683. [HttpPost]
  684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  685. public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
  686. {
  687. try
  688. {
  689. if (dto.City == "")
  690. {
  691. return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
  692. }
  693. if (dto.Name == "")
  694. {
  695. return Ok(JsonView(false, "请检查酒店名称是否填写!"));
  696. }
  697. if (dto.Address == "")
  698. {
  699. return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
  700. }
  701. if (dto.Tel == "")
  702. {
  703. return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
  704. }
  705. Result result = await _hotelDataRep.OperationHotelData(dto);
  706. if (result.Code != 0)
  707. {
  708. return Ok(JsonView(false, result.Msg));
  709. }
  710. return Ok(JsonView(true, result.Msg));
  711. }
  712. catch (Exception ex)
  713. {
  714. return Ok(JsonView(false, ex.Message));
  715. }
  716. }
  717. /// <summary>
  718. /// 酒店资料操作(删除)
  719. /// </summary>
  720. /// <returns></returns>
  721. [HttpPost]
  722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  723. public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
  724. {
  725. try
  726. {
  727. var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
  728. if (!res)
  729. {
  730. return Ok(JsonView(false, "删除失败"));
  731. }
  732. return Ok(JsonView(true, "删除成功!"));
  733. }
  734. catch (Exception ex)
  735. {
  736. return Ok(JsonView(false, "程序错误!"));
  737. throw;
  738. }
  739. }
  740. #endregion
  741. #region 签证费用资料
  742. /// <summary>
  743. /// 签证费用资料查询
  744. /// </summary>
  745. /// <param name="dto"></param>
  746. /// <returns></returns>
  747. [HttpPost]
  748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  749. public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
  750. {
  751. if (dto.PortType == 1)
  752. {
  753. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  754. if (CountryFee.Count == 0)
  755. {
  756. return Ok(JsonView(false, "暂无数据!"));
  757. }
  758. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  759. return Ok(JsonView(true, "查询成功", CountryFee));
  760. }
  761. else if (dto.PortType == 2)
  762. {
  763. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  764. if (CountryFee.Count == 0)
  765. {
  766. return Ok(JsonView(false, "暂无数据!"));
  767. }
  768. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  769. return Ok(JsonView(true, "查询成功", CountryFee));
  770. }
  771. else
  772. {
  773. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  774. }
  775. }
  776. /// <summary>
  777. /// 签证费用资料操作(Status:1.新增,2.修改)
  778. /// </summary>
  779. /// <param name="dto"></param>
  780. /// <returns></returns>
  781. [HttpPost]
  782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  783. public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
  784. {
  785. if (string.IsNullOrWhiteSpace(dto.VisaContinent))
  786. {
  787. return Ok(JsonView(false, "请检查州名是否填写!"));
  788. }
  789. if (string.IsNullOrWhiteSpace(dto.VisaCountry))
  790. {
  791. return Ok(JsonView(false, "请检查国家名是否填写!"));
  792. }
  793. if (string.IsNullOrWhiteSpace(dto.VisaTime))
  794. {
  795. return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
  796. }
  797. if (string.IsNullOrWhiteSpace(dto.UrgentTime))
  798. {
  799. return Ok(JsonView(false, "请检加急时间是否填写正确!"));
  800. }
  801. Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
  802. if (result.Code == 0)
  803. {
  804. return Ok(JsonView(true, result.Msg));
  805. }
  806. return Ok(JsonView(false, result.Msg));
  807. }
  808. /// <summary>
  809. /// 签证费用资料操作(删除)
  810. /// </summary>
  811. /// <returns></returns>
  812. [HttpPost]
  813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  814. public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
  815. {
  816. var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
  817. if (!res)
  818. {
  819. return Ok(JsonView(false, "删除失败"));
  820. }
  821. return Ok(JsonView(true, "删除成功!"));
  822. }
  823. #endregion
  824. #region 物料信息、供应商维护
  825. #region 供应商
  826. /// <summary>
  827. /// 物料供应商查询
  828. /// </summary>
  829. /// <param name="paras">Json序列化</param>
  830. /// <returns></returns>
  831. [HttpPost]
  832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  833. public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
  834. {
  835. if (string.IsNullOrEmpty(_jsonDto.Paras))
  836. {
  837. return Ok(JsonView(false, "参数为空"));
  838. }
  839. Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
  840. if (_ItemVendorDto != null)
  841. {
  842. if (_ItemVendorDto.SearchType == 2) //获取列表
  843. {
  844. Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
  845. return Ok(rstList);
  846. }
  847. else
  848. {
  849. Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
  850. return Ok(rstInfo);
  851. }
  852. }
  853. else
  854. {
  855. return Ok(JsonView(false, "参数反序列化失败"));
  856. }
  857. return Ok(JsonView(false));
  858. }
  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> PostEditItemVendor(Edit_ResItemVendorDto _dto)
  867. {
  868. bool rst = false;
  869. if (_dto.EditType >= 0)
  870. {
  871. if (string.IsNullOrEmpty(_dto.VendorFullName))
  872. {
  873. return Ok(JsonView(false, "全称未填写"));
  874. }
  875. if (string.IsNullOrEmpty(_dto.VendorLinker))
  876. {
  877. return Ok(JsonView(false, "联系人未填写"));
  878. }
  879. if (string.IsNullOrEmpty(_dto.VendorMobile))
  880. {
  881. return Ok(JsonView(false, "联系人手机号未填写"));
  882. }
  883. if (string.IsNullOrEmpty(_dto.BusRange))
  884. {
  885. return Ok(JsonView(false, "经营范围未选择"));
  886. }
  887. if (_dto.EditType == 0)
  888. {
  889. var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
  890. if (checkEmpty != null)
  891. {
  892. return Ok(JsonView(false, "已存在同名供应商"));
  893. }
  894. rst = await _resItemInfoRep.addVendorInfo(_dto);
  895. }
  896. else if (_dto.EditType == 1)
  897. {
  898. if (_dto.VendorId > 0)
  899. {
  900. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  901. rst = await _resItemInfoRep.updVendorInfo(_entity);
  902. }
  903. else
  904. {
  905. return Ok(JsonView(false, "供应商不存在"));
  906. }
  907. }
  908. }
  909. else
  910. {
  911. if (_dto.VendorId < 1 || _dto.SysUserId < 1)
  912. {
  913. return Ok(JsonView(false, "用户Id或供应商Id不存在"));
  914. }
  915. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  916. rst = await _resItemInfoRep.delVendorInfo(_entity);
  917. }
  918. return Ok(JsonView(rst));
  919. }
  920. #endregion
  921. #region 物料信息
  922. /// <summary>
  923. /// 物料信息查询
  924. /// </summary>
  925. /// <param name="paras">Json序列化</param>
  926. /// <returns></returns>
  927. [HttpPost]
  928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  929. public async Task<IActionResult> PostSearchItemInfo(string paras)
  930. {
  931. if (string.IsNullOrEmpty(paras))
  932. {
  933. return Ok(JsonView(false, "参数为空"));
  934. }
  935. Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
  936. if (_ItemInfoDto != null)
  937. {
  938. if (_ItemInfoDto.SearchType == 2) //获取列表
  939. {
  940. Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
  941. return Ok(rstList);
  942. }
  943. else
  944. {
  945. Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
  946. return Ok(rstInfo);
  947. }
  948. }
  949. else
  950. {
  951. return Ok(JsonView(false, "参数反序列化失败"));
  952. }
  953. return Ok(JsonView(false));
  954. }
  955. /// <summary>
  956. /// 创建/编辑/删除物料信息
  957. /// </summary>
  958. ///
  959. /// <returns></returns>
  960. [HttpPost]
  961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  962. public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
  963. {
  964. bool rst = false;
  965. if (_dto.EditType >= 0)
  966. {
  967. if (_dto.VendorId < 1)
  968. {
  969. return Ok(JsonView(false, "未选择供应商"));
  970. }
  971. if (string.IsNullOrEmpty(_dto.ItemName))
  972. {
  973. return Ok(JsonView(false, "物料名称为空"));
  974. }
  975. if (_dto.ItemTypeId < 1)
  976. {
  977. return Ok(JsonView(false, "未选择物料类型"));
  978. }
  979. if (_dto.SysUserId < 1)
  980. {
  981. return Ok(JsonView(false, "当前操作用户Id为空"));
  982. }
  983. if (_dto.CurrRate <= 0)
  984. {
  985. return Ok(JsonView(false, "物料录入价格不能小于等于0"));
  986. }
  987. if (_dto.EditType == 0)
  988. {
  989. //判断物料名称、类型、供应商全部重复
  990. var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
  991. if (checkEmpty != null)
  992. {
  993. return Ok(JsonView(false, "已存在重复物料信息"));
  994. }
  995. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  996. DateTime dtNow = DateTime.Now;
  997. _entity.CreateUserId = _dto.SysUserId;
  998. _entity.IsDel = 0;
  999. _entity.MaxRate = _dto.CurrRate;
  1000. _entity.MaxDt = dtNow;
  1001. _entity.CurrRate = _dto.CurrRate;
  1002. _entity.CurrDt = dtNow;
  1003. _entity.MinRate = _dto.CurrRate;
  1004. _entity.MinDt = dtNow;
  1005. rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
  1006. }
  1007. else if (_dto.EditType == 1)
  1008. {
  1009. if (_dto.ItemId > 0)
  1010. {
  1011. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1012. _entity.Id = _dto.ItemId;
  1013. rst = await _resItemInfoRep.updItemInfo(_entity);
  1014. }
  1015. else
  1016. {
  1017. return Ok(JsonView(false, "供应商不存在"));
  1018. }
  1019. }
  1020. }
  1021. else
  1022. {
  1023. if (_dto.ItemId < 1 || _dto.SysUserId < 1)
  1024. {
  1025. return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
  1026. }
  1027. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1028. rst = await _resItemInfoRep.delItemInfo(_entity);
  1029. }
  1030. return Ok(JsonView(rst));
  1031. }
  1032. #endregion
  1033. #region 物料类型获取
  1034. #endregion
  1035. #endregion
  1036. #region 备忘录
  1037. /// <summary>
  1038. /// 备忘录查询
  1039. /// </summary>
  1040. /// <param name="paras">Json序列化</param>
  1041. /// <returns></returns>
  1042. [HttpPost]
  1043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1044. public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
  1045. {
  1046. if (string.IsNullOrEmpty(_jsonDto.Paras))
  1047. {
  1048. return Ok(JsonView(false, "参数为空"));
  1049. }
  1050. Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
  1051. if (_memoDto != null)
  1052. {
  1053. if (_memoDto.SearchType == 2)
  1054. {
  1055. //获取列表
  1056. string sqlWhere = string.Format(" Where IsDel=0 ");
  1057. #region SqlWhere
  1058. if (!string.IsNullOrEmpty(_memoDto.Abstracts))
  1059. {
  1060. sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
  1061. }
  1062. if (!string.IsNullOrEmpty(_memoDto.Title))
  1063. {
  1064. sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
  1065. }
  1066. if (_memoDto.ReadLevel > 0)
  1067. {
  1068. sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
  1069. }
  1070. #endregion
  1071. int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
  1072. int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
  1073. string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
  1074. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1075. m.LastedEditDt,m.LastedEditorId
  1076. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1077. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
  1078. ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
  1079. Res_MemoListView rst = new Res_MemoListView();
  1080. rst.CurrPageIndex = currPIndex;
  1081. rst.CurrPageSize = currPSize;
  1082. List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
  1083. Dictionary<int, string> userDic = new Dictionary<int, string>();
  1084. foreach (var item in dataSource)
  1085. {
  1086. if (userDic.ContainsKey(item.LastedEditorId))
  1087. {
  1088. item.LastedEditor = userDic[item.LastedEditorId];
  1089. }
  1090. else
  1091. {
  1092. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
  1093. userDic[item.LastedEditorId] = _sysUser.CnName;
  1094. item.LastedEditor = _sysUser.CnName;
  1095. }
  1096. }
  1097. rst.DataList = new List<Res_MemoView>(dataSource);
  1098. if (rst.DataList.Count > 0)
  1099. {
  1100. string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
  1101. int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
  1102. rst.DataCount = dataCount;
  1103. }
  1104. return Ok(JsonView(rst));
  1105. }
  1106. else
  1107. {
  1108. //获取对象
  1109. string sqlSingle = string.Format(@" Select
  1110. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1111. m.LastedEditDt,m.LastedEditor,m.MDFilePath
  1112. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1113. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
  1114. Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
  1115. if (_result != null)
  1116. {
  1117. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
  1118. _result.LastedEditor = _sysUser.CnName;
  1119. _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
  1120. return Ok(JsonView(_result));
  1121. }
  1122. }
  1123. }
  1124. else
  1125. {
  1126. return Ok(JsonView(false, "参数反序列化失败"));
  1127. }
  1128. return Ok(JsonView(false));
  1129. }
  1130. /// <summary>
  1131. /// 创建/编辑/删除备忘录信息
  1132. /// </summary>
  1133. /// <param name="_dto"></param>
  1134. /// <returns></returns>
  1135. [HttpPost]
  1136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1137. public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
  1138. {
  1139. bool rst = false;
  1140. if (_dto.SysUserId < 1)
  1141. {
  1142. return Ok(JsonView(false, "操作人失效"));
  1143. }
  1144. Sys_Users _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
  1145. if (_sysUser == null)
  1146. {
  1147. return Ok(JsonView(false, "操作人失效02"));
  1148. }
  1149. if (_dto.EditType >= 0)
  1150. {
  1151. if (_dto.ReadLevel < 1)
  1152. {
  1153. return Ok(JsonView(false, "未知的阅读等级"));
  1154. }
  1155. if (string.IsNullOrEmpty(_dto.Title.Trim()))
  1156. {
  1157. return Ok(JsonView(false, "标题不能为空"));
  1158. }
  1159. if (string.IsNullOrEmpty(_dto.Content.Trim()))
  1160. {
  1161. return Ok(JsonView(false, "正文内容不能为空"));
  1162. }
  1163. //新增备忘录
  1164. DateTime dtNow = DateTime.Now;
  1165. string dir = AppSettingsHelper.Get("MemoCurrPath");
  1166. string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
  1167. string content = JsonConvert.SerializeObject(_dto.Content);
  1168. if (_dto.EditType == 0)//新增
  1169. {
  1170. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1171. if (savePath.Length > 0)
  1172. {
  1173. Res_MemoInfo _insert = new Res_MemoInfo();
  1174. _insert.Abstracts = _dto.Abstracts;
  1175. _insert.Title = _dto.Title;
  1176. _insert.DepartmentId = _sysUser.DepId;
  1177. _insert.CreateUserId = _sysUser.Id;
  1178. _insert.LastedEditDt = dtNow;
  1179. _insert.LastedEditor = _sysUser.Id;
  1180. _insert.MDFilePath = savePath;
  1181. _insert.ReadLevel = _dto.ReadLevel;
  1182. _insert.Title = _dto.Title;
  1183. int result = await _resItemInfoRep.AddAsync(_insert);
  1184. return Ok(JsonView(result > 0));
  1185. }
  1186. else
  1187. {
  1188. return Ok(JsonView(false, "路径保存失败"));
  1189. }
  1190. }
  1191. else//修改
  1192. {
  1193. if (_dto.MemoId < 1)
  1194. {
  1195. return Ok(JsonView(false, "MemoId不存在"));
  1196. }
  1197. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1198. if (_source == null)
  1199. {
  1200. return Ok(JsonView(false, "MemoInfo不存在"));
  1201. }
  1202. //修改
  1203. string sourcePath = _source.MDFilePath;
  1204. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1205. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1206. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1207. if (savePath.Length > 0)
  1208. {
  1209. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1210. .SetColumns(it => it.LastedEditDt == DateTime.Now)
  1211. .SetColumns(it => it.LastedEditor == _sysUser.Id)
  1212. .SetColumns(it => it.Abstracts == _dto.Abstracts)
  1213. .SetColumns(it => it.MDFilePath == savePath)
  1214. .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
  1215. .SetColumns(it => it.Title == _dto.Title)
  1216. .Where(s => s.Id == _source.Id)
  1217. .ExecuteCommandAsync();
  1218. return Ok(JsonView(result > 0));
  1219. }
  1220. }
  1221. }
  1222. else
  1223. {
  1224. //删除
  1225. if (_dto.MemoId < 1)
  1226. {
  1227. return Ok(JsonView(false, "MemoId不存在"));
  1228. }
  1229. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1230. if (_source == null)
  1231. {
  1232. return Ok(JsonView(false, "MemoInfo不存在"));
  1233. }
  1234. //修改
  1235. string sourcePath = _source.MDFilePath;
  1236. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1237. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1238. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1239. .SetColumns(it => it.IsDel == 1)
  1240. .SetColumns(it => it.DeleteUserId == _sysUser.Id)
  1241. .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  1242. .Where(s => s.Id == _source.Id)
  1243. .ExecuteCommandAsync();
  1244. return Ok(JsonView(result > 0));
  1245. }
  1246. return Ok(JsonView(rst));
  1247. }
  1248. #endregion
  1249. #region 商邀资料
  1250. /// <summary>
  1251. /// 商邀资料 基础数据源
  1252. /// </summary>
  1253. /// <param name="dto"></param>
  1254. /// <returns></returns>
  1255. [HttpPost]
  1256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1257. public async Task<IActionResult> QueryIOAInitData(QueryIOAInitDataDto dto)
  1258. {
  1259. try
  1260. {
  1261. #region 参数验证
  1262. if (dto.PortType < 1) return Ok(JsonView(false, "请传入有效的PortType参数!"));
  1263. #endregion
  1264. List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.JietuanTime).ToList();
  1265. List<Res_InvitationOfficialActivityData> _ioaDatas = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().Where(it => it.IsDel == 0).ToList();
  1266. List<Sys_Users> _Users = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0).ToList();
  1267. var _countryData = _ioaDatas.Select(it => it.Country).Distinct().ToList(); _countryData.Remove("");
  1268. var _inviterData = _ioaDatas.Select(it => it.UnitName).Distinct().ToList(); _inviterData.Remove("");
  1269. var _contactData = _ioaDatas.Select(it => it.Contact).Distinct().ToList(); _contactData.Remove("");
  1270. var _domainData = _ioaDatas.Select(it => it.Field).Distinct().ToList(); _domainData.Remove("");
  1271. var _groupNameData = _DelegationInfos.Select(it => new { it.Id, it.TeamName }).ToList();
  1272. var _userNameData = _Users.Select(it => new { it.Id, it.CnName }).ToList();
  1273. var _data = new {
  1274. CountryData = _countryData,
  1275. InviterData = _inviterData,
  1276. DomainData = _domainData,
  1277. ContactData = _contactData,
  1278. GroupNameData = _groupNameData,
  1279. UserNameData = _userNameData,
  1280. };
  1281. return Ok(JsonView(true, $"查询成功!", _data));
  1282. }
  1283. catch (Exception ex)
  1284. {
  1285. return Ok(JsonView(false, ex.Message));
  1286. }
  1287. }
  1288. /// <summary>
  1289. /// 商邀资料查询
  1290. /// </summary>
  1291. /// <param name="dto"></param>
  1292. /// <returns></returns>
  1293. [HttpPost]
  1294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1295. public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
  1296. {
  1297. try
  1298. {
  1299. #region 参数验证
  1300. if (dto.PageIndex < 1) return Ok(JsonView(false, "请传入有效的PageIndex参数!"));
  1301. if (dto.PageSize < 1) return Ok(JsonView(false, "请传入有效的PageSize参数!"));
  1302. #endregion
  1303. string sqlWhere = string.Empty;
  1304. if (!string.IsNullOrWhiteSpace(dto.Country)) { sqlWhere += string.Format(@" And i.Country like '%{0}%'", dto.Country); }
  1305. if (!string.IsNullOrWhiteSpace(dto.UnitName)) { sqlWhere += string.Format(@" And i.UnitName like '%{0}%'", dto.UnitName); }
  1306. if (!string.IsNullOrWhiteSpace(dto.Contact)) { sqlWhere += string.Format(@" And i.Contact like '%{0}%'", dto.Contact); }
  1307. if (!string.IsNullOrWhiteSpace(dto.Delegation)) { sqlWhere += string.Format(@" And i.Delegation like '%{0}%'", dto.Delegation); }
  1308. if (!string.IsNullOrWhiteSpace(dto.Field)) { sqlWhere += string.Format(@" And i.Field like '%{0}%'", dto.Field); }
  1309. if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { sqlWhere += string.Format(@" And i.CreateUserId={0}", dto.CreateUserId); }
  1310. if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
  1311. {
  1312. sqlWhere += string.Format(@" And i.CreateTime between '{0}' and '{1}'", dto.StartCreateTime, dto.EndCreateTime);
  1313. }
  1314. sqlWhere += string.Format(@"And i.Isdel={0}", 0);
  1315. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  1316. {
  1317. Regex r = new Regex("And");
  1318. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  1319. }
  1320. string sql = string.Format(@"Select ROW_NUMBER() Over(Order By i.CreateTime Desc) As Row_Number,
  1321. i.*,u.CnName As CreateUserName
  1322. From Res_InvitationOfficialActivityData i
  1323. Left Join Sys_Users u On i.CreateUserId = u.Id {0}", sqlWhere);
  1324. int totalCount = 0;
  1325. List<InvitationOfficialActivityDataView> _ivitiesViews = _sqlSugar.SqlQueryable<InvitationOfficialActivityDataView>(sql).ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  1326. List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().ToList();
  1327. foreach (var item in _ivitiesViews)
  1328. {
  1329. string delegationNameList = "";
  1330. if (!string.IsNullOrEmpty(item.Delegation))
  1331. {
  1332. string[] DelegationName = item.Delegation.Split(',');
  1333. for (int i = 0; i < DelegationName.Length; i++)
  1334. {
  1335. string grpId = DelegationName[i];
  1336. if (!string.IsNullOrEmpty(grpId))
  1337. {
  1338. if (grpId.IsNumeric())
  1339. {
  1340. delegationNameList += _DelegationInfos.Find(it => it.Id == int.Parse(grpId))?.TeamName ?? "Unknown" + ",";
  1341. }
  1342. }
  1343. }
  1344. if (!string.IsNullOrWhiteSpace(delegationNameList))
  1345. {
  1346. item.DelegationStr = delegationNameList.Substring(0, delegationNameList.Length - 1);
  1347. }
  1348. }
  1349. }
  1350. return Ok(JsonView(true, $"查询成功!", _ivitiesViews, totalCount));
  1351. }
  1352. catch (Exception ex)
  1353. {
  1354. return Ok(JsonView(false, ex.Message));
  1355. }
  1356. }
  1357. /// <summary>
  1358. /// 根据商邀资料Id查询信息
  1359. /// </summary>
  1360. /// <param name="dto"></param>
  1361. /// <returns></returns>
  1362. [HttpPost]
  1363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1364. public async Task<IActionResult> QueryInvitationOfficialActivityById(QueryInvitationOfficialActivityByIdDto dto)
  1365. {
  1366. try
  1367. {
  1368. Result groupData = await _InvitationOfficialActivityDataRep.QueryInvitationOfficialActivityById(dto);
  1369. if (groupData.Code != 0)
  1370. {
  1371. return Ok(JsonView(false, groupData.Msg));
  1372. }
  1373. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1374. }
  1375. catch (Exception ex)
  1376. {
  1377. return Ok(JsonView(false, "程序错误!"));
  1378. throw;
  1379. }
  1380. }
  1381. /// <summary>
  1382. /// 商邀资料操作(Status:1.新增,2.修改)
  1383. /// </summary>
  1384. /// <param name="dto"></param>
  1385. /// <returns></returns>
  1386. [HttpPost]
  1387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1388. public async Task<IActionResult> OpInvitationOfficialActivity(OpInvitationOfficialActivityDto dto)
  1389. {
  1390. try
  1391. {
  1392. Result groupData = await _InvitationOfficialActivityDataRep.OpInvitationOfficialActivity(dto);
  1393. if (groupData.Code != 0)
  1394. {
  1395. return Ok(JsonView(false, groupData.Msg));
  1396. }
  1397. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1398. }
  1399. catch (Exception ex)
  1400. {
  1401. return Ok(JsonView(false, "程序错误!"));
  1402. throw;
  1403. }
  1404. }
  1405. /// <summary>
  1406. /// 删除商邀资料信息
  1407. /// </summary>
  1408. /// <param name="dto"></param>
  1409. /// <returns></returns>
  1410. [HttpPost]
  1411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1412. public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
  1413. {
  1414. try
  1415. {
  1416. var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
  1417. if (!res)
  1418. {
  1419. return Ok(JsonView(false, "删除失败"));
  1420. }
  1421. return Ok(JsonView(true, "删除成功!"));
  1422. }
  1423. catch (Exception ex)
  1424. {
  1425. return Ok(JsonView(false, "程序错误!"));
  1426. throw;
  1427. }
  1428. }
  1429. #endregion
  1430. #region 公务出访
  1431. /// <summary>
  1432. /// 获取团组所有信息,绑定下拉框
  1433. /// </summary>
  1434. /// <param name="dto"></param>
  1435. /// <returns></returns>
  1436. [HttpPost]
  1437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1438. public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
  1439. {
  1440. //string groupSql = string.Format("Select * From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By CreateTime Desc");
  1441. //List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.SqlQueryable< Grp_DelegationInfo >(groupSql).ToList();
  1442. var _groupData = await _delegationInfoRep.PostShareGroupInfos(1);
  1443. dynamic groupInfos = null;
  1444. if (_groupData.Code == 0) groupInfos = _groupData.Data;
  1445. List<Sys_SetData> data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 38).ToList();
  1446. List<Grp_DeleFile> _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
  1447. return Ok(JsonView(true, "查询成功!", new { Delegation = groupInfos, SetData = data, DeleFile = _DeleFile }));
  1448. }
  1449. [HttpPost]
  1450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1451. public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
  1452. {
  1453. try
  1454. {
  1455. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto);
  1456. if (groupData.Code != 0)
  1457. {
  1458. return Ok(JsonView(false, groupData.Msg));
  1459. }
  1460. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1461. }
  1462. catch (Exception ex)
  1463. {
  1464. return Ok(JsonView(false, "程序错误!"));
  1465. throw;
  1466. }
  1467. }
  1468. /// <summary>
  1469. /// 根据公务出访数据Id查询数据
  1470. /// </summary>
  1471. /// <param name="dto"></param>
  1472. /// <returns></returns>
  1473. [HttpPost]
  1474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1475. public async Task<IActionResult> QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
  1476. {
  1477. try
  1478. {
  1479. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
  1480. if (groupData.Code != 0)
  1481. {
  1482. return Ok(JsonView(false, groupData.Msg));
  1483. }
  1484. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1485. }
  1486. catch (Exception ex)
  1487. {
  1488. return Ok(JsonView(false, "程序错误!"));
  1489. throw;
  1490. }
  1491. }
  1492. /// <summary>
  1493. /// 公务出访操作(Status:1.新增,2.修改)
  1494. /// </summary>
  1495. /// <param name="dto"></param>
  1496. /// <returns></returns>
  1497. [HttpPost]
  1498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1499. public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
  1500. {
  1501. try
  1502. {
  1503. Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
  1504. if (groupData.Code != 0)
  1505. {
  1506. return Ok(JsonView(false, groupData.Msg));
  1507. }
  1508. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1509. }
  1510. catch (Exception ex)
  1511. {
  1512. return Ok(JsonView(false, "程序错误!"));
  1513. throw;
  1514. }
  1515. }
  1516. /// <summary>
  1517. /// 上传文件
  1518. /// </summary>
  1519. /// <param name="file"></param>
  1520. /// <returns></returns>
  1521. [HttpPost]
  1522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1523. public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
  1524. {
  1525. try
  1526. {
  1527. int Type = int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
  1528. int DiId = int.Parse(Request.Headers["DiId"]);
  1529. int CreateUserId = int.Parse(Request.Headers["CreateUserId"]);
  1530. if (file != null)
  1531. {
  1532. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1533. //文件名称
  1534. string projectFileName = file.FileName;
  1535. //上传的文件的路径
  1536. string filePath = "";
  1537. if (!Directory.Exists(fileDir))
  1538. {
  1539. Directory.CreateDirectory(fileDir);
  1540. }
  1541. //上传的文件的路径
  1542. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1543. using (FileStream fs = System.IO.File.Create(filePath))
  1544. {
  1545. file.CopyTo(fs);
  1546. fs.Flush();
  1547. }
  1548. Grp_DeleFile d = new Grp_DeleFile();
  1549. d.Diid = DiId;
  1550. d.Category = 970;
  1551. if (Type == 1) d.Kind = 1;
  1552. else if (Type == 2) d.Kind = 2;
  1553. else if (Type == 3) d.Kind = 3;
  1554. d.FileName = projectFileName;
  1555. d.FilePath = "";
  1556. d.CreateUserId = CreateUserId;
  1557. int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
  1558. return Ok(JsonView(true, "上传成功!", projectFileName));
  1559. }
  1560. else
  1561. {
  1562. return Ok(JsonView(false, "上传失败!"));
  1563. }
  1564. }
  1565. catch (Exception ex)
  1566. {
  1567. return Ok(JsonView(false, "程序错误!"));
  1568. throw;
  1569. }
  1570. }
  1571. /// <summary>
  1572. /// 删除文件
  1573. /// </summary>
  1574. /// <param name="dto"></param>
  1575. /// <returns></returns>
  1576. [HttpPost]
  1577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1578. public async Task<IActionResult> DelloadOfficialActivities(DelBaseDto dto)
  1579. {
  1580. try
  1581. {
  1582. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1583. Grp_DeleFile _DeleFile = await _sqlSugar.Queryable<Grp_DeleFile>().FirstAsync(a => a.Id == dto.Id);
  1584. if (_DeleFile != null)
  1585. {
  1586. string fileName = _DeleFile.FileName;
  1587. string filePath = fileDir + "/团组增减款项相关文件/" + fileName;
  1588. // 删除该文件
  1589. System.IO.File.Delete(filePath);
  1590. 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();
  1591. return Ok(JsonView(true, "取消文件成功!"));
  1592. }
  1593. else
  1594. {
  1595. return Ok(JsonView(false, "取消文件失败!"));
  1596. }
  1597. }
  1598. catch (Exception ex)
  1599. {
  1600. return Ok(JsonView(false, "程序错误!"));
  1601. throw;
  1602. }
  1603. }
  1604. /// <summary>
  1605. /// 删除公务出访信息
  1606. /// </summary>
  1607. /// <param name="dto"></param>
  1608. /// <returns></returns>
  1609. [HttpPost]
  1610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1611. public async Task<IActionResult> DelOfficialActivities(DelBaseDto dto)
  1612. {
  1613. try
  1614. {
  1615. var res = await _officialActivitiesRep.SoftDeleteByIdAsync<Res_OfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  1616. if (!res)
  1617. {
  1618. return Ok(JsonView(false, "删除失败"));
  1619. }
  1620. return Ok(JsonView(true, "删除成功!"));
  1621. }
  1622. catch (Exception ex)
  1623. {
  1624. return Ok(JsonView(false, "程序错误!"));
  1625. throw;
  1626. }
  1627. }
  1628. /// <summary>
  1629. /// 公务出访 (省外办,市外办) File Downlaod
  1630. /// </summary>
  1631. /// <param name="dto"></param>
  1632. /// <returns></returns>
  1633. [HttpPost]
  1634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1635. public async Task<IActionResult> OfficialActivitiesFileDownload(OfficialActivitiesFileDownload dto)
  1636. {
  1637. #region 参数验证
  1638. if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示"));
  1639. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数."));
  1640. #endregion
  1641. //团组基础信息
  1642. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  1643. if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在"));
  1644. groupInfo.VisitCountry = groupInfo.VisitCountry.Replace("|", "、");
  1645. //团组公务信息
  1646. var obDatas = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderBy(it => it.Date).ToList();
  1647. if (obDatas.Count < 1) return Ok(JsonView(false, "请先录入公务信息!"));
  1648. //请示数据库范例数据
  1649. //团组客户名单
  1650. var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
  1651. List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
  1652. if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
  1653. if (dto.FileType == 1)
  1654. {
  1655. //载入模板
  1656. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
  1657. var doc = new Document(tempPath);
  1658. DocumentBuilder builder = new DocumentBuilder(doc);
  1659. //键值对存放数据
  1660. Dictionary<string, string> dic = new Dictionary<string, string>();
  1661. //××(组团单位):接团客户信息团组
  1662. dic.Add("GroupClient", groupInfo.ClientUnit);
  1663. //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
  1664. string guestName = "";
  1665. string guestJob = "";
  1666. string guestInfoStr = "";
  1667. var guestFirstInfo = guestInfos.FirstOrDefault();
  1668. if (guestFirstInfo != null)
  1669. {
  1670. guestName = guestFirstInfo.LastName + guestFirstInfo.FirstName;
  1671. guestJob = guestFirstInfo.Job;
  1672. guestInfoStr = $@"{guestJob}、{guestName}";
  1673. }
  1674. string askTitle = $@"关于{guestInfoStr}等{guestInfos.Count}人赴{groupInfo.VisitCountry}进行{groupInfo.VisitPurpose}的请示";
  1675. dic.Add("AskTitle", askTitle);
  1676. //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
  1677. string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
  1678. string obInfoStr = "";
  1679. string obBackgroundStr = "×××";//出访背景
  1680. foreach (var ob in obDatas)
  1681. {
  1682. obInfoStr += @$"{ob.Client}{ob.Job}{ob.Contact}、";
  1683. obBackgroundStr += $"{ob.Client}\r\n \t {ob.Setting}\r\n";
  1684. }
  1685. if (obInfoStr.Length > 0)
  1686. {
  1687. obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
  1688. }
  1689. string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{guestInfos.Count}人于{visitDateStr}赴{groupInfo.VisitCountry}进行{groupInfo.VisitPurpose}。现请示如下。";
  1690. dic.Add("AskSubTitle", askSubTitle);
  1691. //出访背景
  1692. obBackgroundStr = "×××";//出访背景
  1693. dic.Add("OBSetting", obBackgroundStr);
  1694. //出访目的
  1695. dic.Add("VisitPurpose", groupInfo.VisitPurpose);
  1696. //出访任务
  1697. //(一)××(国家或地区)
  1698. //1.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  1699. //2.拜访×××(机构名称)×××(姓名、职务)洽谈(或调研、推动等)×××(项目或机构名称等)。(例:拜会×××经济与发展司司长×××,商讨“×××活动”相关筹备工作。)
  1700. string taskStr = "××××"; ;
  1701. //List<string> countrys = groupInfo.VisitCountry.Split("、").ToList();
  1702. //int countryIndex = 1;
  1703. //foreach (var item in countrys)
  1704. //{
  1705. // string taskTitle = $"({GetToUpperNumber(countryIndex)}){item}\r\n";
  1706. // string taskContent = "";
  1707. // var countryObDatas = obDatas.Where(it => it.Client.Contains(item)).ToList();
  1708. // int obIndex = 1;
  1709. // foreach (var obInfo in countryObDatas)
  1710. // {
  1711. // taskContent += $"{obIndex}. 拜访{obInfo.Client}({obInfo.Contact}、{obInfo.Job})洽谈“{groupInfo.VisitPurpose}”相关工作。\r\n";
  1712. // }
  1713. // taskStr += $"{taskTitle}{taskContent}";
  1714. // countryIndex++;
  1715. //}
  1716. //出访任务
  1717. dic.Add("TaskContent", taskStr);
  1718. //出访时间
  1719. //代表团拟于××年×月×日—×月×日出访,在外停留×天。其中,××国家(或地区)×天,××国家(或地区)×天。
  1720. string visitCountryStr = $"[OP行程单读取]";
  1721. visitCountryStr = GeneralMethod.GetCountryStandingTime(groupInfo.Id); //计算国家出访天数
  1722. string visitTimeQuantumStr = $"代表团拟于{groupInfo.VisitStartDate.Year}年{groupInfo.VisitStartDate.Month}月{groupInfo.VisitStartDate.Day}日—{groupInfo.VisitEndDate.Month}月{groupInfo.VisitEndDate.Day}日出访,在外停留{groupInfo.VisitDays}天。其中,{visitCountryStr}。";
  1723. //出访时间
  1724. dic.Add("TimeQuantum", visitTimeQuantumStr);
  1725. //出访路线
  1726. //成都—××(出境城市名称)—××(转机不出机场)—××(公务所在城市)……—××(入境城市名称)—成都。(例:成都—法兰克福<转机不出机场>—巴黎—巴塞罗那—阿姆斯特丹<转机不出机场>-成都)
  1727. string lineStr = GeneralMethod.GetGroupCityLine(groupInfo.Id, "—");
  1728. dic.Add("Line", lineStr);
  1729. //scheduling //行程安排
  1730. string schedulingStr = $"[OP行程单暂未生成]";
  1731. var tripInfo = _sqlSugar.Queryable<Grp_TravelList>().Where(it => it.IsDel == 0 && it.Diid == groupInfo.Id).OrderBy(it => it.Days).ToList();
  1732. if (tripInfo.Count > 0 )
  1733. {
  1734. schedulingStr = "";
  1735. foreach (var item in tripInfo)
  1736. {
  1737. schedulingStr += $"{item.Date}({item.WeekDay})\r\n{item.Trip}\r\n";
  1738. }
  1739. }
  1740. dic.Add("Scheduling", schedulingStr);
  1741. #region 填充word模板书签内容
  1742. foreach (var key in dic.Keys)
  1743. {
  1744. builder.MoveToBookmark(key);
  1745. builder.Write(dic[key]);
  1746. }
  1747. #endregion
  1748. //获取word里所有表格
  1749. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  1750. //获取所填表格的序数
  1751. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  1752. var rowStart = tableOne.Rows[0]; //获取第1行
  1753. //循环赋值
  1754. for (int i = 0; i < guestInfos.Count; i++)
  1755. {
  1756. var guestInfo = guestInfos[i];
  1757. builder.MoveToCell(0, i + 1, 0, 0);
  1758. builder.Write(guestInfo.LastName + guestInfo.FirstName);
  1759. builder.MoveToCell(0, i + 1, 1, 0);
  1760. int sex = guestInfo.Sex;
  1761. string sexStr = string.Empty;
  1762. if (sex == 0) sexStr = "男";
  1763. else if (sex == 1) sexStr = "女";
  1764. else sexStr = "未设置";
  1765. builder.Write(sexStr);
  1766. builder.MoveToCell(0, i + 1, 2, 0);
  1767. builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
  1768. builder.MoveToCell(0, i + 1, 3, 0);
  1769. string birthDay = "";
  1770. string birthDayStr = string.Empty;
  1771. if (!string.IsNullOrEmpty(birthDay))
  1772. {
  1773. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  1774. }
  1775. builder.Write(birthDayStr);
  1776. }
  1777. //删除多余行
  1778. while (tableOne.Rows.Count > guestInfos.Count + 1)
  1779. {
  1780. tableOne.Rows.RemoveAt(guestInfos.Count + 1);
  1781. }
  1782. var fileDir = AppSettingsHelper.Get("WordBasePath");
  1783. string fileName = $"{groupInfo.TeamName}省外办出访请示.docx";
  1784. string filePath = fileDir + $@"OfficialActivities/{fileName}";
  1785. doc.Save(filePath);
  1786. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/OfficialActivities/{fileName}";
  1787. return Ok(JsonView(true, "操作成功!", Url));
  1788. }
  1789. else if (dto.FileType == 2)
  1790. {
  1791. }
  1792. return Ok(JsonView(true, "操作失败!"));
  1793. }
  1794. private string GetToUpperNumber(int num)
  1795. {
  1796. string numStr = "";
  1797. if (num == 1) numStr = "一";
  1798. else if (num == 2) numStr = "二";
  1799. else if (num == 3) numStr = "三";
  1800. else if (num == 4) numStr = "四";
  1801. else if (num == 5) numStr = "五";
  1802. else if (num == 6) numStr = "六";
  1803. else if (num == 7) numStr = "七";
  1804. else if (num == 8) numStr = "八";
  1805. else if (num == 9) numStr = "九";
  1806. else if (num == 10) numStr = "十";
  1807. return numStr;
  1808. }
  1809. #endregion
  1810. #region 请示数据库
  1811. /// <summary>
  1812. /// 查询请示数据库初始化
  1813. /// </summary>
  1814. /// <param name="dto"></param>
  1815. /// <returns></returns>
  1816. [HttpPost]
  1817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1818. public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
  1819. {
  1820. try
  1821. {
  1822. Result groupData = await _askDataRep.QueryAskData(dto);
  1823. if (groupData.Code != 0)
  1824. {
  1825. return Ok(JsonView(false, groupData.Msg));
  1826. }
  1827. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1828. }
  1829. catch (Exception ex)
  1830. {
  1831. return Ok(JsonView(false, "程序错误!"));
  1832. throw;
  1833. }
  1834. }
  1835. /// <summary>
  1836. /// 根据Id查询请示数据库单挑数据
  1837. /// </summary>
  1838. /// <param name="dto"></param>
  1839. /// <returns></returns>
  1840. [HttpPost]
  1841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1842. public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
  1843. {
  1844. try
  1845. {
  1846. Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
  1847. if (_AskData==null)
  1848. {
  1849. return Ok(JsonView(true, "暂无数据!", _AskData));
  1850. }
  1851. return Ok(JsonView(true, "查询成功!", _AskData));
  1852. }
  1853. catch (Exception ex)
  1854. {
  1855. return Ok(JsonView(false, "程序错误!"));
  1856. throw;
  1857. }
  1858. }
  1859. /// <summary>
  1860. /// 请示数据库操作(Status:1.新增,2.修改)
  1861. /// </summary>
  1862. /// <param name="dto"></param>
  1863. /// <returns></returns>
  1864. [HttpPost]
  1865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1866. public async Task<IActionResult> OpAskData(OpAskDataDto dto)
  1867. {
  1868. try
  1869. {
  1870. Result groupData = await _askDataRep.OpAskData(dto);
  1871. if (groupData.Code != 0)
  1872. {
  1873. return Ok(JsonView(false, groupData.Msg));
  1874. }
  1875. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1876. }
  1877. catch (Exception ex)
  1878. {
  1879. return Ok(JsonView(false, "程序错误!"));
  1880. throw;
  1881. }
  1882. }
  1883. /// <summary>
  1884. /// 删除请示资料信息
  1885. /// </summary>
  1886. /// <param name="dto"></param>
  1887. /// <returns></returns>
  1888. [HttpPost]
  1889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1890. public async Task<IActionResult> DelAskData(DelBaseDto dto)
  1891. {
  1892. try
  1893. {
  1894. var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
  1895. if (!res)
  1896. {
  1897. return Ok(JsonView(false, "删除失败"));
  1898. }
  1899. return Ok(JsonView(true, "删除成功!"));
  1900. }
  1901. catch (Exception ex)
  1902. {
  1903. return Ok(JsonView(false, "程序错误!"));
  1904. throw;
  1905. }
  1906. }
  1907. #endregion
  1908. #region 机票黑屏代码
  1909. /// <summary>
  1910. /// 根据团组Id查询黑屏代码列表
  1911. /// </summary>
  1912. /// <param name="dto"></param>
  1913. /// <returns></returns>
  1914. [HttpPost]
  1915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1916. public async Task<IActionResult> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
  1917. {
  1918. try
  1919. {
  1920. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(dto);
  1921. if (groupData.Code != 0)
  1922. {
  1923. return Ok(JsonView(false, groupData.Msg));
  1924. }
  1925. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1926. }
  1927. catch (Exception ex)
  1928. {
  1929. return Ok(JsonView(false, "程序错误!"));
  1930. throw;
  1931. }
  1932. }
  1933. /// <summary>
  1934. /// 根据黑屏代码数据Id查询信息
  1935. /// </summary>
  1936. /// <param name="dto"></param>
  1937. /// <returns></returns>
  1938. [HttpPost]
  1939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1940. public async Task<IActionResult> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
  1941. {
  1942. try
  1943. {
  1944. Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(dto);
  1945. if (groupData.Code != 0)
  1946. {
  1947. return Ok(JsonView(false, groupData.Msg));
  1948. }
  1949. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1950. }
  1951. catch (Exception ex)
  1952. {
  1953. return Ok(JsonView(false, "程序错误!"));
  1954. throw;
  1955. }
  1956. }
  1957. /// <summary>
  1958. /// 黑屏代码操作(Status:1.新增,2.修改)
  1959. /// </summary>
  1960. /// <param name="dto"></param>
  1961. /// <returns></returns>
  1962. [HttpPost]
  1963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1964. public async Task<IActionResult> OpTicketBlackCode(OpTicketBlackCodeDto dto)
  1965. {
  1966. try
  1967. {
  1968. Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(dto);
  1969. if (groupData.Code != 0)
  1970. {
  1971. return Ok(JsonView(false, groupData.Msg));
  1972. }
  1973. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1974. }
  1975. catch (Exception ex)
  1976. {
  1977. return Ok(JsonView(false, "程序错误!"));
  1978. throw;
  1979. }
  1980. }
  1981. /// <summary>
  1982. /// 删除黑屏代码
  1983. /// </summary>
  1984. /// <param name="dto"></param>
  1985. /// <returns></returns>
  1986. [HttpPost]
  1987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1988. public async Task<IActionResult> DelTicketBlackCode(DelBaseDto dto)
  1989. {
  1990. try
  1991. {
  1992. var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync<Air_TicketBlackCode>(dto.Id.ToString(), dto.DeleteUserId);
  1993. if (!res)
  1994. {
  1995. return Ok(JsonView(false, "删除失败"));
  1996. }
  1997. return Ok(JsonView(true, "删除成功!"));
  1998. }
  1999. catch (Exception ex)
  2000. {
  2001. return Ok(JsonView(false, "程序错误!"));
  2002. throw;
  2003. }
  2004. }
  2005. #endregion
  2006. }
  2007. }