99 lines
3.2 KiB
C#
99 lines
3.2 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using NPOI.SS.Formula.Functions;
|
|
using SqlSugar;
|
|
using WCS.BLL;
|
|
using WCS.BLL.DbModels;
|
|
using WCS.BLL.HardWare;
|
|
using WCS.BLL.Manager;
|
|
using WCS.BLL.Services.IService;
|
|
using WCS.BLL.Services.Service;
|
|
using WCS.DAL.Db;
|
|
using WCS.DAL.DbModels;
|
|
using WCS.Model;
|
|
using WCS.Model.ApiModel.AGV;
|
|
using WCS.Model.ApiModel.Home;
|
|
using Mode = WCS.BLL.HardWare.Mode;
|
|
|
|
namespace WCS.WebApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 主页面的接口
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class AgvCallbackServiceController : ControllerBase
|
|
{
|
|
|
|
public AgvCallbackServiceController(IHomerService homerService, ISelfCheckService selfCheckService)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// agv任务回调
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[Route("agvCallback")]
|
|
[HttpPost(Name = "agvCallback")]
|
|
public async Task<object> agvCallback(AGVCallBackRequest request)
|
|
{
|
|
try
|
|
{
|
|
Logs.Write("收到AGV回调" + JsonConvert.SerializeObject(request));
|
|
//找到任务数据
|
|
var task = await DbHelp.db.Queryable<AgvTask>().Where(t => t.TaskCode == request.taskCode)
|
|
.FirstAsync();
|
|
if (task == null)
|
|
{
|
|
return new
|
|
{
|
|
Code = 0,
|
|
Message = "成功",
|
|
reqCode = "123",
|
|
};
|
|
}
|
|
|
|
//判断并更新数据
|
|
var shelf = await DbHelp.db.Queryable<ShelfInfo>().Where(t => t.ShelfCode == request.podCode || t.ShelfCode == task.ShelfCode)
|
|
.FirstAsync();
|
|
if (shelf != null && request.method == "outbin")
|
|
{
|
|
shelf.CurrentLocationId = 0;
|
|
shelf.CurrentLocaiotnCode = string.Empty;
|
|
DbHelp.db.Updateable(shelf).ExecuteCommand();
|
|
}
|
|
|
|
if (shelf != null && request.method == "end")
|
|
{
|
|
task.TaskStatus = TaskStatusEnum.已结束;
|
|
DbHelp.db.Updateable(task).ExecuteCommand();
|
|
|
|
shelf.CurrentLocationId = shelf.DestinationLocationId;
|
|
shelf.CurrentLocaiotnCode = shelf.DestinationLocaiotnCode;
|
|
shelf.DestinationLocationId = 0;
|
|
shelf.DestinationLocaiotnCode = string.Empty;
|
|
shelf.TransStatus = TransStatusEnum.静止;
|
|
DbHelp.db.Updateable(shelf).ExecuteCommand();
|
|
}
|
|
|
|
return new
|
|
{
|
|
Code = 0,
|
|
Message = "成功",
|
|
reqCode = "123",
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ResponseBase()
|
|
{
|
|
Code = 300,
|
|
Message = "获取失败:" + ex.Message,
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|