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(); try { #region 向WMS申请 var ResultData = HttpHelper.PostAsync(WMSInterfaceAddress.ConveyorLineRequestInbound, lineDTO.ToJson(), headers: new Dictionary()); if (ResultData.Result == null) throw new Exception($"向WMS请求入库超时"); content = JsonConvert.DeserializeObject(ResultData.Result); #endregion #region 产线申请入库任务 if (content != null && content.Status)//任务转换 { var task = JsonConvert.DeserializeObject(content.Data.ToJson()); if (task != null) { List TaskNums = new List(); List routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.TargetAddress); if (routers.Count > 0) { task.NextAddress = routers.FirstOrDefault().ChildPosi; } task.WMSId = task.TaskId; task.Creater = "WMS"; task.Dispatchertime = null; task.CreateDate = DateTime.Now; BaseDal.AddData(task); TaskNums.Add(task.TaskNum); _taskExecuteDetailService.AddTaskExecuteDetail(TaskNums, "接收WMS任务"); } } #endregion } catch (Exception ex) { content = WebResponseContent.Instance.Error(ex.Message); } return content; } /// /// 输送线入库完成向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) throw new Exception(content.Message); var receiveWMSInfo = JsonConvert.DeserializeObject(content.Data.ToJson()); task.IsPickPlace = receiveWMSInfo.IsPickPlace; task.TargetAddress = receiveWMSInfo.TargetAddress; task.NextAddress = task.TargetAddress; BaseDal.UpdateData(task); } catch (Exception ex) { content.Error(ex.Message); } return content; } } }