GroupsController.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using Microsoft.AspNetCore.Mvc;
  2. using Newtonsoft.Json.Serialization;
  3. using OASystem.API.OAMethodLibs;
  4. using OASystem.Domain.Dtos.Groups;
  5. using OASystem.Domain.Entities.Groups;
  6. using OASystem.Domain.ViewModels.Groups;
  7. using OASystem.Infrastructure.Repositories.Groups;
  8. namespace OASystem.API.Controllers
  9. {
  10. /// <summary>
  11. /// 团组相关
  12. /// </summary>
  13. //[Authorize]
  14. [Route("api/[controller]/[action]")]
  15. public class GroupsController : ControllerBase
  16. {
  17. private readonly GrpScheduleRepository _grpScheduleRep;
  18. private readonly IMapper _mapper;
  19. private readonly DelegationInfoRepository _groupRepository;
  20. public GroupsController(IMapper mapper, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository)
  21. {
  22. _mapper = mapper;
  23. _grpScheduleRep = grpScheduleRep;
  24. _groupRepository = groupRepository;
  25. }
  26. #region 流程管控
  27. /// <summary>
  28. /// 获取团组流程管控信息
  29. /// </summary>
  30. /// <param name="paras">参数Json字符串</param>
  31. /// <returns></returns>
  32. [HttpPost]
  33. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  34. public async Task<IActionResult> PostSearchGrpSchedule(string paras)
  35. {
  36. if (string.IsNullOrEmpty(paras))
  37. {
  38. return Ok(JsonView(false, "参数为空"));
  39. }
  40. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(paras);
  41. if (_ScheduleDto != null)
  42. {
  43. if (_ScheduleDto.SearchType == 2)//获取列表
  44. {
  45. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  46. return Ok(JsonView(_grpScheduleViewList));
  47. }
  48. else//获取对象
  49. {
  50. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  51. if (_grpScheduleView != null)
  52. {
  53. return Ok(JsonView(_grpScheduleView));
  54. }
  55. }
  56. }
  57. else
  58. {
  59. return Ok(JsonView(false, "参数反序列化失败"));
  60. }
  61. return Ok(JsonView(false, "暂无数据!"));
  62. }
  63. /// <summary>
  64. /// 修改团组流程管控详细表数据
  65. /// </summary>
  66. /// <param name="paras"></param>
  67. /// <returns></returns>
  68. [HttpPost]
  69. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  70. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  71. {
  72. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  73. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  74. .Where(s => s.Id == dto.Id)
  75. .UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  76. .ExecuteCommandAsync();
  77. if (result > 0)
  78. {
  79. return Ok(JsonView(true, "保存成功!"));
  80. }
  81. return Ok(JsonView(false, "保存失败!"));
  82. }
  83. /// <summary>
  84. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  85. /// </summary>
  86. /// <param name="dto"></param>
  87. /// <returns></returns>
  88. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  89. {
  90. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  91. _detail.IsDel = 1;
  92. _detail.DeleteUserId = dto.Duty;
  93. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  94. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  95. .Where(s => s.Id == dto.Id)
  96. .UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  97. .ExecuteCommandAsync();
  98. if (result > 0)
  99. {
  100. return Ok(JsonView(true, "删除成功!"));
  101. }
  102. return Ok(JsonView(false, "删除失败!"));
  103. }
  104. /// <summary>
  105. /// 增加团组流程管控详细表数据
  106. /// </summary>
  107. /// <param name="dto"></param>
  108. /// <returns></returns>
  109. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  110. {
  111. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  112. if (DateTime.Now < _detail.ExpectBeginDt)
  113. {
  114. _detail.StepStatus = 0;
  115. }
  116. else
  117. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  118. _detail.StepStatus = 1;
  119. }
  120. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  121. if (result > 0)
  122. {
  123. return Ok(JsonView(true, "添加成功!"));
  124. }
  125. return Ok(JsonView(false, "添加失败!"));
  126. }
  127. #endregion
  128. #region 团组基本信息
  129. /// <summary>
  130. /// 接团信息列表
  131. /// </summary>
  132. /// <param name="dto">团组列表请求dto</param>
  133. /// <returns></returns>
  134. [HttpPost]
  135. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  136. {
  137. var groupData = await _groupRepository.GetGroupList(dto);
  138. if (groupData.Code != 0)
  139. {
  140. return Ok(JsonView(false, groupData.Msg));
  141. }
  142. return Ok(JsonView(groupData.Data));
  143. }
  144. /// <summary>
  145. /// 接团信息详情
  146. /// </summary>
  147. /// <param name="dto">团组info请求dto</param>
  148. /// <returns></returns>
  149. [HttpPost]
  150. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  151. {
  152. var groupData = await _groupRepository.GetGroupInfo(dto);
  153. if (groupData.Code != 0)
  154. {
  155. return Ok(JsonView(false, groupData.Msg));
  156. }
  157. return Ok(JsonView(groupData.Data));
  158. }
  159. /// <summary>
  160. /// 接团信息 编辑添加
  161. /// 基础信息数据源
  162. /// </summary>
  163. /// <param name="dto"></param>
  164. /// <returns></returns>
  165. [HttpPost]
  166. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  167. {
  168. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  169. if (groupData.Code != 0)
  170. {
  171. return Ok(JsonView(false, groupData.Msg));
  172. }
  173. return Ok(JsonView(groupData.Data));
  174. }
  175. /// <summary>
  176. /// 接团信息 操作(增改)
  177. /// </summary>
  178. /// <param name="dto"></param>
  179. /// <returns></returns>
  180. [HttpPost]
  181. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  182. {
  183. try
  184. {
  185. var groupData = await _groupRepository.GroupOperation(dto);
  186. if (groupData.Code != 0)
  187. {
  188. return Ok(JsonView(false, groupData.Msg));
  189. }
  190. return Ok(JsonView(true));
  191. }
  192. catch (Exception ex)
  193. {
  194. Logs("[response]" + JsonConvert.SerializeObject(dto));
  195. Logs(ex.Message);
  196. return Ok(JsonView(false, ex.Message));
  197. }
  198. }
  199. /// <summary>
  200. /// 接团信息 操作(删除)
  201. /// </summary>
  202. /// <param name="dto"></param>
  203. /// <returns></returns>
  204. [HttpPost]
  205. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  206. {
  207. try
  208. {
  209. var groupData = await _groupRepository.GroupDel(dto);
  210. if (groupData.Code != 0)
  211. {
  212. return Ok(JsonView(false, groupData.Msg));
  213. }
  214. return Ok(JsonView(true));
  215. }
  216. catch (Exception ex)
  217. {
  218. Logs("[response]" + JsonConvert.SerializeObject(dto));
  219. Logs(ex.Message);
  220. return Ok(JsonView(false, ex.Message));
  221. }
  222. }
  223. /// <summary>
  224. /// 获取团组销售报价号
  225. /// 团组添加时 使用
  226. /// </summary>
  227. /// <returns></returns>
  228. [HttpPost]
  229. public async Task<IActionResult> GetGroupSalesQuoteNo()
  230. {
  231. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  232. if (groupData.Code != 0)
  233. {
  234. return Ok(JsonView(false, groupData.Msg));
  235. }
  236. object salesQuoteNo = new
  237. {
  238. SalesQuoteNo = groupData.Data
  239. };
  240. return Ok(JsonView(salesQuoteNo));
  241. }
  242. /// <summary>
  243. /// 获取团组名称 List
  244. /// </summary>
  245. /// <param name="dto"></param>
  246. /// <returns></returns>
  247. [HttpPost]
  248. public async Task<IActionResult> GetGroupNameList(GroupNameDto dto)
  249. {
  250. var groupData = await _groupRepository.GetGroupNameList(dto);
  251. if (groupData.Code != 0)
  252. {
  253. return Ok(JsonView(false, groupData.Msg));
  254. }
  255. return Ok(JsonView(groupData.Data, groupData.Data.Count));
  256. }
  257. #endregion
  258. #region 团组&签证
  259. #endregion
  260. }
  261. }