AdoS8ExceptionsController.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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}/upgrade")]
  68. public async Task<IActionResult> UpgradeAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  69. [FromBody] AdoS8CommentDto? body = null)
  70. {
  71. try
  72. {
  73. var e = await _taskFlowSvc.UpgradeAsync(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}/reject")]
  79. public async Task<IActionResult> RejectAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  80. [FromBody] AdoS8CommentDto? body = null)
  81. {
  82. try
  83. {
  84. var e = await _taskFlowSvc.RejectAsync(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}/close")]
  90. public async Task<IActionResult> CloseAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
  91. [FromBody] AdoS8CommentDto? body = null)
  92. {
  93. try
  94. {
  95. var e = await _taskFlowSvc.CloseAsync(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}/comment")]
  101. public async Task<IActionResult> CommentAsync(long id, [FromBody] AdoS8CommentDto? body = null)
  102. {
  103. try
  104. {
  105. await _taskFlowSvc.CommentAsync(id, body?.Remark);
  106. return Ok(new { id });
  107. }
  108. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  109. }
  110. }
  111. public class AdoS8ClaimBody
  112. {
  113. public long AssigneeId { get; set; }
  114. public string? Remark { get; set; }
  115. }