using Newtonsoft.Json;
using OfficeOpenXml.ConditionalFormatting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm.AGVTask;
using WIDESEA_Common.AGVTask;
using WIDESEA_Core;
using WIDESEA_Core.Enums;
using WIDESEA_Model.Models;
using WIDESEA_StorageTaskRepository;
namespace WIDESEA_StoragIntegrationServices
{
public partial class ToAGVService
{
///
/// AGV继续任务接口
///
///
///
public WebResponseContent confirmToContinueTask(object taskRespon)
{
WebResponseContent content = new WebResponseContent();
try
{
var taskResult = JsonConvert.DeserializeObject(taskRespon.ToString());
if (taskResult == null)
{
throw new Exception("AGV调用接口失败:无请求参数");
}
LogFactory.GetLog("AGV继续任务参数").Info(true, $"\r\r--------------------------------------");
LogFactory.GetLog("AGV继续任务参数").Info(true, taskRespon.ToString());
var task = _taskRepository.QueryFirst(x => x.AGVtaskId == taskResult.task_id);
if (task == null) throw new Exception($"未知任务:{taskResult.task_id}");
var finishTask = _taskRepository.QueryFirst(x => x.Roadway == task.Roadway && x.TaskState == (int)TaskStatusEnum.Completed /*&& x.TargetAddress == task.TargetAddress*/);
if (finishTask != null) throw new Exception("当前位置存在未人工确认完成任务,不允许放货");
return content.OK();
}
catch (Exception ex)
{
LogFactory.GetLog("AGV继续任务异常").Info(true, $"\r\r--------------------------------------");
LogFactory.GetLog("AGV继续任务异常").Info(true, ex.Message);
return content.Error($"AGV继续任务异常:{ex.Message}");
}
}
}
}