using HslCommunication.WebSocket;
|
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.BaseController;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_DTO.TaskInfo;
|
using WIDESEAWCS_IBasicInfoRepository;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_Tasks;
|
using WIDESEAWCS_Tasks.DBNames;
|
|
namespace WIDESEAWCS_WCSServer.Controllers.Task
|
{
|
[Route("api/Task")]
|
[ApiController]
|
public class TaskController : ApiBaseController<ITaskService, Dt_Task>
|
{
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IRouterExtension _routerExtension;
|
private readonly IStationMangerRepository _stationMangerRepository;
|
|
public TaskController(ITaskService service, IHttpContextAccessor httpContextAccessor, IRouterExtension routerExtension, IStationMangerRepository stationMangerRepository) : base(service)
|
{
|
_httpContextAccessor = httpContextAccessor;
|
_routerExtension = routerExtension;
|
_stationMangerRepository=stationMangerRepository;
|
}
|
|
[HttpPost, Route("ReceiveTask"), AllowAnonymous]
|
public WebResponseContent ReceiveWMSTask([FromBody] WMSTaskDTO taskDTO)
|
{
|
return Service.ReceiveWMSTask(taskDTO);
|
}
|
|
|
[HttpPost, HttpGet, Route("UpdateTaskExceptionMessage")]
|
public WebResponseContent UpdateTaskExceptionMessage(int taskNum, string message)
|
{
|
return Service.UpdateTaskExceptionMessage(taskNum, message);
|
}
|
|
[HttpPost, HttpGet, Route("TaskStatusRecovery")]
|
public WebResponseContent TaskStatusRecovery(int taskNum)
|
{
|
return Service.TaskStatusRecovery(taskNum);
|
}
|
|
[HttpPost, HttpGet, Route("RollbackTaskStatusToLast")]
|
public WebResponseContent RollbackTaskStatusToLast(int taskNum)
|
{
|
return Service.RollbackTaskStatusToLast(taskNum);
|
}
|
/// <summary>
|
/// 容器流动接口
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost, HttpGet, Route("ContainerFlow"), AllowAnonymous]
|
public WebResponseContent ContainerFlow([FromBody] ContainerFlowDTO containerFlowDTO)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x=>x.PickStationCode==containerFlowDTO.SlotCode) ?? throw new Exception($"{containerFlowDTO.SlotCode}拣选位置不存在");
|
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
|
if (device == null)
|
{
|
return WebResponseContent.Instance.Error($"未找到对应设备{stationManger.StationDeviceCode}");
|
}
|
CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
|
string PickBarCode = commonConveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.R_PickBarCode, stationManger.StationCode).Replace("\0", "");
|
if (containerFlowDTO.ContainerCode!= PickBarCode) throw new Exception($"传入料箱码{containerFlowDTO.ContainerCode},输送料箱码{PickBarCode}数据错误");
|
commonConveyorLine.SetValue(ConveyorLineDBName.W_PickToHode,(short)containerFlowDTO.Direction.ObjToInt(), stationManger.StationCode);
|
content.OK();
|
}
|
catch (Exception ex)
|
{
|
content.Error(ex.Message);
|
}
|
return content;
|
}
|
|
[HttpPost, HttpGet, Route("GetRouteEndPoint"), AllowAnonymous]
|
public WebResponseContent GetRouteEndPoint(string startPoint, int routeType)
|
{
|
return WebResponseContent.Instance.OK(data: _routerExtension.GetEndPoint(startPoint, routeType));
|
}
|
/// <summary>
|
/// WMS任务完成同步
|
/// </summary>
|
/// <param name="taskNum"></param>
|
/// <returns></returns>
|
[HttpPost, HttpGet, Route("RecWMSTaskCompleted"), AllowAnonymous]
|
public WebResponseContent RecWMSTaskCompleted(int taskNum)
|
{
|
return Service.RecWMSTaskCompleted(taskNum);
|
}
|
}
|
}
|