EnterExitCostQuoteRepository.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using AutoMapper;
  2. using OASystem.Domain;
  3. using OASystem.Domain.Dtos.Groups;
  4. using OASystem.Domain.Entities.Groups;
  5. using OASystem.Domain.ViewModels.Groups;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace OASystem.Infrastructure.Repositories.Groups
  12. {
  13. /// <summary>
  14. /// 团组-出入境费用报价表 仓储
  15. /// </summary>
  16. public class EnterExitCostQuoteRepository : BaseRepository<Grp_EnterExitCostQuoteItem, EnterExitCostQuoteView>
  17. {
  18. private readonly IMapper _mapper;
  19. public EnterExitCostQuoteRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
  20. {
  21. _mapper = mapper;
  22. }
  23. /// <summary>
  24. /// 初始化基础项
  25. /// </summary>
  26. /// <param name="removeNl">是否移除换行符</param>
  27. /// <returns></returns>
  28. public async Task<List<InitBasicItemView>> InitBasicItemAsync(bool removeNl)
  29. {
  30. var origList = await _sqlSugar.Queryable<Sys_SetData>()
  31. .Where(x => x.IsDel == 0 && x.STid == 105)
  32. .Select(x => new
  33. {
  34. Id = x.Id,
  35. Name = x.Name,
  36. Index = x.Remark ?? "-1"
  37. }).ToListAsync();
  38. var newList = origList.Select(x => new InitBasicItemView
  39. {
  40. Id = x.Id,
  41. Name = removeNl ? x.Name.Replace("\r\n", "") : x.Name,
  42. Index = int.TryParse(x.Index,out int index) ? index : -1
  43. })
  44. .OrderBy(x => x.Index)
  45. .ToList();
  46. return newList;
  47. }
  48. /// <summary>
  49. /// 获取报价名称列表
  50. /// </summary>
  51. /// <param name="name"></param>
  52. /// <param name="pageIndex"></param>
  53. /// <param name="pageSize"></param>
  54. /// <returns></returns>
  55. public async Task<JsonView> QuoteNameListAsync(EnterExitCostQuoteNameListDto dto)
  56. {
  57. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  58. string name = dto.Name;
  59. if (pageIndex < 1 || pageSize < 1)
  60. {
  61. var noPageList = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>()
  62. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.Name))
  63. .WhereIF(!string.IsNullOrEmpty(name), x => x.Name.Contains(name))
  64. .Select(x => new EnterExitCostQuoteNameView
  65. {
  66. Id = x.Id,
  67. Name = x.Name
  68. }).ToListAsync();
  69. return new JsonView
  70. {
  71. Code = StatusCodes.Status200OK,
  72. Msg = "获取成功",
  73. Count = noPageList.Count,
  74. Data = noPageList
  75. };
  76. }
  77. RefAsync<int> total = 0;
  78. var pageList = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>()
  79. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.Name))
  80. .WhereIF(!string.IsNullOrEmpty(name), x => x.Name.Contains(name))
  81. .Select(x => new EnterExitCostQuoteNameView
  82. {
  83. Id = x.Id,
  84. Name = x.Name
  85. }).ToPageListAsync(pageIndex, pageSize, total);
  86. return new JsonView
  87. {
  88. Code = StatusCodes.Status200OK,
  89. Msg = "获取成功",
  90. Count = total,
  91. Data = pageList
  92. };
  93. }
  94. /// <summary>
  95. /// 获取团组名称列表
  96. /// </summary>
  97. /// <param name="name"></param>
  98. /// <param name="pageIndex"></param>
  99. /// <param name="pageSize"></param>
  100. /// <returns></returns>
  101. public async Task<JsonView> GroupNameListAsync(EnterExitCostQuoteGroupNameListDto dto)
  102. {
  103. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  104. string name = dto.Name;
  105. if (pageIndex < 1 || pageSize < 1)
  106. {
  107. var noPageList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  108. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  109. .WhereIF(!string.IsNullOrEmpty(name), x => x.TeamName.Contains(name))
  110. .OrderByDescending(x => x.CreateTime)
  111. .Select(x => new EnterExitCostQuoteGroupNameView
  112. {
  113. Id = x.Id,
  114. Name = x.TeamName
  115. }).ToListAsync();
  116. return new JsonView
  117. {
  118. Code = StatusCodes.Status200OK,
  119. Msg = "获取成功",
  120. Count = noPageList.Count,
  121. Data = noPageList
  122. };
  123. }
  124. RefAsync<int> total = 0;
  125. var pageList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  126. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  127. .WhereIF(!string.IsNullOrEmpty(name), x => x.TeamName.Contains(name))
  128. .OrderByDescending(x => x.CreateTime)
  129. .Select(x => new EnterExitCostQuoteGroupNameView
  130. {
  131. Id = x.Id,
  132. Name = x.TeamName
  133. }).ToPageListAsync(pageIndex, pageSize, total);
  134. return new JsonView
  135. {
  136. Code = StatusCodes.Status200OK,
  137. Msg = "获取成功",
  138. Count = total,
  139. Data = pageList
  140. };
  141. }
  142. /// <summary>
  143. /// 获取团组名称列表
  144. /// </summary>
  145. /// <param name="name"></param>
  146. /// <param name="pageIndex"></param>
  147. /// <param name="pageSize"></param>
  148. /// <returns></returns>
  149. public async Task<JsonView> InfoAsync(EnterExitCostQuoteInfoDto dto)
  150. {
  151. if (dto.Id < 1)
  152. {
  153. return new JsonView
  154. {
  155. Code = StatusCodes.Status400BadRequest,
  156. Msg = MsgTips.Id
  157. };
  158. }
  159. var quoteInfo = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>()
  160. .Where(x => x.IsDel == 0 && x.Id == x.Id)
  161. .FirstAsync();
  162. if (quoteInfo == null)
  163. {
  164. return new JsonView
  165. {
  166. Code = StatusCodes.Status400BadRequest,
  167. Msg = $"未找到Id为{dto.Id}的数据"
  168. };
  169. }
  170. //(List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostData.CurrencyRemark)
  171. return new JsonView
  172. {
  173. Code = StatusCodes.Status200OK,
  174. Msg = "获取成功",
  175. // Data = pageList
  176. };
  177. }
  178. }
  179. }