diff --git a/BPASmartClient.Business/MainConsole.cs b/BPASmartClient.Business/MainConsole.cs index 2b72eb67..97f05915 100644 --- a/BPASmartClient.Business/MainConsole.cs +++ b/BPASmartClient.Business/MainConsole.cs @@ -22,14 +22,14 @@ namespace BPASmartClient.Business InternetInfo.InitConfig(); //业务插件初始化 Plugin.GetInstance().Init(); - + //设备开启 Plugin.GetInstance().GetPlugin().StartService(); - MessageLog.GetInstance.InfoNotify = new Action((msg => - { - Console.WriteLine(msg); - })); + //MessageLog.GetInstance.InfoNotify = new Action((msg => + //{ + // Console.WriteLine(msg); + //})); } /// diff --git a/BPASmartClient.Business/Plugin/OrderProxy.cs b/BPASmartClient.Business/Plugin/OrderProxy.cs index e9ab4e49..5867b65e 100644 --- a/BPASmartClient.Business/Plugin/OrderProxy.cs +++ b/BPASmartClient.Business/Plugin/OrderProxy.cs @@ -1,4 +1,5 @@ -using BPA.Message; +//#define test +using BPA.Message; using BPA.Message.Enum; using BPASmartClient.EventBus; using BPASmartClient.Helper; @@ -28,12 +29,32 @@ namespace BPASmartClient.Business private bool running = false; //设备管理 private DeviceMgr deviceMgr; + ConcurrentQueue morkOrderPushes = new ConcurrentQueue(); /// /// 初始化 /// public void Initialize() { deviceMgr = Plugin.GetInstance().GetPlugin(); +#if test + ThreadManage.GetInstance().StartLong(new Action(() => + { + while (morkOrderPushes.Count > 0) + { + if (morkOrderPushes.TryDequeue(out MorkOrderPush mork)) + { + Thread.Sleep(3000); + new OrderStatusChangedEvent() { Status = ORDER_STATUS.COOKING, SubOrderId = mork.SuborderId }.Publish(); + Thread.Sleep(5000); + new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_COOK, SubOrderId = mork.SuborderId }.Publish(); + Thread.Sleep(5000); + new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_TAKE, SubOrderId = mork.SuborderId }.Publish(); + Thread.Sleep(2000); + } + } + Thread.Sleep(1000); + }), "sim order"); +#endif } public void Start() @@ -84,48 +105,13 @@ namespace BPASmartClient.Business { if (orders[deviceId].TryDequeue(out MorkOrderPush temp)) { +#if test + morkOrderPushes.Enqueue(temp); +#endif var orderEvent = DoOrderEvent.Make(temp); orderEvent.Id = device.DeviceId; orderEvent.Publish(); - - #region 添加订单 - ObservableCollection observableCollection = new ObservableCollection(); - observableCollection.Add(new MorkOrder() - { - OrderStatus = ORDER_STATUS.WAIT - }); - var res = Json.Data.orderLists.FirstOrDefault(p => p.DeviceId == deviceId.ToString()); - if (res == null) - { - Json.Data.orderLists.Add(new OrderData() - { - DeviceId = device.ToString(), - IsAllSelect = true, - morkOrderPushes = observableCollection - }); - } - else - { - res.morkOrderPushes.Add(new MorkOrder() { OrderPush = temp }); - } - - #endregion - - - - - //Json.Data.orderLists.Add(new OrderData() - //{ - // DeviceId = device.ToString(), - // IsAllSelect = true, - // morkOrderPushes = observableCollection - //}); - //Json.Data.orderLists.Add(new OrderData() - //{ - // IsSelected = true, - // OrderPush = temp, - // OrderStatus = BPA.Message.Enum.ORDER_STATUS.WAIT - //}); + ActionManage.GetInstance.Send("AddOrder", new object[] { temp, device }); } } Thread.Sleep(50); @@ -149,7 +135,8 @@ namespace BPASmartClient.Business MessageLog.GetInstance.ShowEx(ex.ToString()); } var res = JsonConvert.DeserializeObject(result); - MessageLog.GetInstance.ShowEx(string.Format("订单状态改变,调用API执行结果{0}", res == null ? false : res.isSuccess)); + ActionManage.GetInstance.Send("OrderStatusChange", orderStatusChangedEvent); + MessageLog.GetInstance.Show(string.Format("订单状态改变,调用API执行结果{0}", res == null ? false : res.isSuccess)); } /// diff --git a/BPASmartClient.Business/Plugin/StatusMgr.cs b/BPASmartClient.Business/Plugin/StatusMgr.cs index e4fb4bb6..b65c3e4e 100644 --- a/BPASmartClient.Business/Plugin/StatusMgr.cs +++ b/BPASmartClient.Business/Plugin/StatusMgr.cs @@ -57,6 +57,7 @@ namespace BPASmartClient.Business { wholeDeviceStatus[device.DeviceId] = device.Status.GetStatus(); deviceStatus.Healthy = device.IsHealth ? BPA.Message.Enum.DeviceHealthy.Health : BPA.Message.Enum.DeviceHealthy.UnHealth; + deviceStatus.DeviceType = device.DeviceType; var msg = BPAPackage.Make(deviceStatus, device.DeviceId, device.DeviceType); mqttMgr.Publish(TopicDefine.GetInstance().PushHeartbeatTopics[device.DeviceType], msg.Serialize()); } @@ -70,6 +71,6 @@ namespace BPASmartClient.Business running = false; } - + } } diff --git a/BPASmartClient.CustomResource/Converters/StringToIconConverter.cs b/BPASmartClient.CustomResource/Converters/StringToIconConverter.cs new file mode 100644 index 00000000..732186cf --- /dev/null +++ b/BPASmartClient.CustomResource/Converters/StringToIconConverter.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Data; +using System.Windows.Data; +using System.Globalization; +using System.Text.RegularExpressions; + +namespace BPASmartClient.CustomResource.Converters +{ + public class StringToIconConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + return Regex.Unescape(StringToUnicode(value.ToString())); + } + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + + /// + /// 字符串转为UniCode码字符串 + /// + public static string StringToUnicode(string s) + { + if (!string.IsNullOrEmpty(s)) + { + //这里把格式 转为 \ue625 + return s.Replace(@"&#x", @"\u").Replace(";", ""); + } + return s; + } + } +} diff --git a/BPASmartClient.CustomResource/RecDictionarys/GlobalStyle.xaml b/BPASmartClient.CustomResource/RecDictionarys/GlobalStyle.xaml index 373c7848..2426ffba 100644 --- a/BPASmartClient.CustomResource/RecDictionarys/GlobalStyle.xaml +++ b/BPASmartClient.CustomResource/RecDictionarys/GlobalStyle.xaml @@ -1,4 +1,8 @@ - + + \ No newline at end of file diff --git a/BPASmartClient.CustomResource/Themes/GenricStyle.xaml b/BPASmartClient.CustomResource/Themes/GenricStyle.xaml index 7e92e855..72f62ca5 100644 --- a/BPASmartClient.CustomResource/Themes/GenricStyle.xaml +++ b/BPASmartClient.CustomResource/Themes/GenricStyle.xaml @@ -557,93 +557,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.CustomResource/UserControls/IcoButton.xaml b/BPASmartClient.CustomResource/UserControls/IcoButton.xaml index 5ea149d7..0d786e05 100644 --- a/BPASmartClient.CustomResource/UserControls/IcoButton.xaml +++ b/BPASmartClient.CustomResource/UserControls/IcoButton.xaml @@ -2,6 +2,7 @@ x:Class="BPASmartClient.CustomResource.UserControls.IcoButton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:BPASmartClient.CustomResource.UserControls" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -52,35 +53,47 @@ --> - + + + -