AdoS8ExceptionsController.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. [FromBody] AdoS8CommentDto? body = null)
  70. {
  71. try
  72. {
  73. var e = await _taskFlowSvc.StartProgressAsync(id, tenantId, factoryId, 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}/submit-verification")]
  101. public async Task<IActionResult> SubmitVerificationAsync(long id,
  102. [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  103. [FromBody] AdoS8SubmitVerificationDto? body = null)
  104. {
  105. try
  106. {
  107. var e = await _taskFlowSvc.SubmitVerificationAsync(
  108. id, tenantId, factoryId, body?.VerifierId ?? 0, body?.Remark);
  109. return Ok(new { id = e.Id, status = e.Status, verifierId = e.VerifierId });
  110. }
  111. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  112. }
  113. [HttpPost("{id:long}/approve-verification")]
  114. public async Task<IActionResult> ApproveVerificationAsync(long id,
  115. [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  116. [FromBody] AdoS8ApproveVerificationDto? body = null)
  117. {
  118. try
  119. {
  120. var e = await _taskFlowSvc.ApproveVerificationAsync(id, tenantId, factoryId, body?.Remark);
  121. return Ok(new { id = e.Id, status = e.Status });
  122. }
  123. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  124. }
  125. [HttpPost("{id:long}/reject-verification")]
  126. public async Task<IActionResult> RejectVerificationAsync(long id,
  127. [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  128. [FromBody] AdoS8RejectVerificationDto? body = null)
  129. {
  130. try
  131. {
  132. var e = await _taskFlowSvc.RejectVerificationAsync(id, tenantId, factoryId, body?.Remark ?? string.Empty);
  133. return Ok(new { id = e.Id, status = e.Status });
  134. }
  135. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  136. }
  137. [HttpPost("{id:long}/comment")]
  138. public async Task<IActionResult> CommentAsync(long id, [FromBody] AdoS8CommentDto? body = null)
  139. {
  140. try
  141. {
  142. await _taskFlowSvc.CommentAsync(id, body?.Remark);
  143. return Ok(new { id });
  144. }
  145. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  146. }
  147. }
  148. public class AdoS8ClaimBody
  149. {
  150. public long AssigneeId { get; set; }
  151. public string? Remark { get; set; }
  152. }