using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using HBLConsole.Abstract; using BPA.Message; using HBLConsole.Model; using HBLConsole.Service; using BPA.Message.Enum; using HBLConsole.GVL; using BPA.Utility; using Newtonsoft.Json; namespace HBLConsole.Business.MessageServer { public class Base : AbstractMessageServer { public override void AddOrder(T orderInfo) { if (orderInfo == null) return; if (orderInfo is MorkOrderPush morkOrderpush) { Json.GetInstance.Base.morkOrderPushes.Add(new OrderData() { OrderStatus = ORDER_STATUS.WAIT, IsSelected = true, OrderPush = morkOrderpush }); ActionManagerment.GetInstance.Send("AddOrder", morkOrderpush); ActionManagerment.GetInstance.Send("MorksParse", morkOrderpush); } } public override void GetBatchingInfo(T batchingInfo) { if (batchingInfo == null) return; if (batchingInfo is OrderMaterialDelivery BatchingInfos) { Json.GetInstance.Base.orderMaterialDelivery = BatchingInfos; } } public override void GetBatchingInfo(int ClientId) { string result = string.Empty; try { var jsondata = new { ClientId }; string header = $"[{InternetInfo.GetInstance.StockServer}/GetItemInfo]_[{DateTime.Now.Ticks}]".AESEncrypt(); string url = $"{InternetInfo.GetInstance.ApiAddress}{InternetInfo.GetInstance.StockServer}/GetItemInfo"; result = APIHelper.GetInstance.HttpRequest(url, header, jsondata, RequestType.POST); } catch (Exception ex) { MessageLog.GetInstance.Show(ex.ToString()); } Json.GetInstance.Base.orderMaterialDelivery = JsonConvert.DeserializeObject(result); MessageLog.GetInstance.Show("【物料信息】"); Json.GetInstance.Base.orderMaterialDelivery?.BatchingInfo?.ForEach(x => { MessageLog.GetInstance.Show($"{x.BatchingLoc}号位置:{x.BatchingCount}"); }); } public override void GetRecipeBom(T recipeBomInfo) { if (recipeBomInfo == null) return; if (recipeBomInfo is RecipeBoms recipeBom) { Json.GetInstance.Base.recipeBoms = recipeBom; } } public override bool OrderStatusChange(string subOrderId, ORDER_STATUS status) { string result = string.Empty; OrderStatusChange orderStatusChange = new OrderStatusChange() { CookingStatus = status, SuborderId = subOrderId }; try { string header = $"[{InternetInfo.GetInstance.OrderServer}/order/robotstatuschange]_[{DateTime.Now.Ticks}]".AESEncrypt(); string url = $"{InternetInfo.GetInstance.ApiAddress}{InternetInfo.GetInstance.OrderServer}/order/robotstatuschange"; result = APIHelper.GetInstance.HttpRequest(url, header, orderStatusChange, RequestType.POST); } catch (Exception ex) { MessageLog.GetInstance.Show(ex.ToString()); } var res = JsonConvert.DeserializeObject(result); return res?.Result == 2; } } }