Parcourir la source

订单本地保存,订单状态更新

样式分支
pry il y a 2 ans
Parent
révision
c533c2db7f
9 fichiers modifiés avec 336 ajouts et 88 suppressions
  1. +55
    -8
      BPASmartClient.Business/Plugin/OrderProxy.cs
  2. +1
    -0
      BPASmartClient.Model/BPASmartClient.Model.csproj
  3. +2
    -0
      BPASmartClient.Model/KeepDataBase.cs
  4. +36
    -9
      BPASmartClient.Model/OrderData.cs
  5. +17
    -23
      BPASmartClient.ViewModel/OrderListDialogViewModel.cs
  6. +24
    -18
      BPASmartClient.ViewModel/OrderStatusViewModel.cs
  7. +20
    -20
      BPASmartClient/App.config
  8. +39
    -4
      BPASmartClient/App.xaml.cs
  9. +142
    -6
      BPASmartClient/OrderListDialogView.xaml

+ 55
- 8
BPASmartClient.Business/Plugin/OrderProxy.cs Voir le fichier

@@ -1,4 +1,5 @@
using BPA.Message;
using BPA.Message.Enum;
using BPASmartClient.EventBus;
using BPASmartClient.Helper;
using BPASmartClient.Http;
@@ -8,6 +9,7 @@ using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -37,10 +39,12 @@ namespace BPASmartClient.Business
public void Start()
{
running = true;
Plugin.GetInstance().GetPlugin<MQTTMgr>().SetMessageReciveHandler(delegate (IMessage orderInfo)
Plugin.GetInstance().GetPlugin<MQTTMgr>().SetMessageReciveHandler(delegate (IMessage message)
{
if (orderInfo == null) return;
if (orderInfo is MorkOrderPush morkOrderpush)
if (message == null) return;

//订单消息
if (message is MorkOrderPush morkOrderpush)
{
if (!orders.ContainsKey(morkOrderpush.DeviceId))
{
@@ -49,6 +53,16 @@ namespace BPASmartClient.Business
}
orders[morkOrderpush.DeviceId].Enqueue(morkOrderpush);
}
//辅料信息
else if (message is RecipeBoms recipe)
{

}
//物料消息
else if (message is OrderMaterialDelivery delivery)
{

}
});

EventBus.EventBus.GetInstance().Subscribe<OrderStatusChangedEvent>(0, OrderStatusChangedHandle);
@@ -73,12 +87,45 @@ namespace BPASmartClient.Business
var orderEvent = DoOrderEvent.Make(temp);
orderEvent.Id = device.DeviceId;
orderEvent.Publish();
Json<KeepDataBase>.Data.orderLists.Add(new OrderData()

#region 添加订单
ObservableCollection<MorkOrder> observableCollection = new ObservableCollection<MorkOrder>();
observableCollection.Add(new MorkOrder()
{
IsSelected = true,
OrderPush = temp,
OrderStatus = BPA.Message.Enum.ORDER_STATUS.WAIT
OrderStatus = ORDER_STATUS.WAIT
});
var res = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(p => p.DeviceId == deviceId.ToString());
if (res == null)
{
Json<KeepDataBase>.Data.orderLists.Add(new OrderData()
{
DeviceId = device.ToString(),
IsAllSelect = true,
morkOrderPushes = observableCollection
});
}
else
{
res.morkOrderPushes.Add(new MorkOrder() { OrderPush = temp });
}

#endregion




//Json<KeepDataBase>.Data.orderLists.Add(new OrderData()
//{
// DeviceId = device.ToString(),
// IsAllSelect = true,
// morkOrderPushes = observableCollection
//});
//Json<KeepDataBase>.Data.orderLists.Add(new OrderData()
//{
// IsSelected = true,
// OrderPush = temp,
// OrderStatus = BPA.Message.Enum.ORDER_STATUS.WAIT
//});
}
}
Thread.Sleep(50);
@@ -113,6 +160,6 @@ namespace BPASmartClient.Business
running = false;
}

}
}

+ 1
- 0
BPASmartClient.Model/BPASmartClient.Model.csproj Voir le fichier

@@ -16,6 +16,7 @@

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.11" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
</ItemGroup>

</Project>

+ 2
- 0
BPASmartClient.Model/KeepDataBase.cs Voir le fichier

@@ -22,6 +22,8 @@ namespace BPASmartClient.Model
/// </summary>
public ObservableCollection<OrderData> orderLists { get; set; } = new ObservableCollection<OrderData>();



/// <summary>
/// 参数设置
/// </summary>


+ 36
- 9
BPASmartClient.Model/OrderData.cs Voir le fichier

@@ -5,30 +5,57 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.Model
{
public class OrderData
public class OrderData : ObservableObject
{
public bool IsSelected { get { return _mIsSelected; } set { _mIsSelected = value; } }
private bool _mIsSelected;
public bool IsAllSelect
{
get { return _mIsAllSelect; }
set
{
_mIsAllSelect = value;
OnPropertyChanged();
for (int i = 0; i < morkOrderPushes.Count; i++)
{
morkOrderPushes.ElementAt(i).IsSelected = value;
}
}
}
private bool _mIsAllSelect;


public string DeviceId { get { return _mDeviceId; } set { _mDeviceId = value; OnPropertyChanged(); } }
private string _mDeviceId;

public ObservableCollection<MorkOrder> morkOrderPushes { get; set; } = new ObservableCollection<MorkOrder>();

public MorkOrderPush OrderPush { get { return _mOrderPush; } set { _mOrderPush = value; } }
}

public class MorkOrder : ObservableObject
{
public bool IsSelected { get { return _mIsSelected; } set { _mIsSelected = value; OnPropertyChanged(); } }
private bool _mIsSelected = true;

public MorkOrderPush OrderPush { get { return _mOrderPush; } set { _mOrderPush = value; OnPropertyChanged(); } }
private MorkOrderPush _mOrderPush = new MorkOrderPush();

public ORDER_STATUS OrderStatus { get { return _mOrderStatus; } set { _mOrderStatus = value; } }
public ORDER_STATUS OrderStatus { get { return _mOrderStatus; } set { _mOrderStatus = value; OnPropertyChanged(); } }
private ORDER_STATUS _mOrderStatus;

public string StartDate { get { return _mStartDate; } set { _mStartDate = value; } }
public string StartDate { get { return _mStartDate; } set { _mStartDate = value; OnPropertyChanged(); } }
private string _mStartDate = string.Empty;

public string EndDate { get { return _mEndDate; } set { _mEndDate = value; } }
public string EndDate { get { return _mEndDate; } set { _mEndDate = value; OnPropertyChanged(); } }
private string _mEndDate = string.Empty;

public string CompleteDate { get { return _mCompleteDate; } set { _mCompleteDate = value; } }
public string CompleteDate { get { return _mCompleteDate; } set { _mCompleteDate = value; OnPropertyChanged(); } }
private string _mCompleteDate = string.Empty;
}



}
}

+ 17
- 23
BPASmartClient.ViewModel/OrderListDialogViewModel.cs Voir le fichier

@@ -2,6 +2,7 @@ using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using BPA.Message;
using BPA.Message.Enum;
using BPASmartClient.Helper;
using BPASmartClient.Model;
@@ -32,7 +33,6 @@ namespace BPASmartClient.ViewModel
if (!IsAutoClose) WeakReferenceMessenger.Default.Send("false", "Close");
}), "ÑÓʱÍ˳ö");
}
AllSelected = true;
}

/// <summary>
@@ -68,38 +68,32 @@ namespace BPASmartClient.ViewModel
{
ConfirmCommand = new RelayCommand(() =>
{
var res = orderStatusLists.Where(p => p.IsSelected == true).ToList();
Json<KeepDataBase>.Data.orderLists.Clear();
//var res = orderStatusLists.Where(p => p.IsSelected == true).ToList();
var res = orderStatusLists.Where(p => p.morkOrderPushes.Where(s => s.IsSelected == true).ToList().Count > 0).ToList();

if (res != null)
{
Json<KeepDataBase>.Data.orderLists.Clear();
foreach (var item in res)
foreach (var item in orderStatusLists)
{
item.OrderStatus = ORDER_STATUS.WAIT;
Json<KeepDataBase>.Data.orderLists.Add(item);
ObservableCollection<MorkOrder> morkOrders = new ObservableCollection<MorkOrder>();
foreach (var mork in item.morkOrderPushes)
{
if (mork.IsSelected) morkOrders.Add(mork);
}
Json<KeepDataBase>.Data.orderLists.Add(new OrderData()
{
DeviceId = item.DeviceId,
IsAllSelect = item.IsAllSelect,
morkOrderPushes = morkOrders,
});
}
}
WeakReferenceMessenger.Default.Send("true", "Close");
});
}

/// <summary>
/// È«Ñ¡±êÖ¾
/// </summary>
public bool AllSelected
{
get { return _mAllSelected; }
set
{
_mAllSelected = value;
OnPropertyChanged();
for (int i = 0; i < orderStatusLists.Count; i++)
{
orderStatusLists.ElementAt(i).IsSelected = value;
}
}
}
private bool _mAllSelected = true;

public RelayCommand CloseCommand { get; set; }

public RelayCommand CancelCommand { get; set; }


+ 24
- 18
BPASmartClient.ViewModel/OrderStatusViewModel.cs Voir le fichier

@@ -55,17 +55,17 @@ namespace BPASmartClient.ViewModel
{
System.Windows.Application.Current?.Dispatcher.BeginInvoke((Action)delegate
{
var result = orderStatusLists.FirstOrDefault(p => p.OrderPush.SuborderId == morkOrderpush.SuborderId);
if (result == null)
{
orderStatusLists.Add(new OrderData()
{
OrderPush = morkOrderpush,
OrderStatus = ORDER_STATUS.WAIT,
IsSelected = true,
StartDate = DateTime.Now.ToString("HH:mm:ss")
});
}
//var result = orderStatusLists.FirstOrDefault(p => p.OrderPush.SuborderId == morkOrderpush.SuborderId);
//if (result == null)
//{
// orderStatusLists.Add(new OrderData()
// {
// OrderPush = morkOrderpush,
// OrderStatus = ORDER_STATUS.WAIT,
// IsSelected = true,
// StartDate = DateTime.Now.ToString("HH:mm:ss")
// });
//}
});
}
}), "AddOrder");
@@ -76,23 +76,29 @@ namespace BPASmartClient.ViewModel
{
Application.Current?.Dispatcher.BeginInvoke((Action)delegate
{
int index = Array.FindIndex(orderStatusLists.ToArray(), p => p.OrderPush.SuborderId == orderStatusChange.SuborderId);
int index = Array.FindIndex(orderStatusLists.ToArray(), p => p.morkOrderPushes.FirstOrDefault(s => s.OrderPush.SuborderId == orderStatusChange.SuborderId) != null);
int index2 = -1;
if (index >= 0 && index < orderStatusLists.Count)
{
index2 = Array.FindIndex(orderStatusLists.ElementAt(index).morkOrderPushes.ToArray(), p => p.OrderPush.SuborderId == orderStatusChange.SuborderId);
}
if (index2 < 0) return;

switch (orderStatusChange.CookingStatus)
{
case ORDER_STATUS.COOKING:
if (index >= 0 && index < orderStatusLists.Count)
orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.CookingStatus;
orderStatusLists.ElementAt(index).morkOrderPushes.ElementAt(index2).OrderStatus = orderStatusChange.CookingStatus;
break;
case ORDER_STATUS.COMPLETED_COOK:
if (index >= 0 && index < orderStatusLists.Count)
{
Application.Current.Dispatcher.BeginInvoke((Action)delegate
{
orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.CookingStatus;
orderStatusLists.ElementAt(index).EndDate = DateTime.Now.ToString("HH:mm:ss");
TimeSpan timeSpan = DateTime.Now.Subtract(Convert.ToDateTime(orderStatusLists.ElementAt(index).StartDate));
orderStatusLists.ElementAt(index).CompleteDate = $"{timeSpan.TotalSeconds.ToString("0.00")} S";
orderStatusLists.ElementAt(index).morkOrderPushes.ElementAt(index2).OrderStatus = orderStatusChange.CookingStatus;
orderStatusLists.ElementAt(index).morkOrderPushes.ElementAt(index2).EndDate = DateTime.Now.ToString("HH:mm:ss");
TimeSpan timeSpan = DateTime.Now.Subtract(Convert.ToDateTime(orderStatusLists.ElementAt(index).morkOrderPushes.ElementAt(index2).StartDate));
orderStatusLists.ElementAt(index).morkOrderPushes.ElementAt(index2).CompleteDate = $"{timeSpan.TotalSeconds.ToString("0.00")} S";
WaitTakeMeal.Insert(0, orderStatusLists.ElementAt(index));
orderStatusLists.RemoveAt(index);
});
@@ -100,7 +106,7 @@ namespace BPASmartClient.ViewModel

break;
case ORDER_STATUS.COMPLETED_TAKE:
var re = WaitTakeMeal.FirstOrDefault(p => p.OrderPush.SuborderId == orderStatusChange.SuborderId);
var re = WaitTakeMeal.FirstOrDefault(p => p.morkOrderPushes.FirstOrDefault(s => s.OrderPush.SuborderId == orderStatusChange.SuborderId) != null);
if (re != null)
{
Application.Current.Dispatcher.BeginInvoke((Action)delegate


+ 20
- 20
BPASmartClient/App.config Voir le fichier

@@ -1,29 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!--通用配置-->
<appSettings>
<!--通用配置-->

<!--测试服务 Consul 地址-->
<!--<add key="ConsulAddress" value="http://111.9.47.105:9011/" />-->
<!--测试服务 Consul 地址-->
<!--<add key="ConsulAddress" value="http://111.9.47.105:9011/" />-->

<!--正式服务 Consul 地址-->
<!--<add key="ConsulAddress" value="http://162.14.105.138:9005" />-->
<!--正式服务 Consul 地址-->
<!--<add key="ConsulAddress" value="http://162.14.105.138:9005" />-->

<!--客户端ID-->
<!--1:且时且多冰淇淋咖啡机,2:且时且多煮面机,3:海科煮面机测试店铺-->
<add key="ClientId" value="12"/>
<add key="ApolloUri" value="http://10.2.1.21:28080"/>
<add key="OrderServiceUri" value="http://10.2.1.26:21527/order/"/>
<add key="StockServiceUri" value="http://10.2.1.26:21527/stock/"/>
<!--客户端ID-->
<!--1:且时且多冰淇淋咖啡机,2:且时且多煮面机,3:海科煮面机测试店铺-->
<add key="ClientId" value="10"/>
<add key="ApolloUri" value="http://10.2.1.21:28080"/>
<add key="OrderServiceUri" value="http://10.2.1.26:21527/order/"/>
<add key="StockServiceUri" value="http://10.2.1.26:21527/stock/"/>


<add key="COM_Coffee" value="COM3"/>
<add key="BAUD_Coffee" value="115200"/>
<add key="COM_IceCream" value="COM12"/>
<add key="BAUD_IceCream" value="9600"/>
<add key="IceCream_CXB_Threshold" value="90"/>
<add key="COM_ICChip" value="COM6"/>
<add key="BAUD_IChip" value="9600"/>
<add key="COM_Coffee" value="COM3"/>
<add key="BAUD_Coffee" value="115200"/>
<add key="COM_IceCream" value="COM12"/>
<add key="BAUD_IceCream" value="9600"/>
<add key="IceCream_CXB_Threshold" value="90"/>
<add key="COM_ICChip" value="COM6"/>
<add key="BAUD_IChip" value="9600"/>

</appSettings>
</appSettings>
</configuration>

+ 39
- 4
BPASmartClient/App.xaml.cs Voir le fichier

@@ -1,8 +1,11 @@
using BPASmartClient.Helper;
using BPA.Message;
using BPA.Message.Enum;
using BPASmartClient.Helper;
using BPASmartClient.Message;
using BPASmartClient.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Data;
using System.Drawing;
@@ -67,11 +70,43 @@ namespace BPASmartClient
/// </summary>
private void NoCompleteOrderInit()
{
if (Json<KeepDataBase>.Data.orderLists.Count > 0)


#region 模拟数据
for (int i = 0; i < 5; i++)
{
OrderListDialogView listDialogView = new OrderListDialogView();
listDialogView.ShowDialog();

ObservableCollection<MorkOrder> morkOrders = new ObservableCollection<MorkOrder>();
for (int m = 0; m < 10; m++)
{
morkOrders.Add(new MorkOrder()
{
OrderPush = new MorkOrderPush(),
OrderStatus = ORDER_STATUS.WAIT
});
}



Json<KeepDataBase>.Data.orderLists.Add(new OrderData()
{
DeviceId = Convert.ToString((i % 2) == 0 ? 1 : 2),
IsAllSelect = true,
morkOrderPushes = morkOrders
});


}

OrderListDialogView listDialogView = new OrderListDialogView();
listDialogView.ShowDialog();
#endregion

//if (Json<KeepDataBase>.Data.orderLists.Count > 0)
//{
// OrderListDialogView listDialogView = new OrderListDialogView();
// listDialogView.ShowDialog();
//}
}

private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)


+ 142
- 6
BPASmartClient/OrderListDialogView.xaml Voir le fichier

@@ -97,7 +97,7 @@
BorderBrush="#55ffffff"
BorderThickness="0,0,0,1">
<StackPanel Orientation="Horizontal">
<Image Margin="15,5,0,5" Source="pack://application:,,,/BPASmartClient.CustomResource;component/Image/HBL.png" />
<Image Margin="15,5,0,5" Source="pack://application:,,,/BPASmartClient.CustomResource;component/Image/HBL.png" />
<TextBlock
Name="tbTitle"
Margin="10,0"
@@ -135,12 +135,13 @@

<!--#region 表单数据-->
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<!--<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
</Grid.RowDefinitions>
</Grid.RowDefinitions>-->

<!--#region 表格标题栏设置-->
<!--
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.1*" />
@@ -200,17 +201,152 @@


</Grid>
-->
<!--#endregion-->

<!--#region 表格数据显示-->
<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding orderStatusLists}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Height="30">
<Grid>
<StackPanel Margin="0 0 0 15">
<CheckBox
Height="20"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Background="#FF2AB2E7"
Content="{Binding DeviceId}"
FontSize="14"
Foreground="#ddd"
IsChecked="{Binding IsAllSelect}"
Template="{StaticResource CbTemplate}" />

<!--#region 表格标题栏设置-->
<Grid Margin="23 5 0 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.068*" />
<ColumnDefinition Width="0.3*" />
<ColumnDefinition />
<ColumnDefinition Width="0.7*" />
</Grid.ColumnDefinitions>

<CheckBox
Height="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#FF2AB2E7"
Content=""
FontSize="14"
Foreground="#ddd"
IsChecked="{Binding AllSelected}"
Template="{StaticResource CbTemplate}" />

<!--<Border
Grid.Column="1"
Grid.ColumnSpan="3"
Background="#882AB2E7" />-->

<Grid Grid.Column="1">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="取餐号" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" />
</Grid>

<TextBlock
Grid.Column="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="商品名称" />

<Grid Grid.Column="3">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="订单状态" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" />
</Grid>

<Border
Grid.Column="1"
Grid.ColumnSpan="3"
Background="#882AB2E7"
BorderBrush="{StaticResource BorderSolid}"
BorderThickness="1,0,1,1" />
</Grid>
<!--#endregion-->

<ItemsControl ItemsSource="{Binding morkOrderPushes}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="23 0 0 0" Height="30">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.068*" />
<ColumnDefinition Width="0.3*" />
<ColumnDefinition />
<ColumnDefinition Width="0.7*" />
</Grid.ColumnDefinitions>

<CheckBox
Height="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#FF2AB2E7"
Content=""
FontSize="14"
Foreground="#ddd"
IsChecked="{Binding IsSelected}"
Template="{StaticResource CbTemplate}" />

<Grid Grid.Column="1">
<TextBlock
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding OrderPush.SortNum}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>

<TextBlock
Grid.Column="2"
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding OrderPush.GoodsName}" />

<Grid Grid.Column="3">
<TextBlock
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}"
Style="{StaticResource TextBlockStyle}"
Text="{Binding OrderStatus, Converter={StaticResource TextConverter}}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>

<Border
Grid.Column="1"
Grid.ColumnSpan="8"
BorderBrush="{StaticResource BorderSolid}"
BorderThickness="1,0,1,1" />

</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

</StackPanel>


</Grid>

<!--<Grid Height="30">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.1*" />
<ColumnDefinition Width="0.3*" />
@@ -256,7 +392,7 @@
BorderBrush="{StaticResource BorderSolid}"
BorderThickness="1,0,1,1" />

</Grid>
</Grid>-->
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>


Chargement…
Annuler
Enregistrer