ResourceController.cs 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599
  1. using OASystem.API.OAMethodLib;
  2. using OASystem.Domain.Dtos.Resource;
  3. using OASystem.Domain.Entities.Groups;
  4. using OASystem.Infrastructure.Repositories.Groups;
  5. using System.Collections.Generic;
  6. namespace OASystem.API.Controllers
  7. {
  8. /// <summary>
  9. /// 资料相关
  10. /// </summary>
  11. //[Authorize]
  12. [Route("api/[controller]/[action]")]
  13. public class ResourceController : ControllerBase
  14. {
  15. private readonly IMapper _mapper;
  16. private readonly IConfiguration _config;
  17. private readonly CarDataRepository _carDataRep;
  18. private readonly LocalGuideDataRepository _localGuideDataRep;
  19. private readonly ThreeCodeRepository _ThreeCodeRep;
  20. private readonly HotelDataRepository _hotelDataRep;
  21. private readonly ResItemInfoRepository _resItemInfoRep;
  22. private readonly SetDataRepository _setDataRepository;
  23. private readonly CountryFeeRepository _countryFeeRep;
  24. private readonly SetDataTypeRepository _setDataTypeRep;
  25. private readonly AirTicketAgentRepository _airTicketAgentRep;
  26. private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
  27. private readonly OfficialActivitiesRepository _officialActivitiesRep;
  28. private readonly SqlSugarClient _sqlSugar;
  29. public ResourceController(IMapper mapper, IConfiguration config, SqlSugarClient sqlSugar, CarDataRepository carDataRep,
  30. LocalGuideDataRepository localGuideDataRep, ThreeCodeRepository threeCodeRep,
  31. HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
  32. CountryFeeRepository countryFeeRep, SetDataTypeRepository setDataTypeRep, AirTicketAgentRepository airTicketAgentRep,
  33. InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep, OfficialActivitiesRepository officialActivitiesRep)
  34. {
  35. _mapper = mapper;
  36. _config = config;
  37. _sqlSugar = sqlSugar;
  38. _carDataRep = carDataRep;
  39. _localGuideDataRep = localGuideDataRep;
  40. _ThreeCodeRep = threeCodeRep;
  41. _hotelDataRep = hotelDataRep;
  42. _resItemInfoRep = resItemInfoRep;
  43. _setDataRepository = setDataRepository;
  44. _countryFeeRep = countryFeeRep;
  45. _setDataTypeRep = setDataTypeRep;
  46. _airTicketAgentRep = airTicketAgentRep;
  47. _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
  48. _officialActivitiesRep = officialActivitiesRep;
  49. }
  50. #region 车公司资料板块
  51. /// <summary>
  52. /// 车公司信息查询
  53. /// </summary>
  54. /// <returns></returns>
  55. [HttpPost]
  56. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  57. public async Task<IActionResult> QueryCarData(QueryCarDataDto dto)
  58. {
  59. try
  60. {
  61. Result LocalGuide = await _carDataRep.QueryCarData(dto);
  62. if (LocalGuide.Code == 0)
  63. {
  64. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  65. }
  66. else
  67. {
  68. return Ok(JsonView(false, LocalGuide.Msg));
  69. }
  70. }
  71. catch (Exception)
  72. {
  73. return Ok(JsonView(false, "程序错误!"));
  74. throw;
  75. }
  76. }
  77. /// <summary>
  78. /// 车公司资料下拉框数据
  79. /// </summary>
  80. /// <returns></returns>
  81. [HttpPost]
  82. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  83. public async Task<IActionResult> QueryCarSelect()
  84. {
  85. try
  86. {
  87. var CarData = _carDataRep.QueryDto<Res_CarData, CarDataSelectView>().ToList();
  88. if (CarData.Count == 0)
  89. {
  90. return Ok(JsonView(false, "暂无数据!"));
  91. }
  92. CarData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
  93. CarData = CarData.Where((x, i) => CarData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
  94. CarData = CarData.OrderBy(x => x.Id).ToList();
  95. List<CarDataSelectView> data = new List<CarDataSelectView>();
  96. foreach (CarDataSelectView car in CarData)
  97. {
  98. if (!string.IsNullOrWhiteSpace(car.UnitArea))
  99. {
  100. data.Add(car);
  101. }
  102. }
  103. return Ok(JsonView(true, "查询成功", data));
  104. }
  105. catch (Exception)
  106. {
  107. return Ok(JsonView(false, "程序错误!"));
  108. throw;
  109. }
  110. }
  111. /// <summary>
  112. /// 车公司信息添加
  113. /// </summary>
  114. /// <returns></returns>
  115. [HttpPost]
  116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  117. public async Task<IActionResult> AddCarData(AddCarDataDto dto)
  118. {
  119. try
  120. {
  121. if (dto.UnitArea == "")
  122. {
  123. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  124. }
  125. if (dto.UnitName == "")
  126. {
  127. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  128. }
  129. if (dto.Contact == "")
  130. {
  131. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  132. }
  133. if (dto.ContactTel == "")
  134. {
  135. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  136. }
  137. 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();
  138. if (carDada.Count != 0)
  139. {
  140. return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
  141. }
  142. Res_CarData _CarData = _mapper.Map<Res_CarData>(dto);
  143. int id = await _carDataRep.AddAsyncReturnId(_CarData);
  144. if (id == 0)
  145. {
  146. return Ok(JsonView(false, "添加失败!"));
  147. }
  148. return Ok(JsonView(true, "添加成功", new { Id = id }));
  149. }
  150. catch (Exception ex)
  151. {
  152. return Ok(JsonView(false, "程序错误!"));
  153. throw;
  154. }
  155. }
  156. /// <summary>
  157. /// 车公司信息修改
  158. /// </summary>
  159. /// <returns></returns>
  160. [HttpPost]
  161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  162. public async Task<IActionResult> UpCarData(UpCarDataDto 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. bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
  183. {
  184. UnitArea = dto.UnitArea,
  185. UnitName = dto.UnitName,
  186. Address = dto.Address,
  187. Contact = dto.Contact,
  188. ContactTel = dto.ContactTel,
  189. ContactEmail = dto.ContactEmail,
  190. ContactFax = dto.ContactFax,
  191. CarDes = dto.CarDes,
  192. CarPicPaths = dto.CarPicPaths,
  193. OtherInfo = dto.OtherInfo,
  194. Score = dto.Score,
  195. QualificationScore = dto.QualificationScore,
  196. CarAgeScore = dto.CarAgeScore,
  197. CleanImgScore = dto.CleanImgScore,
  198. SmellScore = dto.SmellScore,
  199. WaterPaperScore = dto.WaterPaperScore,
  200. HardwareScore = dto.HardwareScore,
  201. TimeScore = dto.TimeScore,
  202. SafetyScore = dto.SafetyScore,
  203. DrivingAgeScore = dto.DrivingAgeScore,
  204. Remark = dto.Remark,
  205. });
  206. if (!res) { return Ok(JsonView(false, "修改失败!")); }
  207. return Ok(JsonView(true, "修改成功"));
  208. }
  209. catch (Exception ex)
  210. {
  211. return Ok(JsonView(false, "程序错误!"));
  212. throw;
  213. }
  214. }
  215. /// <summary>
  216. /// 车公司信息删除
  217. /// </summary>
  218. /// <returns></returns>
  219. [HttpPost]
  220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  221. public async Task<IActionResult> DelCarData(DelCarDataDto dto)
  222. {
  223. try
  224. {
  225. bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
  226. if (!res) { return Ok(JsonView(false, "删除失败!")); }
  227. return Ok(JsonView(true, "删除成功"));
  228. }
  229. catch (Exception ex)
  230. {
  231. return Ok(JsonView(false, "程序错误!"));
  232. throw;
  233. }
  234. }
  235. #endregion
  236. #region 导游地接资料板块
  237. /// <summary>
  238. /// 导游地接资料查询
  239. /// </summary>
  240. /// <param name="dto"></param>
  241. /// <returns></returns>
  242. [HttpPost]
  243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  244. public async Task<IActionResult> QueryLocalGuide(QueryLocalGuide dto)
  245. {
  246. try
  247. {
  248. Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
  249. if (LocalGuide.Code == 0)
  250. {
  251. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  252. }
  253. else
  254. {
  255. return Ok(JsonView(false, LocalGuide.Msg));
  256. }
  257. }
  258. catch (Exception ex)
  259. {
  260. return Ok(JsonView(false, "程序错误!"));
  261. throw;
  262. }
  263. }
  264. /// <summary>
  265. /// 导游地接资料下拉框数据
  266. /// </summary>
  267. /// <returns></returns>
  268. [HttpPost]
  269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  270. public async Task<IActionResult> QueryLocalGuideSelect()
  271. {
  272. try
  273. {
  274. var LocalGuide = _carDataRep.QueryDto<Res_LocalGuideData, QueryLocalGuideSelectView>().ToList();
  275. if (LocalGuide.Count == 0)
  276. {
  277. return Ok(JsonView(false, "暂无数据!"));
  278. }
  279. LocalGuide.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
  280. LocalGuide = LocalGuide.Where((x, i) => LocalGuide.FindIndex(z => z.UnitArea == x.UnitArea && z.UnitArea != "") == i).ToList();
  281. LocalGuide = LocalGuide.OrderBy(x => x.Id).ToList();
  282. List<QueryLocalGuideSelectView> data = new List<QueryLocalGuideSelectView>();
  283. foreach (QueryLocalGuideSelectView Local in LocalGuide)
  284. {
  285. if (!string.IsNullOrWhiteSpace(Local.UnitArea))
  286. {
  287. data.Add(Local);
  288. }
  289. }
  290. return Ok(JsonView(true, "查询成功", data));
  291. }
  292. catch (Exception)
  293. {
  294. return Ok(JsonView(false, "程序错误!"));
  295. throw;
  296. }
  297. }
  298. /// <summary>
  299. /// 导游地接信息操作(Status:1.新增,2.修改)
  300. /// </summary>
  301. /// <returns></returns>
  302. [HttpPost]
  303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  304. public async Task<IActionResult> OperationLocalGuide(LocalGuideOperationDto dto)
  305. {
  306. try
  307. {
  308. if (dto.UnitArea == "")
  309. {
  310. return Ok(JsonView(false, "请检查单位区域是否填写!"));
  311. }
  312. if (dto.UnitName == "")
  313. {
  314. return Ok(JsonView(false, "请检查单位名称是否填写!"));
  315. }
  316. if (dto.Contact == "")
  317. {
  318. return Ok(JsonView(false, "请检查单位联系人是否填写!"));
  319. }
  320. if (dto.ContactTel == "")
  321. {
  322. return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
  323. }
  324. Result result = await _localGuideDataRep.LocalGuideOperation(dto);
  325. if (result.Code != 0)
  326. {
  327. return Ok(JsonView(false, result.Msg));
  328. }
  329. return Ok(JsonView(true, result.Msg));
  330. }
  331. catch (Exception ex)
  332. {
  333. return Ok(JsonView(false, "程序错误!"));
  334. throw;
  335. }
  336. }
  337. /// <summary>
  338. /// 导游地接信息操作(删除)
  339. /// </summary>
  340. /// <returns></returns>
  341. [HttpPost]
  342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  343. public async Task<IActionResult> DelLocalGuide(LocalGuideDelDto dto)
  344. {
  345. try
  346. {
  347. var res = await _localGuideDataRep.SoftDeleteByIdAsync<Res_LocalGuideData>(dto.Id.ToString(), dto.DeleteUserId);
  348. if (!res)
  349. {
  350. return Ok(JsonView(false, "删除失败"));
  351. }
  352. return Ok(JsonView(true, "删除成功!"));
  353. }
  354. catch (Exception ex)
  355. {
  356. return Ok(JsonView(false, "程序错误!"));
  357. throw;
  358. }
  359. }
  360. #endregion
  361. #region 机场三字码信息
  362. /// <summary>
  363. /// 机场三字码查询
  364. /// </summary>
  365. /// <param name="dto"></param>
  366. /// <returns></returns>
  367. [HttpPost]
  368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  369. public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
  370. {
  371. try
  372. {
  373. Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
  374. if (LocalGuide.Code == 0)
  375. {
  376. return Ok(JsonView(true, "查询成功", LocalGuide.Data));
  377. }
  378. else
  379. {
  380. return Ok(JsonView(false, LocalGuide.Msg));
  381. }
  382. }
  383. catch (Exception ex)
  384. {
  385. return Ok(JsonView(false, "程序错误!"));
  386. throw;
  387. }
  388. }
  389. /// <summary>
  390. /// 机场三字码数据城市下拉框数据
  391. /// </summary>
  392. /// <returns></returns>
  393. [HttpPost]
  394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  395. public async Task<IActionResult> QueryThreeCodeSelect()
  396. {
  397. try
  398. {
  399. var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
  400. if (ThreeCode.Count == 0)
  401. {
  402. return Ok(JsonView(false, "暂无数据!"));
  403. }
  404. ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
  405. ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  406. ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
  407. List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
  408. foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
  409. {
  410. if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
  411. {
  412. data.Add(_ThreeCode);
  413. }
  414. }
  415. return Ok(JsonView(true, "查询成功", data));
  416. }
  417. catch (Exception)
  418. {
  419. return Ok(JsonView(false, "程序错误!"));
  420. throw;
  421. }
  422. }
  423. /// <summary>
  424. /// 机场三字码资料操作(Status:1.新增,2.修改)
  425. /// </summary>
  426. /// <param name="dto"></param>
  427. /// <returns></returns>
  428. [HttpPost]
  429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  430. public async Task<IActionResult> OperationThreeCode(ThreeCodeOperationDto dto)
  431. {
  432. try
  433. {
  434. if (dto.Three == "")
  435. {
  436. return Ok(JsonView(false, "请检查三字码是否填写!"));
  437. }
  438. if (dto.Country == "")
  439. {
  440. return Ok(JsonView(false, "请检查国家是否填写!"));
  441. }
  442. if (dto.City == "")
  443. {
  444. return Ok(JsonView(false, "请检查城市是否填写正确!"));
  445. }
  446. if (dto.AirPort == "")
  447. {
  448. return Ok(JsonView(false, "请检查机场是否填写正确!"));
  449. }
  450. Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
  451. if (result.Code != 0)
  452. {
  453. return Ok(JsonView(false, result.Msg));
  454. }
  455. return Ok(JsonView(true, result.Msg));
  456. }
  457. catch (Exception ex)
  458. {
  459. return Ok(JsonView(false, "程序错误!"));
  460. throw;
  461. }
  462. }
  463. /// <summary>
  464. /// 机场三字码资料操作(删除)
  465. /// </summary>
  466. /// <returns></returns>
  467. [HttpPost]
  468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  469. public async Task<IActionResult> DelThreeCode(ThreeCodeDelDto dto)
  470. {
  471. try
  472. {
  473. var res = await _ThreeCodeRep.SoftDeleteByIdAsync<Res_ThreeCode>(dto.Id.ToString(), dto.DeleteUserId);
  474. if (!res)
  475. {
  476. return Ok(JsonView(false, "删除失败"));
  477. }
  478. return Ok(JsonView(true, "删除成功!"));
  479. }
  480. catch (Exception ex)
  481. {
  482. return Ok(JsonView(false, "程序错误!"));
  483. throw;
  484. }
  485. }
  486. #endregion
  487. #region 代理出票合作方资料
  488. /// <summary>
  489. /// 代理出票合作方资料
  490. /// </summary>
  491. /// <param name="dto"></param>
  492. /// <returns></returns>
  493. [HttpPost]
  494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  495. public async Task<IActionResult> QueryAirTicketAgent(DtoBase dto)
  496. {
  497. try
  498. {
  499. List<Res_AirTicketAgent> res_AirTicketAgents = _airTicketAgentRep.Query<Res_AirTicketAgent>(a => a.IsDel == 0).ToList();
  500. if (res_AirTicketAgents.Count != 0)
  501. {
  502. res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
  503. if (dto.PageSize == 0 && dto.PageIndex == 0)
  504. {
  505. return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
  506. }
  507. else
  508. {
  509. int count = res_AirTicketAgents.Count;
  510. float totalPage = (float)count / dto.PageSize;//总页数
  511. if (totalPage == 0) totalPage = 1;
  512. else totalPage = (int)Math.Ceiling((double)totalPage);
  513. List<Res_AirTicketAgent> _AirTicketAgent = new List<Res_AirTicketAgent>();
  514. for (int i = 0; i < dto.PageSize; i++)
  515. {
  516. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  517. if (RowIndex < res_AirTicketAgents.Count)
  518. {
  519. _AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
  520. }
  521. else
  522. {
  523. break;
  524. }
  525. }
  526. return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
  527. }
  528. }
  529. else
  530. {
  531. return Ok(JsonView(false, "暂无数据!"));
  532. }
  533. }
  534. catch (Exception ex)
  535. {
  536. return Ok(JsonView(false, "程序错误!"));
  537. throw;
  538. }
  539. }
  540. /// <summary>
  541. /// 代理出票合作方资料操作(Status:1.新增,2.修改)
  542. /// </summary>
  543. /// <param name="dto"></param>
  544. /// <returns></returns>
  545. [HttpPost]
  546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  547. public async Task<IActionResult> OpAirTicketAgent(OpAirTicketAgentDto dto)
  548. {
  549. try
  550. {
  551. if (dto.Account == "")
  552. {
  553. return Ok(JsonView(false, "请检查代理商账户是否填写!"));
  554. }
  555. if (dto.Bank == "")
  556. {
  557. return Ok(JsonView(false, "请检查代理商银行是否填写!"));
  558. }
  559. if (dto.Name == "")
  560. {
  561. return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
  562. }
  563. Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
  564. if (result.Code != 0)
  565. {
  566. return Ok(JsonView(false, result.Msg));
  567. }
  568. return Ok(JsonView(true, result.Msg));
  569. }
  570. catch (Exception ex)
  571. {
  572. return Ok(JsonView(false, "程序错误!"));
  573. throw;
  574. }
  575. }
  576. /// <summary>
  577. /// 代理出票合作方资料操作(删除)
  578. /// </summary>
  579. /// <returns></returns>
  580. [HttpPost]
  581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  582. public async Task<IActionResult> DelAirTicketAgent(DelBaseDto dto)
  583. {
  584. try
  585. {
  586. var res = await _airTicketAgentRep.SoftDeleteByIdAsync<Res_AirTicketAgent>(dto.Id.ToString(), dto.DeleteUserId);
  587. if (!res)
  588. {
  589. return Ok(JsonView(false, "删除失败"));
  590. }
  591. return Ok(JsonView(true, "删除成功!"));
  592. }
  593. catch (Exception ex)
  594. {
  595. return Ok(JsonView(false, "程序错误!"));
  596. throw;
  597. }
  598. }
  599. #endregion
  600. #region 酒店资料数据
  601. /// <summary>
  602. /// 酒店信息查询
  603. /// </summary>
  604. /// <param name="dto"></param>
  605. /// <returns></returns>
  606. [HttpPost]
  607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  608. public async Task<IActionResult> QueryHotelData(QueryHotelDataDto dto)
  609. {
  610. try
  611. {
  612. Result hotelData = await _hotelDataRep.QueryHotelData(dto);
  613. if (hotelData.Code == 0)
  614. {
  615. return Ok(JsonView(true, "查询成功", hotelData.Data));
  616. }
  617. else
  618. {
  619. return Ok(JsonView(false, hotelData.Msg));
  620. }
  621. }
  622. catch (Exception ex)
  623. {
  624. return Ok(JsonView(false, "程序错误!"));
  625. throw;
  626. }
  627. }
  628. /// <summary>
  629. /// 酒店资料下拉框数据
  630. /// </summary>
  631. /// <returns></returns>
  632. [HttpPost]
  633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  634. public async Task<IActionResult> QueryHotelDataSelect()
  635. {
  636. try
  637. {
  638. var HotelData = _carDataRep.QueryDto<Res_HotelData, QueryHotelDataSelect>().ToList();
  639. if (HotelData.Count == 0)
  640. {
  641. return Ok(JsonView(false, "暂无数据!"));
  642. }
  643. HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
  644. HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
  645. HotelData = HotelData.OrderBy(x => x.Id).ToList();
  646. List<QueryHotelDataSelect> data = new List<QueryHotelDataSelect>();
  647. foreach (QueryHotelDataSelect Hotel in HotelData)
  648. {
  649. if (!string.IsNullOrWhiteSpace(Hotel.City))
  650. {
  651. data.Add(Hotel);
  652. }
  653. }
  654. return Ok(JsonView(true, "查询成功", data));
  655. }
  656. catch (Exception)
  657. {
  658. return Ok(JsonView(false, "程序错误!"));
  659. throw;
  660. }
  661. }
  662. /// <summary>
  663. /// 酒店资料操作(Status:1.新增,2.修改)
  664. /// </summary>
  665. /// <param name="dto"></param>
  666. /// <returns></returns>
  667. [HttpPost]
  668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  669. public async Task<IActionResult> OperationHotelData(OperationHotelDto dto)
  670. {
  671. try
  672. {
  673. if (dto.City == "")
  674. {
  675. return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
  676. }
  677. if (dto.Name == "")
  678. {
  679. return Ok(JsonView(false, "请检查酒店名称是否填写!"));
  680. }
  681. if (dto.Address == "")
  682. {
  683. return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
  684. }
  685. if (dto.Tel == "")
  686. {
  687. return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
  688. }
  689. Result result = await _hotelDataRep.OperationHotelData(dto);
  690. if (result.Code != 0)
  691. {
  692. return Ok(JsonView(false, result.Msg));
  693. }
  694. return Ok(JsonView(true, result.Msg));
  695. }
  696. catch (Exception ex)
  697. {
  698. return Ok(JsonView(false, "程序错误!"));
  699. throw;
  700. }
  701. }
  702. /// <summary>
  703. /// 酒店资料操作(删除)
  704. /// </summary>
  705. /// <returns></returns>
  706. [HttpPost]
  707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  708. public async Task<IActionResult> DelHotelData(DelHotelDataDto dto)
  709. {
  710. try
  711. {
  712. var res = await _hotelDataRep.SoftDeleteByIdAsync<Res_HotelData>(dto.Id.ToString(), dto.DeleteUserId);
  713. if (!res)
  714. {
  715. return Ok(JsonView(false, "删除失败"));
  716. }
  717. return Ok(JsonView(true, "删除成功!"));
  718. }
  719. catch (Exception ex)
  720. {
  721. return Ok(JsonView(false, "程序错误!"));
  722. throw;
  723. }
  724. }
  725. #endregion
  726. #region 签证费用资料
  727. /// <summary>
  728. /// 签证费用资料查询
  729. /// </summary>
  730. /// <param name="dto"></param>
  731. /// <returns></returns>
  732. [HttpPost]
  733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  734. public async Task<IActionResult> QueryCountryFeeCost(DtoBase dto)
  735. {
  736. try
  737. {
  738. if (dto.PortType == 1)
  739. {
  740. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  741. if (CountryFee.Count == 0)
  742. {
  743. return Ok(JsonView(false, "暂无数据!"));
  744. }
  745. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  746. return Ok(JsonView(true, "查询成功", CountryFee));
  747. }
  748. else if (dto.PortType == 2)
  749. {
  750. var CountryFee = _countryFeeRep.QueryDto<Res_CountryFeeCost, CountryFeeCostView>().ToList();
  751. if (CountryFee.Count == 0)
  752. {
  753. return Ok(JsonView(false, "暂无数据!"));
  754. }
  755. CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
  756. return Ok(JsonView(true, "查询成功", CountryFee));
  757. }
  758. else
  759. {
  760. return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
  761. }
  762. }
  763. catch (Exception ex)
  764. {
  765. return Ok(JsonView(false, "程序错误!"));
  766. throw;
  767. }
  768. }
  769. /// <summary>
  770. /// 签证费用资料操作(Status:1.新增,2.修改)
  771. /// </summary>
  772. /// <param name="dto"></param>
  773. /// <returns></returns>
  774. [HttpPost]
  775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  776. public async Task<IActionResult> OperationCountryFeeCost(OperationCountryFeeCostDto dto)
  777. {
  778. try
  779. {
  780. if (dto.VisaContinent == "")
  781. {
  782. return Ok(JsonView(false, "请检查州名是否填写!"));
  783. }
  784. if (dto.VisaCountry == "")
  785. {
  786. return Ok(JsonView(false, "请检查国家名是否填写!"));
  787. }
  788. if (dto.VisaTime == "1")
  789. {
  790. return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
  791. }
  792. if (dto.UrgentTime == "1")
  793. {
  794. return Ok(JsonView(false, "请检加急时间是否填写正确!"));
  795. }
  796. if (dto.VisaPrice == 0)
  797. {
  798. return Ok(JsonView(false, "请检查签证费用是否填写正确,小数点后可1到2位!"));
  799. }
  800. if (dto.VisaPrice == 1)
  801. {
  802. return Ok(JsonView(false, "请检查签证加急费用是否填写正确,小数点后可1到2位!"));
  803. }
  804. Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
  805. if (result.Code != 0)
  806. {
  807. return Ok(JsonView(false, result.Msg));
  808. }
  809. return Ok(JsonView(true, result.Msg));
  810. }
  811. catch (Exception ex)
  812. {
  813. return Ok(JsonView(false, "程序错误!"));
  814. throw;
  815. }
  816. }
  817. /// <summary>
  818. /// 签证费用资料操作(删除)
  819. /// </summary>
  820. /// <returns></returns>
  821. [HttpPost]
  822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  823. public async Task<IActionResult> DelCountryFeeCost(DelCountryFeeCostDto dto)
  824. {
  825. try
  826. {
  827. var res = await _countryFeeRep.SoftDeleteByIdAsync<Res_CountryFeeCost>(dto.Id.ToString(), dto.DeleteUserId);
  828. if (!res)
  829. {
  830. return Ok(JsonView(false, "删除失败"));
  831. }
  832. return Ok(JsonView(true, "删除成功!"));
  833. }
  834. catch (Exception ex)
  835. {
  836. return Ok(JsonView(false, "程序错误!"));
  837. throw;
  838. }
  839. }
  840. #endregion
  841. #region 物料信息、供应商维护
  842. #region 供应商
  843. /// <summary>
  844. /// 物料供应商查询
  845. /// </summary>
  846. /// <param name="paras">Json序列化</param>
  847. /// <returns></returns>
  848. [HttpPost]
  849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  850. public async Task<IActionResult> PostSearchItemVendor(JsonDtoBase _jsonDto)
  851. {
  852. if (string.IsNullOrEmpty(_jsonDto.Paras))
  853. {
  854. return Ok(JsonView(false, "参数为空"));
  855. }
  856. Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize<Search_ResItemVendorDto>(_jsonDto.Paras);
  857. if (_ItemVendorDto != null)
  858. {
  859. if (_ItemVendorDto.SearchType == 2) //获取列表
  860. {
  861. Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
  862. return Ok(rstList);
  863. }
  864. else
  865. {
  866. Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
  867. return Ok(rstInfo);
  868. }
  869. }
  870. else
  871. {
  872. return Ok(JsonView(false, "参数反序列化失败"));
  873. }
  874. return Ok(JsonView(false));
  875. }
  876. /// <summary>
  877. /// 创建/编辑/删除供应商信息
  878. /// </summary>
  879. /// <param name="_dto"></param>
  880. /// <returns></returns>
  881. [HttpPost]
  882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  883. public async Task<IActionResult> PostEditItemVendor(Edit_ResItemVendorDto _dto)
  884. {
  885. bool rst = false;
  886. if (_dto.EditType >= 0)
  887. {
  888. if (string.IsNullOrEmpty(_dto.VendorFullName))
  889. {
  890. return Ok(JsonView(false, "全称未填写"));
  891. }
  892. if (string.IsNullOrEmpty(_dto.VendorLinker))
  893. {
  894. return Ok(JsonView(false, "联系人未填写"));
  895. }
  896. if (string.IsNullOrEmpty(_dto.VendorMobile))
  897. {
  898. return Ok(JsonView(false, "联系人手机号未填写"));
  899. }
  900. if (string.IsNullOrEmpty(_dto.BusRange))
  901. {
  902. return Ok(JsonView(false, "经营范围未选择"));
  903. }
  904. if (_dto.EditType == 0)
  905. {
  906. var checkEmpty = _resItemInfoRep.Query<Res_ItemVendor>(s => s.FullName == _dto.VendorFullName).First();
  907. if (checkEmpty != null)
  908. {
  909. return Ok(JsonView(false, "已存在同名供应商"));
  910. }
  911. rst = await _resItemInfoRep.addVendorInfo(_dto);
  912. }
  913. else if (_dto.EditType == 1)
  914. {
  915. if (_dto.VendorId > 0)
  916. {
  917. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  918. rst = await _resItemInfoRep.updVendorInfo(_entity);
  919. }
  920. else
  921. {
  922. return Ok(JsonView(false, "供应商不存在"));
  923. }
  924. }
  925. }
  926. else
  927. {
  928. if (_dto.VendorId < 1 || _dto.SysUserId < 1)
  929. {
  930. return Ok(JsonView(false, "用户Id或供应商Id不存在"));
  931. }
  932. Res_ItemVendor _entity = _mapper.Map<Res_ItemVendor>(_dto);
  933. rst = await _resItemInfoRep.delVendorInfo(_entity);
  934. }
  935. return Ok(JsonView(rst));
  936. }
  937. #endregion
  938. #region 物料信息
  939. /// <summary>
  940. /// 物料信息查询
  941. /// </summary>
  942. /// <param name="paras">Json序列化</param>
  943. /// <returns></returns>
  944. [HttpPost]
  945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  946. public async Task<IActionResult> PostSearchItemInfo(string paras)
  947. {
  948. if (string.IsNullOrEmpty(paras))
  949. {
  950. return Ok(JsonView(false, "参数为空"));
  951. }
  952. Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize<Search_ItemInfoDto>(paras);
  953. if (_ItemInfoDto != null)
  954. {
  955. if (_ItemInfoDto.SearchType == 2) //获取列表
  956. {
  957. Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
  958. return Ok(rstList);
  959. }
  960. else
  961. {
  962. Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
  963. return Ok(rstInfo);
  964. }
  965. }
  966. else
  967. {
  968. return Ok(JsonView(false, "参数反序列化失败"));
  969. }
  970. return Ok(JsonView(false));
  971. }
  972. /// <summary>
  973. /// 创建/编辑/删除物料信息
  974. /// </summary>
  975. ///
  976. /// <returns></returns>
  977. [HttpPost]
  978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  979. public async Task<IActionResult> PostEditItemInfo(Edit_ResItemInfoDto _dto)
  980. {
  981. bool rst = false;
  982. if (_dto.EditType >= 0)
  983. {
  984. if (_dto.VendorId < 1)
  985. {
  986. return Ok(JsonView(false, "未选择供应商"));
  987. }
  988. if (string.IsNullOrEmpty(_dto.ItemName))
  989. {
  990. return Ok(JsonView(false, "物料名称为空"));
  991. }
  992. if (_dto.ItemTypeId < 1)
  993. {
  994. return Ok(JsonView(false, "未选择物料类型"));
  995. }
  996. if (_dto.SysUserId < 1)
  997. {
  998. return Ok(JsonView(false, "当前操作用户Id为空"));
  999. }
  1000. if (_dto.CurrRate <= 0)
  1001. {
  1002. return Ok(JsonView(false, "物料录入价格不能小于等于0"));
  1003. }
  1004. if (_dto.EditType == 0)
  1005. {
  1006. //判断物料名称、类型、供应商全部重复
  1007. var checkEmpty = _resItemInfoRep.Query<Res_ItemDetailInfo>(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
  1008. if (checkEmpty != null)
  1009. {
  1010. return Ok(JsonView(false, "已存在重复物料信息"));
  1011. }
  1012. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1013. DateTime dtNow = DateTime.Now;
  1014. _entity.CreateUserId = _dto.SysUserId;
  1015. _entity.IsDel = 0;
  1016. _entity.MaxRate = _dto.CurrRate;
  1017. _entity.MaxDt = dtNow;
  1018. _entity.CurrRate = _dto.CurrRate;
  1019. _entity.CurrDt = dtNow;
  1020. _entity.MinRate = _dto.CurrRate;
  1021. _entity.MinDt = dtNow;
  1022. rst = await _resItemInfoRep.AddAsync<Res_ItemDetailInfo>(_entity) > 0;
  1023. }
  1024. else if (_dto.EditType == 1)
  1025. {
  1026. if (_dto.ItemId > 0)
  1027. {
  1028. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1029. _entity.Id = _dto.ItemId;
  1030. rst = await _resItemInfoRep.updItemInfo(_entity);
  1031. }
  1032. else
  1033. {
  1034. return Ok(JsonView(false, "供应商不存在"));
  1035. }
  1036. }
  1037. }
  1038. else
  1039. {
  1040. if (_dto.ItemId < 1 || _dto.SysUserId < 1)
  1041. {
  1042. return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
  1043. }
  1044. Res_ItemDetailInfo _entity = _mapper.Map<Res_ItemDetailInfo>(_dto);
  1045. rst = await _resItemInfoRep.delItemInfo(_entity);
  1046. }
  1047. return Ok(JsonView(rst));
  1048. }
  1049. #endregion
  1050. #region 物料类型获取
  1051. #endregion
  1052. #endregion
  1053. #region 备忘录
  1054. /// <summary>
  1055. /// 备忘录查询
  1056. /// </summary>
  1057. /// <param name="paras">Json序列化</param>
  1058. /// <returns></returns>
  1059. [HttpPost]
  1060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1061. public async Task<IActionResult> PostSearchMemo(JsonDtoBase _jsonDto)
  1062. {
  1063. if (string.IsNullOrEmpty(_jsonDto.Paras))
  1064. {
  1065. return Ok(JsonView(false, "参数为空"));
  1066. }
  1067. Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject<Search_ResMemoDto>(_jsonDto.Paras);
  1068. if (_memoDto != null)
  1069. {
  1070. if (_memoDto.SearchType == 2)
  1071. {
  1072. //获取列表
  1073. string sqlWhere = string.Format(" Where IsDel=0 ");
  1074. #region SqlWhere
  1075. if (!string.IsNullOrEmpty(_memoDto.Abstracts))
  1076. {
  1077. sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
  1078. }
  1079. if (!string.IsNullOrEmpty(_memoDto.Title))
  1080. {
  1081. sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
  1082. }
  1083. if (_memoDto.ReadLevel > 0)
  1084. {
  1085. sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
  1086. }
  1087. #endregion
  1088. int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
  1089. int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
  1090. string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
  1091. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1092. m.LastedEditDt,m.LastedEditorId
  1093. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1094. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
  1095. ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
  1096. Res_MemoListView rst = new Res_MemoListView();
  1097. rst.CurrPageIndex = currPIndex;
  1098. rst.CurrPageSize = currPSize;
  1099. List<Res_MemoView> dataSource = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sql).ToList();
  1100. Dictionary<int, string> userDic = new Dictionary<int, string>();
  1101. foreach (var item in dataSource)
  1102. {
  1103. if (userDic.ContainsKey(item.LastedEditorId))
  1104. {
  1105. item.LastedEditor = userDic[item.LastedEditorId];
  1106. }
  1107. else
  1108. {
  1109. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == item.LastedEditorId).First();
  1110. userDic[item.LastedEditorId] = _sysUser.CnName;
  1111. item.LastedEditor = _sysUser.CnName;
  1112. }
  1113. }
  1114. rst.DataList = new List<Res_MemoView>(dataSource);
  1115. if (rst.DataList.Count > 0)
  1116. {
  1117. string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
  1118. int dataCount = _carDataRep._sqlSugar.SqlQueryable<Res_MemoInfo>(sqlCount).Count();
  1119. rst.DataCount = dataCount;
  1120. }
  1121. return Ok(JsonView(rst));
  1122. }
  1123. else
  1124. {
  1125. //获取对象
  1126. string sqlSingle = string.Format(@" Select
  1127. m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
  1128. m.LastedEditDt,m.LastedEditor,m.MDFilePath
  1129. From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
  1130. Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
  1131. Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable<Res_MemoView>(sqlSingle).First();
  1132. if (_result != null)
  1133. {
  1134. Sys_Users _sysUser = _carDataRep.Query<Sys_Users>(s => s.Id == _result.LastedEditorId).First();
  1135. _result.LastedEditor = _sysUser.CnName;
  1136. _result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
  1137. return Ok(JsonView(_result));
  1138. }
  1139. }
  1140. }
  1141. else
  1142. {
  1143. return Ok(JsonView(false, "参数反序列化失败"));
  1144. }
  1145. return Ok(JsonView(false));
  1146. }
  1147. /// <summary>
  1148. /// 创建/编辑/删除备忘录信息
  1149. /// </summary>
  1150. /// <param name="_dto"></param>
  1151. /// <returns></returns>
  1152. [HttpPost]
  1153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1154. public async Task<IActionResult> PostEditMemo(Edit_ResMemoDto _dto)
  1155. {
  1156. bool rst = false;
  1157. if (_dto.SysUserId < 1)
  1158. {
  1159. return Ok(JsonView(false, "操作人失效"));
  1160. }
  1161. Sys_Users _sysUser = _resItemInfoRep.Query<Sys_Users>(s => s.Id == _dto.SysUserId).First();
  1162. if (_sysUser == null)
  1163. {
  1164. return Ok(JsonView(false, "操作人失效02"));
  1165. }
  1166. if (_dto.EditType >= 0)
  1167. {
  1168. if (_dto.ReadLevel < 1)
  1169. {
  1170. return Ok(JsonView(false, "未知的阅读等级"));
  1171. }
  1172. if (string.IsNullOrEmpty(_dto.Title.Trim()))
  1173. {
  1174. return Ok(JsonView(false, "标题不能为空"));
  1175. }
  1176. if (string.IsNullOrEmpty(_dto.Content.Trim()))
  1177. {
  1178. return Ok(JsonView(false, "正文内容不能为空"));
  1179. }
  1180. //新增备忘录
  1181. DateTime dtNow = DateTime.Now;
  1182. string dir = AppSettingsHelper.Get("MemoCurrPath");
  1183. string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
  1184. string content = JsonConvert.SerializeObject(_dto.Content);
  1185. if (_dto.EditType == 0)//新增
  1186. {
  1187. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1188. if (savePath.Length > 0)
  1189. {
  1190. Res_MemoInfo _insert = new Res_MemoInfo();
  1191. _insert.Abstracts = _dto.Abstracts;
  1192. _insert.Title = _dto.Title;
  1193. _insert.DepartmentId = _sysUser.DepId;
  1194. _insert.CreateUserId = _sysUser.Id;
  1195. _insert.LastedEditDt = dtNow;
  1196. _insert.LastedEditor = _sysUser.Id;
  1197. _insert.MDFilePath = savePath;
  1198. _insert.ReadLevel = _dto.ReadLevel;
  1199. _insert.Title = _dto.Title;
  1200. int result = await _resItemInfoRep.AddAsync(_insert);
  1201. return Ok(JsonView(result > 0));
  1202. }
  1203. else
  1204. {
  1205. return Ok(JsonView(false, "路径保存失败"));
  1206. }
  1207. }
  1208. else//修改
  1209. {
  1210. if (_dto.MemoId < 1)
  1211. {
  1212. return Ok(JsonView(false, "MemoId不存在"));
  1213. }
  1214. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1215. if (_source == null)
  1216. {
  1217. return Ok(JsonView(false, "MemoInfo不存在"));
  1218. }
  1219. //修改
  1220. string sourcePath = _source.MDFilePath;
  1221. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1222. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1223. string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
  1224. if (savePath.Length > 0)
  1225. {
  1226. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1227. .SetColumns(it => it.LastedEditDt == DateTime.Now)
  1228. .SetColumns(it => it.LastedEditor == _sysUser.Id)
  1229. .SetColumns(it => it.Abstracts == _dto.Abstracts)
  1230. .SetColumns(it => it.MDFilePath == savePath)
  1231. .SetColumns(it => it.ReadLevel == _dto.ReadLevel)
  1232. .SetColumns(it => it.Title == _dto.Title)
  1233. .Where(s => s.Id == _source.Id)
  1234. .ExecuteCommandAsync();
  1235. return Ok(JsonView(result > 0));
  1236. }
  1237. }
  1238. }
  1239. else
  1240. {
  1241. //删除
  1242. if (_dto.MemoId < 1)
  1243. {
  1244. return Ok(JsonView(false, "MemoId不存在"));
  1245. }
  1246. Res_MemoInfo _source = _resItemInfoRep.Query<Res_MemoInfo>(s => s.Id == _dto.MemoId).First();
  1247. if (_source == null)
  1248. {
  1249. return Ok(JsonView(false, "MemoInfo不存在"));
  1250. }
  1251. //修改
  1252. string sourcePath = _source.MDFilePath;
  1253. string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
  1254. new IOOperatorHelper().MoveFile(sourcePath, recycDir);
  1255. var result = await _resItemInfoRep._sqlSugar.Updateable<Res_MemoInfo>()
  1256. .SetColumns(it => it.IsDel == 1)
  1257. .SetColumns(it => it.DeleteUserId == _sysUser.Id)
  1258. .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  1259. .Where(s => s.Id == _source.Id)
  1260. .ExecuteCommandAsync();
  1261. return Ok(JsonView(result > 0));
  1262. }
  1263. return Ok(JsonView(rst));
  1264. }
  1265. #endregion
  1266. #region 商邀资料
  1267. /// <summary>
  1268. /// 商邀资料查询
  1269. /// </summary>
  1270. /// <param name="dto"></param>
  1271. /// <returns></returns>
  1272. [HttpPost]
  1273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1274. public async Task<IActionResult> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
  1275. {
  1276. try
  1277. {
  1278. Result groupData = await _InvitationOfficialActivityDataRep.QueryInvitationOfficialActivityData(dto);
  1279. if (groupData.Code != 0)
  1280. {
  1281. return Ok(JsonView(false, groupData.Msg));
  1282. }
  1283. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1284. }
  1285. catch (Exception ex)
  1286. {
  1287. return Ok(JsonView(false, "程序错误!"));
  1288. throw;
  1289. }
  1290. }
  1291. /// <summary>
  1292. /// 根据商邀资料Id查询信息
  1293. /// </summary>
  1294. /// <param name="dto"></param>
  1295. /// <returns></returns>
  1296. [HttpPost]
  1297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1298. public async Task<IActionResult> QueryInvitationOfficialActivityById(QueryInvitationOfficialActivityByIdDto dto)
  1299. {
  1300. try
  1301. {
  1302. Result groupData = await _InvitationOfficialActivityDataRep.QueryInvitationOfficialActivityById(dto);
  1303. if (groupData.Code != 0)
  1304. {
  1305. return Ok(JsonView(false, groupData.Msg));
  1306. }
  1307. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1308. }
  1309. catch (Exception ex)
  1310. {
  1311. return Ok(JsonView(false, "程序错误!"));
  1312. throw;
  1313. }
  1314. }
  1315. /// <summary>
  1316. /// 商邀资料操作(Status:1.新增,2.修改)
  1317. /// </summary>
  1318. /// <param name="dto"></param>
  1319. /// <returns></returns>
  1320. [HttpPost]
  1321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1322. public async Task<IActionResult> OpInvitationOfficialActivity(OpInvitationOfficialActivityDto dto)
  1323. {
  1324. try
  1325. {
  1326. Result groupData = await _InvitationOfficialActivityDataRep.OpInvitationOfficialActivity(dto);
  1327. if (groupData.Code != 0)
  1328. {
  1329. return Ok(JsonView(false, groupData.Msg));
  1330. }
  1331. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1332. }
  1333. catch (Exception ex)
  1334. {
  1335. return Ok(JsonView(false, "程序错误!"));
  1336. throw;
  1337. }
  1338. }
  1339. /// <summary>
  1340. /// 删除商邀资料信息
  1341. /// </summary>
  1342. /// <param name="dto"></param>
  1343. /// <returns></returns>
  1344. [HttpPost]
  1345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1346. public async Task<IActionResult> DelInvitationOfficialActivity(DelBaseDto dto)
  1347. {
  1348. try
  1349. {
  1350. var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync<Res_InvitationOfficialActivityData>(dto.Id.ToString(), dto.DeleteUserId);
  1351. if (!res)
  1352. {
  1353. return Ok(JsonView(false, "删除失败"));
  1354. }
  1355. return Ok(JsonView(true, "删除成功!"));
  1356. }
  1357. catch (Exception ex)
  1358. {
  1359. return Ok(JsonView(false, "程序错误!"));
  1360. throw;
  1361. }
  1362. }
  1363. #region 公务出访
  1364. /// <summary>
  1365. /// 获取团组所有信息,绑定下拉框
  1366. /// </summary>
  1367. /// <param name="dto"></param>
  1368. /// <returns></returns>
  1369. [HttpPost]
  1370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1371. public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
  1372. {
  1373. List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.CreateTime, OrderByType.Desc).ToList();
  1374. List<Sys_SetData> data = await _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 38).ToListAsync();
  1375. List<Grp_DeleFile> _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel==0 && a.Category== 970).ToList();
  1376. return Ok(JsonView(true, "查询成功!", new { Delegation=_DelegationInfos,SetData=data, DeleFile= _DeleFile }));
  1377. }
  1378. [HttpPost]
  1379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1380. public async Task<IActionResult> QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
  1381. {
  1382. try
  1383. {
  1384. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto);
  1385. if (groupData.Code != 0)
  1386. {
  1387. return Ok(JsonView(false, groupData.Msg));
  1388. }
  1389. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1390. }
  1391. catch (Exception ex)
  1392. {
  1393. return Ok(JsonView(false, "程序错误!"));
  1394. throw;
  1395. }
  1396. }
  1397. /// <summary>
  1398. /// 根据公务出访数据Id查询数据
  1399. /// </summary>
  1400. /// <param name="dto"></param>
  1401. /// <returns></returns>
  1402. [HttpPost]
  1403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1404. public async Task<IActionResult> QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
  1405. {
  1406. try
  1407. {
  1408. Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
  1409. if (groupData.Code != 0)
  1410. {
  1411. return Ok(JsonView(false, groupData.Msg));
  1412. }
  1413. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1414. }
  1415. catch (Exception ex)
  1416. {
  1417. return Ok(JsonView(false, "程序错误!"));
  1418. throw;
  1419. }
  1420. }
  1421. /// <summary>
  1422. /// 公务出访操作(Status:1.新增,2.修改)
  1423. /// </summary>
  1424. /// <param name="dto"></param>
  1425. /// <returns></returns>
  1426. [HttpPost]
  1427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1428. public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
  1429. {
  1430. try
  1431. {
  1432. Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
  1433. if (groupData.Code != 0)
  1434. {
  1435. return Ok(JsonView(false, groupData.Msg));
  1436. }
  1437. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1438. }
  1439. catch (Exception ex)
  1440. {
  1441. return Ok(JsonView(false, "程序错误!"));
  1442. throw;
  1443. }
  1444. }
  1445. [HttpPost]
  1446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1447. public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
  1448. {
  1449. try
  1450. {
  1451. int Type =int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
  1452. int DiId= int.Parse(Request.Headers["DiId"]);
  1453. int CreateUserId= DiId = int.Parse(Request.Headers["CreateUserId"]);
  1454. if (file != null)
  1455. {
  1456. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1457. //文件名称
  1458. string projectFileName = file.FileName;
  1459. //上传的文件的路径
  1460. string filePath = "";
  1461. if (!Directory.Exists(fileDir))
  1462. {
  1463. Directory.CreateDirectory(fileDir);
  1464. }
  1465. //上传的文件的路径
  1466. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  1467. using (FileStream fs = System.IO.File.Create(filePath))
  1468. {
  1469. file.CopyTo(fs);
  1470. fs.Flush();
  1471. }
  1472. Grp_DeleFile d = new Grp_DeleFile();
  1473. d.Diid = DiId;
  1474. d.Category = 970;
  1475. if (Type == 1) d.Kind = 1;
  1476. else if (Type == 2) d.Kind = 2;
  1477. else if (Type == 3) d.Kind = 3;
  1478. d.FileName = projectFileName;
  1479. d.FilePath = "";
  1480. d.CreateUserId = CreateUserId;
  1481. int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
  1482. return Ok(JsonView(true, "上传成功!", projectFileName));
  1483. }
  1484. else
  1485. {
  1486. return Ok(JsonView(false, "上传失败!"));
  1487. }
  1488. }
  1489. catch (Exception ex)
  1490. {
  1491. return Ok(JsonView(false, "程序错误!"));
  1492. throw;
  1493. }
  1494. }
  1495. #endregion
  1496. }
  1497. #endregion
  1498. }