using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels;
using WIDESEA_WCS;
using WIDESEA_Services.Services;
using System.Collections.Generic;
using WIDESEA_Common;
using WIDESEA_WCS.WCSClient;
using System.Linq;
using System;
using WIDESEA_Common.CutomerModel;
using WIDESEA_Services.Repositories;
using WIDESEA_Services;
namespace WIDESEA_WCSServer.Controllers.ToWMS
{
[Route("api/ToWMS")]
[ApiController]
public class ToWMSController : ControllerBase
{
///
/// 接收WMS下发的任务
///
///
///
[HttpPost, Route("ReceiveTaskFromWMS"), AllowAnonymous]
public WebResponseContent ReceiveTaskFromWMS([FromBody] List taskinfo)
{
Dt_TaskWCSinfoRepository taskWCSinfoRepository = new Dt_TaskWCSinfoRepository(Dt_TaskWCSinfoRepository.Instance.DbContext);
Dt_TaskWCSinfoService taskWCSinfoService = new Dt_TaskWCSinfoService(taskWCSinfoRepository);
return taskWCSinfoService.AddTaskByWms(taskinfo);
}
///
/// 取消一条未开始执行的任务
///
///
///
[HttpPost, Route("CancelATask"), AllowAnonymous]
public WebResponseContent CancelATask([FromBody] SaveModel saveModel)
{
Dt_TaskWCSinfoRepository taskWCSinfoRepository = new Dt_TaskWCSinfoRepository(Dt_TaskWCSinfoRepository.Instance.DbContext);
Dt_TaskWCSinfoService taskWCSinfoService = new Dt_TaskWCSinfoService(taskWCSinfoRepository);
return taskWCSinfoService.CancelATask(saveModel);
}
///
/// WMS下发更改任务状态,给测量设备测量完毕后,更新WCS任务状态
///
///
///
[HttpPost, Route("UpdateWcsTaskState"), AllowAnonymous]
public WebResponseContent UpdateWcsTaskState([FromBody] SaveModel saveModel)
{
Dt_TaskWCSinfoRepository taskWCSinfoRepository = new Dt_TaskWCSinfoRepository(Dt_TaskWCSinfoRepository.Instance.DbContext);
Dt_TaskWCSinfoService taskWCSinfoService = new Dt_TaskWCSinfoService(taskWCSinfoRepository);
return taskWCSinfoService.UpdateWcsTaskState(saveModel);
}
///
/// WMS下发更改任务信息,当入库任务与出库测量任务冲突时,WMS调用此接口来更换目的货位
///
///
///
[HttpPost, Route("UpdateWcsTaskInformation"), AllowAnonymous]
public WebResponseContent UpdateWcsTaskInformation([FromBody] SaveModel saveModel)
{
Dt_TaskWCSinfoRepository taskWCSinfoRepository = new Dt_TaskWCSinfoRepository(Dt_TaskWCSinfoRepository.Instance.DbContext);
Dt_TaskWCSinfoService taskWCSinfoService = new Dt_TaskWCSinfoService(taskWCSinfoRepository);
return taskWCSinfoService.UpdateWcsTaskInformation(saveModel);
}
///
/// 切换入库线体区的模式,正常模式和应急模式
///
[HttpPost, Route("ChangeInboundLineModel"), AllowAnonymous]
public WebResponseContent ChangeInboundLineModel([FromBody] SaveModel saveModel)
{
return WCSService.ChangeInboundLineModel(saveModel);
}
///
/// 获取入库线体当前模式状态
///
[HttpPost, Route("GetInboundLineCurrentModel"), AllowAnonymous]
public WebResponseContent GetInboundLineCurrentModel([FromBody] SaveModel saveModel)
{
return WCSService.GetInboundLineCurrentModel(saveModel);
}
///
/// 当校验托盘码不一致时,人工触发继续任务
///
[HttpPost, Route("CheckBarcodeSameOk"), AllowAnonymous]
public WebResponseContent CheckBarcodeSameOk([FromBody] SaveModel saveModel)
{
return WCSService.CheckBarcodeSameOk(saveModel);
}
///
/// 称重后,由人工继续任务
///
[HttpPost, Route("WeightCheckOk"), AllowAnonymous]
public WebResponseContent WeightCheckOk([FromBody] SaveModel saveModel)
{
return WCSService.WeightCheckOk(saveModel);
}
///
/// 取消测量,直接回库
///
[HttpPost, Route("CancelAMeasureTask"), AllowAnonymous]
public WebResponseContent CancelAMeasureTask([FromBody] SaveModel saveModel)
{
Dt_TaskWCSinfoRepository taskWCSinfoRepository = new Dt_TaskWCSinfoRepository(Dt_TaskWCSinfoRepository.Instance.DbContext);
Dt_TaskWCSinfoService taskWCSinfoService = new Dt_TaskWCSinfoService(taskWCSinfoRepository);
return taskWCSinfoService.CancelAMeasureTask(saveModel);
}
}
}