AppFlowController.Actions.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. using System;
  2. using System.Threading.Tasks;
  3. using Datory;
  4. using GxPress.Common.Tools;
  5. using GxPress.EnumConst;
  6. using GxPress.Result;
  7. using Microsoft.AspNetCore.Authorization;
  8. using Microsoft.AspNetCore.Mvc;
  9. namespace GxPress.Api.AppControllers
  10. {
  11. public partial class AppFlowController
  12. {
  13. /// <summary>
  14. /// 动作 - 审批
  15. /// </summary>
  16. /// <param name="request">审批意见</param>
  17. /// <returns></returns>
  18. [HttpPost("action/check")]
  19. [AllowAnonymous]
  20. public async Task<DefaultResult> ActionsCheck([FromBody] CheckRequest request)
  21. {
  22. if (!string.IsNullOrEmpty(request.Message) && request.Message.Length > 500)
  23. {
  24. throw new Exception("审批意见不能操作500字,请重新输入");
  25. }
  26. await _flowService.CheckAsync(request.TodoId, request.IsChecked, request.Message);
  27. return new DefaultResult
  28. {
  29. Value = true
  30. };
  31. }
  32. /// <summary>
  33. /// 动作 - 下载
  34. /// </summary>
  35. /// <param name="request">请求</param>
  36. /// <returns></returns>
  37. [HttpPost("action/download")]
  38. [AllowAnonymous]
  39. public async Task<DownloadResult> ActionsDownload([FromBody] ActionRequest request)
  40. {
  41. // var url = await _flowService.DownloadAsync(request.FlowId);
  42. // url = Request.Scheme + "://" + Request.Host.Host +
  43. // (Request.Host.Port > 0 ? $":{Request.Host.Port}" : string.Empty) +
  44. // "/" + url;
  45. var url = await docService.MakeDoc(request.FlowId, _loginContext.AccountId);
  46. return new DownloadResult
  47. {
  48. DownloadUrl = StringUtils.AddDomain(url),
  49. PreviewUrl = StringUtils.GetPreviewDocUrl(url)
  50. };
  51. }
  52. /// <summary>
  53. /// 动作 - 催办
  54. /// </summary>
  55. /// <param name="request">请求</param>
  56. /// <returns></returns>
  57. [HttpPost("action/remind")]
  58. [AllowAnonymous]
  59. public async Task<DefaultResult> ActionsRemind([FromBody] ActionRequest request)
  60. {
  61. return new DefaultResult
  62. {
  63. Value = await _flowService.RemindAsync(request.FlowId, _loginContext.AccountId)
  64. };
  65. }
  66. /// <summary>
  67. /// 动作 - 上会
  68. /// </summary>
  69. /// <param name="request">请求</param>
  70. /// <returns></returns>
  71. [HttpPost("action/meeting")]
  72. [AllowAnonymous]
  73. public async Task<DefaultResult> ActionsMeeting([FromBody] ActionRequest request)
  74. {
  75. // var todoId = request.FlowId;
  76. // var flowTodo = await _flowTodoRepository.GetAsync(request.FlowId);
  77. // if (flowTodo != null)
  78. // request.FlowId = flowTodo.FlowId;
  79. //await _flowRepository.UpdateStateAsync(request.FlowId, nameof(FlowState.Meeting));
  80. //修改当前用户的审核状态
  81. await _flowTodoRepository.UpdateAsync(Q.Set(nameof(Entity.WorkFlow.FlowTodo.IsDone), true).Set(nameof(Entity.WorkFlow.FlowTodo.IsChecked), false).Set(nameof(Entity.WorkFlow.FlowTodo.DoneType), 1).Where(nameof(Entity.WorkFlow.FlowTodo.Id),request.FlowId));
  82. return new DefaultResult
  83. {
  84. Value = true
  85. };
  86. }
  87. /// <summary>
  88. /// 动作 - 撤销上会
  89. /// </summary>
  90. /// <param name="request">请求</param>
  91. /// <returns></returns>
  92. [HttpPost("action/cancelMeeting")]
  93. [AllowAnonymous]
  94. public async Task<DefaultResult> ActionsCancelMeeting([FromBody] ActionRequest request)
  95. {
  96. //await _flowRepository.UpdateStateAsync(request.FlowId, nameof(FlowState.Checking));
  97. //修改当前操作人为带审核
  98. await _flowTodoRepository.UpdateAsync(Q.Where(nameof(Entity.WorkFlow.FlowTodo.Id), request.FlowId).Set(nameof(Entity.WorkFlow.FlowTodo.IsDone), false).Set(nameof(Entity.WorkFlow.FlowTodo.IsChecked), false).Set(nameof(Entity.WorkFlow.FlowTodo.DoneType), 0).Set(nameof(Entity.WorkFlow.FlowTodo.IsOperate), true));
  99. return new DefaultResult
  100. {
  101. Value = true
  102. };
  103. }
  104. /// <summary>
  105. /// 动作 - 转审
  106. /// </summary>
  107. /// <param name="request">请求</param>
  108. /// <returns></returns>
  109. [HttpPost("action/transferCheck")]
  110. [AllowAnonymous]
  111. public async Task<DefaultResult> ActionsTransferCheck([FromBody] ActionTransferCheckRequest request)
  112. {
  113. await _flowService.TransferCheckAsync(request.TodoId, request.TransferUserIds, request.Message, request.FileIds);
  114. // //修改当前用户的审核状态
  115. // await _flowTodoRepository.UpdateAsync(Q.Set(nameof(Entity.WorkFlow.FlowTodo.IsDone), true).Where(nameof(Entity.WorkFlow.FlowTodo.Id), request.TodoId).Where(nameof(Entity.WorkFlow.FlowTodo.UserId), _loginContext.AccountId));
  116. return new DefaultResult
  117. {
  118. Value = true
  119. };
  120. }
  121. /// <summary>
  122. /// 动作 - 重新提交
  123. /// </summary>
  124. /// <param name="request">请求</param>
  125. /// <returns></returns>
  126. [HttpPost("action/reAdd")]
  127. [AllowAnonymous]
  128. public async Task<DefaultResult> ActionsReAddCheck([FromBody] ActionRequest request)
  129. {
  130. await _flowService.ReAddAsync(request.FlowId);
  131. return new DefaultResult
  132. {
  133. Value = true
  134. };
  135. }
  136. /// <summary>
  137. /// 上会待定
  138. /// </summary>
  139. /// <param name="request"></param>
  140. /// <returns></returns>
  141. [HttpPost("action/wait")]
  142. public async Task<DefaultResult> ActionsWait(ActionRequest request)
  143. {
  144. return new DefaultResult
  145. {
  146. Value = await _flowService.ActionsWait(request.FlowId, _loginContext.AccountId)
  147. };
  148. }
  149. }
  150. }