AppFlowController.Actions.cs 6.0 KB

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