using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core;
using WIDESEAWCS_DTO.WMSInfo;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.Models;
namespace WIDESEAWCS_TaskInfoService
{
public partial class TaskService
{
///
/// 输送线检测口向WMS申请入库
///
/// 托盘号
/// 起始地址
///
public WebResponseContent RequestWMSTask(ConveyorLineDTO lineDTO)
{
WebResponseContent content = new WebResponseContent();
#region 向WMS申请
var ResultData = HttpHelper.PostAsync(WMSInterfaceAddress.ConveyorLineRequestInbound, lineDTO.ToJson(), headers: new Dictionary());
if (ResultData.Result == null) throw new Exception($"向WMS请求入库超时");
return JsonConvert.DeserializeObject(ResultData.Result);
#endregion
}
///
/// 输送线入库完成向WMS申请入库/堆垛机申请入库
///
///
///
public WebResponseContent StackerCraneRequestInbound(Dt_Task task)
{
WebResponseContent content = new WebResponseContent();
try
{
ConveyorLineDTO lineDTO = new ConveyorLineDTO()
{
stationCode = task.CurrentAddress,
TaskNum = task.TaskNum,
Barcode = task.PalletCode
};
var ResultData = HttpHelper.PostAsync(WMSInterfaceAddress.StackerCraneRequestInbound, lineDTO.ToJson(), headers: new Dictionary());
if (ResultData.Result == null) throw new Exception($"向WMS请求入库分配货位超时!任务号:{task.TaskNum}");
content = JsonConvert.DeserializeObject(ResultData.Result);
if (content.Status)
{
var receiveWMSInfo = JsonConvert.DeserializeObject(content.Data.ToJson());
task.SourceIsPickPlace = receiveWMSInfo.SourceIsPickPlace;
task.TargetIsPickPlace = receiveWMSInfo.TargetIsPickPlace;
task.TargetAddress = receiveWMSInfo.TargetAddress;
task.NextAddress = task.TargetAddress;
task.ExceptionMessage = null;
}
else
task.ExceptionMessage = content.Message;
BaseDal.UpdateData(task);
}
catch (Exception ex)
{
content.Error(ex.Message);
}
return content;
}
}
}