You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
5.9 KiB
C#
156 lines
5.9 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 海运出口任务API
|
|
/// </summary>
|
|
public class SeaExportTaskController : ApiController
|
|
{
|
|
readonly ISeaExportTaskService taskService;
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="service"></param>
|
|
public SeaExportTaskController(ISeaExportTaskService service)
|
|
{
|
|
taskService = service;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取业务的任务信息
|
|
/// </summary>
|
|
/// <param name="businessId">业务ID</param>
|
|
/// <param name="businessType">业务类型</param>
|
|
/// <param name="taskTypes">任务类型名称(支持多个,可选参数)</param>
|
|
/// <returns></returns>
|
|
/// <remarks>/GetTasks?taskTypes=任务类型1&taskTypes=任务类型2</remarks>
|
|
[HttpGet, Route("GetTasks")]
|
|
public async Task<DataResult<List<BusinessTaskDto>>> GetTasksAsync(
|
|
[FromQuery] long businessId, [FromQuery] BusinessType businessType, [FromQuery] params string[] taskTypes)
|
|
{
|
|
TaskBaseTypeEnum[]? types = null;
|
|
if (taskTypes?.Length > 0)
|
|
types = taskTypes.Select(Enum.Parse<TaskBaseTypeEnum>).ToArray();
|
|
|
|
return await taskService.GetTasks(businessId, businessType, types);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取指定业务的任务日志
|
|
/// </summary>
|
|
/// <param name="logService"></param>
|
|
/// <param name="businessId">业务ID</param>
|
|
/// <param name="businessType">业务类型</param>
|
|
/// <returns></returns>
|
|
[HttpGet, Route("GetLogs")]
|
|
public async Task<DataResult<List<BusinessTaskLog>>> GetLogsAsync([FromServices] ITaskLogService logService,
|
|
[FromQuery] long businessId, [FromQuery] BusinessType businessType)
|
|
{
|
|
return await logService.ReadLogAsync(businessId, businessType);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建关联任务
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("CreateTask")]
|
|
public async Task<DataResult> CreateTaskAsync([FromBody] TaskCreationRequest request)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
|
|
|
|
return await taskService.CreateTaskAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置任务状态
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("SetTaskStatus")]
|
|
public async Task<DataResult<TaskBaseTypeEnum?>> SetTaskStatusAsync([FromBody] TaskUpdateRequest request)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
return DataResult<TaskBaseTypeEnum?>.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
|
|
|
|
return await taskService.SetTaskStatusAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 手动发起任务审核(用于二次审核)
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("SubmitAudit")]
|
|
public async Task<DataResult> SubmitAuditAsync(TaskRequest request)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
|
|
|
|
return await taskService.SubmitAuditAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 任务审核
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("Audit")]
|
|
public async virtual Task<DataResult> AuditAsync([FromBody] TaskAuditRequest request)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
|
|
|
|
return await taskService.AuditAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 审批完成回调更新(无需客户端手动调用)
|
|
/// </summary>
|
|
/// <param name="callback">回调信息</param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("UpdateBusiness")]
|
|
public async Task<IActionResult> UpdateBusinessAsync([FromBody] FlowCallback callback)
|
|
{
|
|
await taskService.UpdateBusinessAsync(callback);
|
|
return StatusCode((int)HttpStatusCode.NoContent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通知审批执行人变更(无需客户端手动调用)
|
|
/// </summary>
|
|
/// <param name="callback">回调信息</param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("MarkerChanged")]
|
|
public async Task<IActionResult> MarkerChangedAsync([FromBody] MarkerChangedCallback callback)
|
|
{
|
|
await taskService.MarkerChangedAsync(callback);
|
|
return StatusCode((int)HttpStatusCode.NoContent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除任务(内部调试用)
|
|
/// </summary>
|
|
/// <param name="id">业务ID</param>
|
|
/// <param name="businessType">业务类型</param>
|
|
/// <param name="taskType">任务类型(为空时删除全部任务)</param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("Delete")]
|
|
public async Task<DataResult> Delete(long id, BusinessType businessType = BusinessType.OceanShippingExport,
|
|
TaskBaseTypeEnum? taskType = null)
|
|
{
|
|
return await taskService.Delete(id, businessType, null, taskType.HasValue ? [taskType.Value] : []);
|
|
}
|
|
}
|
|
}
|