Files
wcs/WCS.WebApi/Controllers/AgvCallbackServiceController.cs
hehaibing-1996 018c11430f 1.BUG修复 任务信息显示都为起点
2.界面优化
3.RCS回调限制优化
2025-02-28 13:00:36 +08:00

124 lines
4.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)
{
Logs.Write("不是我们系统发出的任务!!!!");
return new
{
Code = 0,
Message = "成功",
reqCode = "123",
};
}
//if (task.TaskStatus == TaskStatusEnum.已结束)
//{
// return new
// {
// Code = 0,
// Message = "成功",
// reqCode = "123",
// };
//}
//RCS先调用结束再调用出库时会遇到先更新为对应位置 然后又将对应位置更新为0的情况 所以加运输中状态限制
//判断并更新数据
var shelf = await DbHelp.db.Queryable<ShelfInfo>().Where(t => t.ShelfCode == request.podCode || t.ShelfCode == task.ShelfCode)
.FirstAsync();
//调用的接口不是当前货架正在执行的任务
if (task.TaskCode != shelf.CurrentTaskCode)
{
Logs.Write($"AGV回调的任务[{task.TaskCode}],货架当前任务为【{shelf.CurrentTaskCode}】,不是同一个任务 不进行货架状态更新!");
return new
{
Code = 0,
Message = "成功",
reqCode = "123",
};
}
Logs.Write($"AGV回调的任务[{task.TaskCode}]{request.method}");
if (shelf != null && request.method == "outbin" && shelf.TransStatus == TransStatusEnum.)
{
shelf.CurrentLocationId = 0;
shelf.CurrentLocaiotnCode = string.Empty;
DbHelp.db.Updateable(shelf).ExecuteCommand();
}
if (shelf != null && request.method == "end" && shelf.TransStatus == TransStatusEnum.)
{
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.;
shelf.CurrentTaskCode = string.Empty;
DbHelp.db.Updateable(shelf).ExecuteCommand();
}
return new
{
Code = 0,
Message = "成功",
reqCode = "123",
};
}
catch (Exception ex)
{
return new ResponseBase()
{
Code = 300,
Message = "获取失败:" + ex.Message,
};
}
}
}
}