AdoS8ExceptionsController.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using Admin.NET.Plugin.AiDOP.Dto.S8;
  2. using Admin.NET.Plugin.AiDOP.Service.S8;
  3. namespace Admin.NET.Plugin.AiDOP.Controllers.S8;
  4. [ApiController]
  5. [Route("api/aidop/s8/exceptions")]
  6. [NonUnify]
  7. public class AdoS8ExceptionsController : ControllerBase
  8. {
  9. private readonly S8ExceptionService _exceptionSvc;
  10. private readonly S8TaskFlowService _taskFlowSvc;
  11. private readonly S8DecisionService _decisionSvc;
  12. public AdoS8ExceptionsController(
  13. S8ExceptionService exceptionSvc,
  14. S8TaskFlowService taskFlowSvc,
  15. S8DecisionService decisionSvc)
  16. {
  17. _exceptionSvc = exceptionSvc;
  18. _taskFlowSvc = taskFlowSvc;
  19. _decisionSvc = decisionSvc;
  20. }
  21. [HttpGet]
  22. public async Task<IActionResult> GetPagedAsync([FromQuery] AdoS8ExceptionQueryDto q)
  23. {
  24. var (total, list) = await _exceptionSvc.GetPagedAsync(q);
  25. return Ok(new { total, page = q.Page, pageSize = q.PageSize, list });
  26. }
  27. [HttpGet("filter-options")]
  28. public async Task<IActionResult> GetFilterOptionsAsync([FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1) =>
  29. Ok(await _exceptionSvc.GetFilterOptionsAsync(tenantId, factoryId));
  30. [HttpGet("{id:long}")]
  31. public async Task<IActionResult> GetDetailAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1)
  32. {
  33. var detail = await _exceptionSvc.GetDetailAsync(id, tenantId, factoryId);
  34. return detail == null ? NotFound() : Ok(detail);
  35. }
  36. [HttpGet("{id:long}/timeline")]
  37. public async Task<IActionResult> GetTimelineAsync(long id) =>
  38. Ok(await _decisionSvc.GetTimelineAsync(id));
  39. [HttpGet("{id:long}/decisions")]
  40. public async Task<IActionResult> GetDecisionsAsync(long id) =>
  41. Ok(await _decisionSvc.GetDecisionsAsync(id));
  42. [HttpGet("{id:long}/evidences")]
  43. public async Task<IActionResult> GetEvidencesAsync(long id) =>
  44. Ok(await _decisionSvc.GetEvidencesAsync(id));
  45. [HttpPost("{id:long}/claim")]
  46. public async Task<IActionResult> ClaimAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  47. [FromBody] AdoS8ClaimBody? body = null)
  48. {
  49. try
  50. {
  51. var e = await _taskFlowSvc.ClaimAsync(id, tenantId, factoryId, body?.AssigneeId ?? 0, body?.Remark);
  52. return Ok(new { id = e.Id, status = e.Status });
  53. }
  54. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  55. }
  56. [HttpPost("{id:long}/transfer")]
  57. public async Task<IActionResult> TransferAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  58. [FromBody] AdoS8TransferDto? body = null)
  59. {
  60. try
  61. {
  62. var e = await _taskFlowSvc.TransferAsync(id, tenantId, factoryId, body?.AssigneeId ?? 0, body?.Remark);
  63. return Ok(new { id = e.Id, assigneeId = e.AssigneeId });
  64. }
  65. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  66. }
  67. [HttpPost("{id:long}/start-progress")]
  68. public async Task<IActionResult> StartProgressAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  69. [FromQuery] long currentUserId = 0, [FromBody] AdoS8CommentDto? body = null)
  70. {
  71. try
  72. {
  73. var e = await _taskFlowSvc.StartProgressAsync(id, tenantId, factoryId, currentUserId, body?.Remark);
  74. return Ok(new { id = e.Id, status = e.Status });
  75. }
  76. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  77. }
  78. [HttpPost("{id:long}/upgrade")]
  79. public async Task<IActionResult> UpgradeAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  80. [FromBody] AdoS8CommentDto? body = null)
  81. {
  82. try
  83. {
  84. var e = await _taskFlowSvc.UpgradeAsync(id, tenantId, factoryId, body?.Remark);
  85. return Ok(new { id = e.Id, status = e.Status });
  86. }
  87. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  88. }
  89. [HttpPost("{id:long}/reject")]
  90. public async Task<IActionResult> RejectAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  91. [FromBody] AdoS8CommentDto? body = null)
  92. {
  93. try
  94. {
  95. var e = await _taskFlowSvc.RejectAsync(id, tenantId, factoryId, body?.Remark);
  96. return Ok(new { id = e.Id, status = e.Status });
  97. }
  98. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  99. }
  100. [HttpPost("{id:long}/close")]
  101. public async Task<IActionResult> CloseAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  102. [FromBody] AdoS8CommentDto? body = null)
  103. {
  104. try
  105. {
  106. var e = await _taskFlowSvc.CloseAsync(id, tenantId, factoryId, body?.Remark);
  107. return Ok(new { id = e.Id, status = e.Status });
  108. }
  109. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  110. }
  111. [HttpPost("{id:long}/submit-verification")]
  112. public async Task<IActionResult> SubmitVerificationAsync(long id,
  113. [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  114. [FromQuery] long currentUserId = 0,
  115. [FromBody] AdoS8SubmitVerificationDto? body = null)
  116. {
  117. try
  118. {
  119. var e = await _taskFlowSvc.SubmitVerificationAsync(
  120. id, tenantId, factoryId, currentUserId, body?.VerifierId ?? 0, body?.Remark);
  121. return Ok(new { id = e.Id, status = e.Status, verifierId = e.VerifierId });
  122. }
  123. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  124. }
  125. [HttpPost("{id:long}/approve-verification")]
  126. public async Task<IActionResult> ApproveVerificationAsync(long id,
  127. [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  128. [FromQuery] long currentUserId = 0,
  129. [FromBody] AdoS8ApproveVerificationDto? body = null)
  130. {
  131. try
  132. {
  133. var e = await _taskFlowSvc.ApproveVerificationAsync(id, tenantId, factoryId, currentUserId, body?.Remark);
  134. return Ok(new { id = e.Id, status = e.Status });
  135. }
  136. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  137. }
  138. [HttpPost("{id:long}/reject-verification")]
  139. public async Task<IActionResult> RejectVerificationAsync(long id,
  140. [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  141. [FromQuery] long currentUserId = 0,
  142. [FromBody] AdoS8RejectVerificationDto? body = null)
  143. {
  144. try
  145. {
  146. var e = await _taskFlowSvc.RejectVerificationAsync(id, tenantId, factoryId, currentUserId, body?.Remark ?? string.Empty);
  147. return Ok(new { id = e.Id, status = e.Status });
  148. }
  149. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  150. }
  151. [HttpPost("{id:long}/comment")]
  152. public async Task<IActionResult> CommentAsync(long id, [FromBody] AdoS8CommentDto? body = null)
  153. {
  154. try
  155. {
  156. await _taskFlowSvc.CommentAsync(id, body?.Remark);
  157. return Ok(new { id });
  158. }
  159. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  160. }
  161. }
  162. public class AdoS8ClaimBody
  163. {
  164. public long AssigneeId { get; set; }
  165. public string? Remark { get; set; }
  166. }