Pārlūkot izejas kodu

网络调整修改

煮面机(新)
pry pirms 1 gada
vecāks
revīzija
d4757a4091
3 mainītis faili ar 119 papildinājumiem un 23 dzēšanām
  1. +28
    -22
      BPASmartClient.Business/Plugin/OrderProxy.cs
  2. +77
    -1
      BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs
  3. +14
    -0
      BPASmartClient.MorkSUpgradedVer/Model/OrderStatusModel.cs

+ 28
- 22
BPASmartClient.Business/Plugin/OrderProxy.cs Parādīt failu

@@ -179,36 +179,42 @@ namespace BPASmartClient.Business
SortNum = orderStatusChangedEvent.SortNum
};

#region API 订单状态修改
if (orderStatusChange.SuborderId.Length > 0 && orderStatusChange.CookingStatus != ORDER_STATUS.WAIT)
try
{
try
bool isSuccess = false;
#region API 订单状态修改
if (orderStatusChange.SuborderId.Length > 0 && orderStatusChange.CookingStatus != ORDER_STATUS.WAIT)
{

string header = $"[{InternetInfo.OrderServer}/order/robotstatuschange]_[{DateTime.Now.Ticks}]".AESEncrypt();
string url = $"{InternetInfo.OrderServer}order/robotstatuschange";
result = APIHelper.GetInstance.HttpRequest(url, orderStatusChange, header, RequestType.POST);

var res = JsonConvert.DeserializeObject<OrderStatusRsp>(result);
ActionManage.GetInstance.Send("OrderStatusChange", orderStatusChangedEvent);
isSuccess = res == null ? false : res.isSuccess;
//MessageLog.GetInstance.Show($"订单:{orderStatusChange.SuborderId} 状态:{orderStatusChange.CookingStatus} 执行结果:{isSuccess}");
//MessageLog.GetInstance.Show(string.Format("订单状态改变,调用API执行结果{0}", res == null ? false : res.isSuccess));
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
}
var res = JsonConvert.DeserializeObject<OrderStatusRsp>(result);
ActionManage.GetInstance.Send("OrderStatusChange", orderStatusChangedEvent);
bool isSuccess = res == null ? false : res.isSuccess;
MessageLog.GetInstance.Show($"订单:{orderStatusChange.SuborderId} 状态:{orderStatusChange.CookingStatus} 执行结果:{isSuccess}");
//MessageLog.GetInstance.Show(string.Format("订单状态改变,调用API执行结果{0}", res == null ? false : res.isSuccess));
}
#endregion
#endregion

#region MQTT 订单状态修改
var clientId = Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId;
var temp = BPAPackage.Make(orderStatusChange, clientId, orderStatusChangedEvent.deviceClientType);
var q = temp.Serialize(false);
Plugin.GetInstance().GetPlugin<MQTTMgr>().Publish(TOPIC.GetInstance.GetAppTopic(clientId.ToString()), temp.Serialize(false));
if (orderStatusChange.CookingStatus == ORDER_STATUS.COMPLETED_TAKE)
MessageLog.GetInstance.Show($"通知叫号:{orderStatusChange.GoodName}--{orderStatusChange.SortNum}");
#endregion

if (isSuccess) callBack?.Invoke();

#region MQTT 订单状态修改
var clientId = Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId;
var temp = BPAPackage.Make(orderStatusChange, clientId, orderStatusChangedEvent.deviceClientType);
var q = temp.Serialize(false);
Plugin.GetInstance().GetPlugin<MQTTMgr>().Publish(TOPIC.GetInstance.GetAppTopic(clientId.ToString()), temp.Serialize(false));
if (orderStatusChange.CookingStatus == ORDER_STATUS.COMPLETED_TAKE)
MessageLog.GetInstance.Show($"通知叫号:{orderStatusChange.GoodName}--{orderStatusChange.SortNum}");
#endregion
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
}
}




+ 77
- 1
BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs Parādīt failu

@@ -1,6 +1,6 @@
using BPASmartClient.CustomResource;
using static BPA.Helper.EventBus;
using System.Collections.Concurrent;
//using BPA.Helper;

namespace BPASmartClient.MorkSUpgradedVer
@@ -104,10 +104,86 @@ namespace BPASmartClient.MorkSUpgradedVer
recipeBoms = recipe.recipeBoms;
}
});

OrderNotifyInit();
}


#region 接口通知任务处理
ConcurrentQueue<OrderStatusModel> osm = new ConcurrentQueue<OrderStatusModel>();
private void OrderNotifyInit()
{
TaskManage.GetInstance.StartLong(() =>
{
while (osm.Count > 0)
{
TempOrderChange(osm.ElementAt(0).SubOrderId, osm.ElementAt(0).Status, () =>
{
osm.TryDequeue(out OrderStatusModel tempOSM);
DeviceProcessLogShow($"订单:{tempOSM.SubOrderId}, 状态:{tempOSM.Status}, API状态修改成功");
});
}
Thread.Sleep(100);
}, $"订单状态更新接口{DeviceId}", true);
}

private void TempOrderChange(string subid, ORDER_STATUS oRDER_STATUS, Action complete)
{
var res = mORKS.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid);
string goodName = string.Empty;
string SortNum = string.Empty;
if (res != null)
{
goodName = res.MorkOrder.GoodsName;
SortNum = res.MorkOrder.SortNum.ToString();
}
if (!string.IsNullOrEmpty(goodName) && !string.IsNullOrEmpty(SortNum))
{
EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }, e => { complete?.Invoke(); });

var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum);
//如果订单信息已经存在,则修改状态,否则新增。
if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count)
{
if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK)
{
DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index);
DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel()
{
Status = oRDER_STATUS,
GoodName = goodName,
SortNum = SortNum,
StopTime = DateTime.Now.ToString("HH:mm:ss")
});
}
else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE)
{
var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum);
if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp);
}
else DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS;
}
else
{
DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel()
{
Status = oRDER_STATUS,
GoodName = goodName,
SortNum = SortNum,
StartTime = DateTime.Now.ToString("HH:mm:ss")
});
}
}
}
#endregion


private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
{
osm.Enqueue(new OrderStatusModel() { SubOrderId = subid, Status = oRDER_STATUS });
return;


var res = mORKS.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid);
string goodName = string.Empty;
string SortNum = string.Empty;


+ 14
- 0
BPASmartClient.MorkSUpgradedVer/Model/OrderStatusModel.cs Parādīt failu

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkSUpgradedVer.Model
{
internal class OrderStatusModel
{
public string SubOrderId { get; set; }
public ORDER_STATUS Status { get; set; }
}
}

Notiek ielāde…
Atcelt
Saglabāt