BusinessController.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. using Microsoft.AspNetCore.Mvc;
  2. using NPOI.SS.Formula.Functions;
  3. using OASystem.API.OAMethodLib.ALiYun;
  4. using OASystem.API.OAMethodLib.ExcelOutput;
  5. using OASystem.Domain.Common;
  6. using OASystem.Domain.Dtos.Business;
  7. using OASystem.Domain.Dtos.Groups;
  8. using OASystem.Domain.Entities.Business;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.Entities.Resource;
  11. using OASystem.Domain.ViewModels.Business;
  12. using OASystem.Domain.ViewModels.Groups;
  13. using OASystem.Infrastructure.Repositories.Business;
  14. using OASystem.Infrastructure.Repositories.Groups;
  15. using OASystem.Infrastructure.Repositories.System;
  16. using Org.BouncyCastle.Asn1.Mozilla;
  17. namespace OASystem.API.Controllers
  18. {
  19. /// <summary>
  20. /// 通用业务操作
  21. /// </summary>
  22. [Route("api/[controller]/[action]")]
  23. public class BusinessController : ControllerBase
  24. {
  25. private readonly IMapper _mapper;
  26. private readonly CommonBusRepository _busRep;
  27. private readonly SetDataRepository _setDataRep;
  28. private readonly DelegationInfoRepository _groupRep;
  29. public BusinessController(IMapper mapper, CommonBusRepository busRep, SetDataRepository setDataRep, DelegationInfoRepository groupRep)
  30. {
  31. _mapper = mapper;
  32. _busRep = busRep;
  33. _setDataRep = setDataRep;
  34. _groupRep = groupRep;
  35. }
  36. #region 团组信息 团组详情
  37. /// <summary>
  38. /// 团组信息 团组详情
  39. /// </summary>
  40. /// <param name="dto">团组info请求dto</param>
  41. /// <returns></returns>
  42. [HttpPost]
  43. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  44. public async Task<IActionResult> PostShareGroupInfo(ShareGroupInfoDto dto)
  45. {
  46. var groupData = await _groupRep.PostShareGroupInfo(dto);
  47. if (groupData.Code != 0)
  48. {
  49. return Ok(JsonView(false, groupData.Msg));
  50. }
  51. return Ok(JsonView(groupData.Data));
  52. }
  53. /// <summary>
  54. /// 团组信息 团组名称 List
  55. /// </summary>
  56. /// <param name="dto"></param>
  57. /// <returns></returns>
  58. [HttpPost]
  59. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  60. public async Task<IActionResult> GetGroupNameList(GroupNameDto dto)
  61. {
  62. var groupData = await _groupRep.GetGroupNameList(dto);
  63. if (groupData.Code != 0)
  64. {
  65. return Ok(JsonView(false, groupData.Msg));
  66. }
  67. return Ok(JsonView(groupData.Data, groupData.Data.Count));
  68. }
  69. #endregion
  70. #region 币种 List
  71. /// <summary>
  72. /// 币种 List
  73. /// </summary>
  74. /// <param name="dto"></param>
  75. /// <returns></returns>
  76. [HttpGet,HttpPost]
  77. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  78. public async Task<IActionResult> PostCurrencyList()
  79. {
  80. try
  81. {
  82. Result setData = await _setDataRep.GetSetDataBySTId(_setDataRep, 66); //币种类型
  83. if (setData.Code == 0)
  84. {
  85. return Ok(JsonView(true, "查询成功", setData.Data));
  86. }
  87. else
  88. {
  89. return Ok(JsonView(false, setData.Msg));
  90. }
  91. }
  92. catch (Exception)
  93. {
  94. return Ok(JsonView(false, "程序错误!"));
  95. throw;
  96. }
  97. }
  98. /// <summary>
  99. /// 根据团组Id币种Id及类型Id查询团组汇率
  100. /// </summary>
  101. /// <param name="dto"></param>
  102. /// <returns></returns>
  103. [HttpGet, HttpPost]
  104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  105. public async Task<IActionResult> PostCurrencyByDiid(int DiId,int CId,int CurrencyId)
  106. {
  107. try
  108. {
  109. Result setData = await _setDataRep.PostCurrencyByDiid( DiId, CId, CurrencyId); //币种类型
  110. if (setData.Code == 0)
  111. {
  112. return Ok(JsonView(true, "查询成功", setData.Data));
  113. }
  114. else
  115. {
  116. return Ok(JsonView(false, setData.Msg));
  117. }
  118. }
  119. catch (Exception)
  120. {
  121. return Ok(JsonView(false, "程序错误!"));
  122. throw;
  123. }
  124. }
  125. #endregion
  126. #region 会务物料单
  127. /// <summary>
  128. /// 获取会务活动列表
  129. /// </summary>
  130. /// <param name="paras"></param>
  131. /// <returns></returns>
  132. [HttpPost]
  133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  134. public async Task<IActionResult> PostConferenceList()
  135. {
  136. List<Grp_DelegationInfo> listSource = _busRep.Query<Grp_DelegationInfo>(s => s.TeamDid == 691 && s.IsDel == 0).ToList();
  137. List<GroupNameView> viewList = new List<GroupNameView>();
  138. foreach (var group in listSource)
  139. {
  140. GroupNameView _view = new GroupNameView();
  141. _view.Id = group.Id;
  142. _view.GroupName = group.TeamName;
  143. }
  144. return Ok(JsonView(viewList));
  145. }
  146. /// <summary>
  147. /// 获取会务的采购物品计划清单
  148. /// </summary>
  149. /// <param name="ConfId">会务活动Id</param>
  150. /// <returns></returns>
  151. [HttpPost]
  152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  153. public async Task<IActionResult> PostConfItemList(int ConfId)
  154. {
  155. Bus_ConfItemListView view = new Bus_ConfItemListView();
  156. Bus_ConfItemListInfo _confListInfo = await _busRep.Query<Bus_ConfItemListInfo>(s => s.Diid == ConfId).FirstAsync();
  157. if (_confListInfo != null)
  158. {
  159. view.TotalCost = _confListInfo.TotalCost;
  160. string sqlItem = string.Format(@" Select c.Id,c.ItemId,d.ItemName,c.[Count],c.CurrCost,c.OpRemark
  161. From Bus_ConfItem as c With(Nolock)
  162. Inner Join Res_ItemDetail as d with(Nolock) On c.ItemId=d.Id
  163. Where c.ConfListId = {0}", ConfId);
  164. List<Bus_ConfItemView> confItemList = await _busRep._sqlSugar.SqlQueryable<Bus_ConfItemView>(sqlItem).ToListAsync();
  165. view.ItemList = new List<Bus_ConfItemView>(confItemList);
  166. }
  167. else
  168. {
  169. view.ItemList = new List<Bus_ConfItemView>();
  170. view.TotalCost = 0;
  171. }
  172. return Ok(JsonView(view));
  173. }
  174. /// <summary>
  175. /// 获取会务可采购的物料集合
  176. /// </summary>
  177. /// <returns></returns>
  178. [HttpPost]
  179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  180. public async Task<IActionResult> PostOptionalItemList()
  181. {
  182. List<OptionalBusRangeView> result = await _busRep.GetViewList_OptionalItem();
  183. return Ok(JsonView(result));
  184. }
  185. /// <summary>
  186. /// 编辑物料采购清单
  187. /// </summary>
  188. /// <returns></returns>
  189. [HttpPost]
  190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  191. public async Task<IActionResult> PostEditOptionalItemList(JsonDtoBase jsonDto)
  192. {
  193. if (string.IsNullOrEmpty(jsonDto.Paras))
  194. {
  195. return Ok(JsonView(false, "参数为空"));
  196. }
  197. Edit_OptionalItemListDto _dto = JsonConvert.DeserializeObject<Edit_OptionalItemListDto>(jsonDto.Paras);
  198. //Edit_OptionalItemListDto _dto = System.Text.Json.JsonSerializer.Deserialize<Edit_OptionalItemListDto>(jsonDto.Paras);
  199. if (_dto.DiId < 1)
  200. {
  201. return Ok(JsonView(false, "团组Id为空"));
  202. }
  203. if (_dto.ConfItemListId < 1)
  204. {
  205. //新增
  206. int rstInsert = await _busRep.Insert_ConfItemList(_dto);
  207. return Ok(JsonView(rstInsert == 0));
  208. }
  209. else
  210. {
  211. //修改
  212. int rstUpdate = await _busRep.Edit_ConfItemList(_dto);
  213. return Ok(JsonView(rstUpdate == 0));
  214. }
  215. return Ok(JsonView(false));
  216. }
  217. /// <summary>
  218. /// 获取会务采购物料清单Excel
  219. /// </summary>
  220. /// <returns></returns>
  221. [HttpPost]
  222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  223. public async Task<IActionResult> Excel_ConfItemList(JsonDtoBase jsonDto)
  224. {
  225. if (string.IsNullOrEmpty(jsonDto.Paras))
  226. {
  227. return Ok(JsonView(false, "参数为空"));
  228. }
  229. dynamic confList = JsonConvert.DeserializeObject<dynamic>(jsonDto.Paras);
  230. int confListId = confList.ConfListId;
  231. Bus_ConfItemListInfo _entityConfList = await _busRep.Query<Bus_ConfItemListInfo>(s => s.Id == confListId).FirstAsync();
  232. if (_entityConfList != null)
  233. {
  234. string result = new Excel_BusConfItemList().Excel(_entityConfList);
  235. }
  236. else
  237. {
  238. return Ok(JsonView(false, "请先保存数据"));
  239. }
  240. return Ok(JsonView(false));
  241. }
  242. #endregion
  243. #region 阿里云短信测试
  244. /// <summary>
  245. /// 编辑物料采购清单
  246. /// </summary>
  247. /// <returns></returns>
  248. [HttpPost]
  249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  250. public async Task<IActionResult> AliMessageTest(string mobile)
  251. {
  252. string add2dayZH = DateTime.Now.AddDays(2).ToString("yyyy年MM月dd日");
  253. string templateParam = JsonConvert.SerializeObject(new { teams = "测试团组", date = add2dayZH });
  254. AliMessagePost.PostMessage(mobile, "泛美国际团组", "SMS_461575447", templateParam);
  255. return Ok(JsonView(true));
  256. }
  257. #endregion
  258. }
  259. }