using System.Net; using DS.Module.Core; using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity.TaskInteraction; using DS.WMS.Core.Op.Interface.TaskInteraction; using Microsoft.AspNetCore.Mvc; namespace DS.WMS.OpApi.Controllers { /// /// 海运出口任务API /// public class SeaExportTaskController : ApiController { readonly ISeaExportTaskService taskService; /// /// 构造函数 /// /// public SeaExportTaskController(ISeaExportTaskService service) { taskService = service; } /// /// 获取业务的任务信息 /// /// 业务ID /// 业务类型 /// 任务类型名称(支持多个,可选参数) /// /// /GetTasks?taskTypes=任务类型1&taskTypes=任务类型2 [HttpGet, Route("GetTasks")] public async Task>> GetTasksAsync( [FromQuery] long businessId, [FromQuery] BusinessType businessType, [FromQuery] params string[] taskTypes) { TaskBaseTypeEnum[]? types = null; if (taskTypes?.Length > 0) types = taskTypes.Select(Enum.Parse).ToArray(); return await taskService.GetTasks(businessId, businessType, types); } /// /// 获取指定业务的任务日志 /// /// /// 业务ID /// 业务类型 /// [HttpGet, Route("GetLogs")] public async Task>> GetLogsAsync([FromServices] ITaskLogService logService, [FromQuery] long businessId, [FromQuery] BusinessType businessType) { return await logService.ReadLogAsync(businessId, businessType); } /// /// 创建关联任务 /// /// /// [HttpPost, Route("CreateTask")] public async Task CreateTaskAsync([FromBody] TaskCreationRequest request) { if (!ModelState.IsValid) return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest); return await taskService.CreateTaskAsync(request); } /// /// 设置任务状态 /// /// /// [HttpPost, Route("SetTaskStatus")] public async Task> SetTaskStatusAsync([FromBody] TaskUpdateRequest request) { if (!ModelState.IsValid) return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest); return await taskService.SetTaskStatusAsync(request); } /// /// 手动发起任务审核(用于二次审核) /// /// /// [HttpPost, Route("SubmitAudit")] public async Task SubmitAuditAsync(TaskRequest request) { return await taskService.SubmitAuditAsync(request); } /// /// 任务审核 /// /// /// [HttpPost, Route("Audit")] public async virtual Task AuditAsync([FromBody] TaskAuditRequest request) { return await taskService.AuditAsync(request); } /// /// 审批完成回调更新(无需客户端手动调用) /// /// 回调信息 /// [HttpPost, Route("UpdateBusiness")] public async Task UpdateBusinessAsync([FromBody] FlowCallback callback) { await taskService.UpdateBusinessAsync(callback); return StatusCode((int)HttpStatusCode.NoContent); } /// /// 通知审批执行人变更(无需客户端手动调用) /// /// 回调信息 /// [HttpPost, Route("MarkerChanged")] public virtual async Task MarkerChangedAsync([FromBody] MarkerChangedCallback callback) { await taskService.MarkerChangedAsync(callback); return StatusCode((int)HttpStatusCode.NoContent); } } }