| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using Admin.NET.Plugin.AiDOP.Dto.S8;
- using Admin.NET.Plugin.AiDOP.Service.S8;
- namespace Admin.NET.Plugin.AiDOP.Controllers.S8;
- [ApiController]
- [Route("api/aidop/s8/exceptions")]
- [NonUnify]
- public class AdoS8ExceptionsController : ControllerBase
- {
- private readonly S8ExceptionService _exceptionSvc;
- private readonly S8TaskFlowService _taskFlowSvc;
- private readonly S8DecisionService _decisionSvc;
- public AdoS8ExceptionsController(
- S8ExceptionService exceptionSvc,
- S8TaskFlowService taskFlowSvc,
- S8DecisionService decisionSvc)
- {
- _exceptionSvc = exceptionSvc;
- _taskFlowSvc = taskFlowSvc;
- _decisionSvc = decisionSvc;
- }
- [HttpGet]
- public async Task<IActionResult> GetPagedAsync([FromQuery] AdoS8ExceptionQueryDto q)
- {
- var (total, list) = await _exceptionSvc.GetPagedAsync(q);
- return Ok(new { total, page = q.Page, pageSize = q.PageSize, list });
- }
- [HttpGet("filter-options")]
- public async Task<IActionResult> GetFilterOptionsAsync([FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1) =>
- Ok(await _exceptionSvc.GetFilterOptionsAsync(tenantId, factoryId));
- [HttpGet("{id:long}")]
- public async Task<IActionResult> GetDetailAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1)
- {
- var detail = await _exceptionSvc.GetDetailAsync(id, tenantId, factoryId);
- return detail == null ? NotFound() : Ok(detail);
- }
- [HttpGet("{id:long}/timeline")]
- public async Task<IActionResult> GetTimelineAsync(long id) =>
- Ok(await _decisionSvc.GetTimelineAsync(id));
- [HttpGet("{id:long}/decisions")]
- public async Task<IActionResult> GetDecisionsAsync(long id) =>
- Ok(await _decisionSvc.GetDecisionsAsync(id));
- [HttpGet("{id:long}/evidences")]
- public async Task<IActionResult> GetEvidencesAsync(long id) =>
- Ok(await _decisionSvc.GetEvidencesAsync(id));
- [HttpPost("{id:long}/claim")]
- public async Task<IActionResult> ClaimAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
- [FromBody] AdoS8ClaimBody? body = null)
- {
- try
- {
- var e = await _taskFlowSvc.ClaimAsync(id, tenantId, factoryId, body?.AssigneeId ?? 0, body?.Remark);
- return Ok(new { id = e.Id, status = e.Status });
- }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- [HttpPost("{id:long}/transfer")]
- public async Task<IActionResult> TransferAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
- [FromBody] AdoS8TransferDto? body = null)
- {
- try
- {
- var e = await _taskFlowSvc.TransferAsync(id, tenantId, factoryId, body?.AssigneeId ?? 0, body?.Remark);
- return Ok(new { id = e.Id, assigneeId = e.AssigneeId });
- }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- [HttpPost("{id:long}/upgrade")]
- public async Task<IActionResult> UpgradeAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
- [FromBody] AdoS8CommentDto? body = null)
- {
- try
- {
- var e = await _taskFlowSvc.UpgradeAsync(id, tenantId, factoryId, body?.Remark);
- return Ok(new { id = e.Id, status = e.Status });
- }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- [HttpPost("{id:long}/reject")]
- public async Task<IActionResult> RejectAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
- [FromBody] AdoS8CommentDto? body = null)
- {
- try
- {
- var e = await _taskFlowSvc.RejectAsync(id, tenantId, factoryId, body?.Remark);
- return Ok(new { id = e.Id, status = e.Status });
- }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- [HttpPost("{id:long}/close")]
- public async Task<IActionResult> CloseAsync(long id, [FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1,
- [FromBody] AdoS8CommentDto? body = null)
- {
- try
- {
- var e = await _taskFlowSvc.CloseAsync(id, tenantId, factoryId, body?.Remark);
- return Ok(new { id = e.Id, status = e.Status });
- }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- [HttpPost("{id:long}/comment")]
- public async Task<IActionResult> CommentAsync(long id, [FromBody] AdoS8CommentDto? body = null)
- {
- try
- {
- await _taskFlowSvc.CommentAsync(id, body?.Remark);
- return Ok(new { id });
- }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- }
- public class AdoS8ClaimBody
- {
- public long AssigneeId { get; set; }
- public string? Remark { get; set; }
- }
|