using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Reflection.Metadata;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_DTO;
|
using WIDESEAWCS_Model.Models;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
public partial class TaskJob
|
{
|
|
#region 下发凯乐士AGV任务
|
public void SendGALAXISTask(List<Dt_Task> tasks)
|
{
|
WebResponseContent content = new WebResponseContent(); // 创建响应对象
|
GALAXISTaskInfo gALAXISTaskInfo = new();
|
try
|
{
|
gALAXISTaskInfo.groupId = DateTime.Now.ToString("yyMMddHHmmss");
|
gALAXISTaskInfo.msgTime = DateTime.Now.ToString();
|
gALAXISTaskInfo.tasks = new List<GALAXISTask>();
|
foreach (var task in tasks)
|
{
|
GALAXISTask gALAXISTask = new GALAXISTask()
|
{
|
taskId = task.WMSTaskNum,
|
taskType = task.TaskType == (int)TaskTypeEnum.MLInbound ? 2 : 1,
|
barCode = task.PalletCode,
|
endNode = task.TargetAddress,
|
startNode = task.SourceAddress,
|
priorityCode = task.Grade
|
};
|
gALAXISTaskInfo.tasks.Add(gALAXISTask);
|
}
|
Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(GALAXISTaskInfo)) ?? throw new Exception("未找到凯乐士AGV任务下发接口配置信息!请检查接口配置");
|
string response = HttpHelper.Post(apiInfo.ApiAddress, gALAXISTaskInfo.Serialize());
|
GALAXISReturn agvContent = response.DeserializeObject<GALAXISReturn>();
|
content.Data = agvContent;
|
if (agvContent.success)
|
{
|
if (agvContent.data.returnStatus != 0) throw new Exception(agvContent.data.returnInfo);
|
tasks.ForEach(task =>
|
{
|
task.TaskState = (int)TaskStatusEnum.Execut;
|
});
|
content.OK();
|
_taskService.UpdateData(tasks);
|
}
|
}
|
catch (Exception ex)
|
{
|
content.Error(ex.Message);
|
//WriteError(nameof(TaskJob), ex.Message, ex);
|
}
|
finally
|
{
|
_trackloginfoService.AddTrackLog(gALAXISTaskInfo, content, "下发凯乐士AGV任务","","");
|
//dt_trackloginfoService.Instance.AddTrackLog(outTaskInfo, content, "接收宇航WMS出库任务下发", "", $"{msg},变更结果:{content.Status}");
|
}
|
}
|
#endregion
|
}
|
}
|