소스 검색

修改订单处理

样式分支
applelon 2 년 전
부모
커밋
7ea6d410bc
22개의 변경된 파일248개의 추가작업 그리고 31개의 파일을 삭제
  1. +1
    -1
      BPASmartClient.Business/BPASmartClient.Business.csproj
  2. +1
    -1
      BPASmartClient.Business/Plugin/ConfigMgr.cs
  3. +2
    -0
      BPASmartClient.Business/Plugin/MQTTMgr.cs
  4. +42
    -12
      BPASmartClient.Business/Plugin/OrderProxy.cs
  5. +9
    -1
      BPASmartClient.Device/BaseDevice.cs
  6. +9
    -1
      BPASmartClient.Device/IDevice.cs
  7. +3
    -3
      BPASmartClient.EventBus/EventBus.cs
  8. +1
    -1
      BPASmartClient.EventBus/IEvent.cs
  9. +2
    -2
      BPASmartClient.KLMCoffee/CoffeeMachine.cs
  10. +2
    -0
      BPASmartClient.MQTT/BPASmartClient.MQTT.csproj
  11. +14
    -2
      BPASmartClient.MQTT/MQTTProxy.cs
  12. +4
    -0
      BPASmartClient.Model/BPASmartClient.Model.csproj
  13. +1
    -1
      BPASmartClient.Model/BaseEvent.cs
  14. +1
    -1
      BPASmartClient.Model/DeviceConfigModel.cs
  15. +21
    -0
      BPASmartClient.Model/DoOrderEvent.cs
  16. +31
    -0
      BPASmartClient.Model/KeepDataBase.cs
  17. +34
    -0
      BPASmartClient.Model/OrderData.cs
  18. +29
    -0
      BPASmartClient.Model/ParSet.cs
  19. +36
    -0
      BPASmartClient.Model/SimOrderVisibleData.cs
  20. +1
    -1
      BPASmartClient.Peripheral/BasePeripheral.cs
  21. +1
    -1
      BPASmartClient.Peripheral/IPeripheral.cs
  22. +3
    -3
      BPASmartClient/MainWindow.xaml.cs

+ 1
- 1
BPASmartClient.Business/BPASmartClient.Business.csproj 파일 보기

@@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="BPA.ApolloClient" Version="1.0.9" />
<PackageReference Include="BPA.Message" Version="1.0.9" />
<PackageReference Include="BPA.Message" Version="1.0.10" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />


+ 1
- 1
BPASmartClient.Business/Plugin/ConfigMgr.cs 파일 보기

@@ -59,7 +59,7 @@ namespace BPASmartClient.Business
DeviceConfig deviceConfig = new DeviceConfig();
deviceConfig.Name = device.Attribute("Name").Value;
deviceConfig.Module = device.Attribute("Module").Value;
deviceConfig.DeviceId = device.Attribute("DeviceId").Value;
deviceConfig.DeviceId =int.Parse(device.Attribute("DeviceId").Value);

foreach (var peripheralEl in device.XPathSelectElements("//Peripheral"))
{


+ 2
- 0
BPASmartClient.Business/Plugin/MQTTMgr.cs 파일 보기

@@ -2,6 +2,7 @@
using BPASmartClient.Helper;
using BPASmartClient.MQTT;
using HBLConsole.Communication;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -33,6 +34,7 @@ namespace BPASmartClient.Business
public void Initialize()
{


//MQTT 连接成功
mqttProxy.Connected = new Action(() =>
{


+ 42
- 12
BPASmartClient.Business/Plugin/OrderProxy.cs 파일 보기

@@ -1,7 +1,9 @@
using BPA.Message;
using BPASmartClient.EventBus;
using BPASmartClient.Helper;
using HBLConsole.Communication;
using BPASmartClient.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -14,25 +16,52 @@ namespace BPASmartClient.Business
/// </summary>
public class OrderProxy : IPlugin
{
//订单队列
private ConcurrentQueue<MorkOrderPush> orders = new ConcurrentQueue<MorkOrderPush>();
//运行标识
private bool running = false;
//设备管理
private DeviceMgr deviceMgr;
/// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
deviceMgr = Plugin.GetInstance().GetPlugin<DeviceMgr>();

Plugin.GetInstance().GetPlugin<MQTTMgr>().SetMessageReciveHandler(delegate (IMessage orderInfo)
{
//if(orderInfo == null) return;
//if (orderInfo is MorkOrderPush morkOrderpush)
//{
// OrderData order = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(par => par.OrderPush?.SuborderId == morkOrderpush.SuborderId);
// if (order == null)//防止重复订单
// {
// ActionManage.GetInstance.Send("AddOrder", morkOrderpush);
// GeneralConfig.morkOrderPushes.Enqueue(morkOrderpush);
// //ActionManage.GetInstance.Send("DataParse", morkOrderpush);
// }
//}
if (orderInfo == null) return;
if (orderInfo is MorkOrderPush morkOrderpush)
{
orders.Enqueue(morkOrderpush);
}
});

ThreadManage.GetInstance().StartLong(() =>
{
while (running)
{
while (orders.Count > 0 && orders.TryDequeue(out MorkOrderPush temp))
{
var device = deviceMgr.GetDevices().FirstOrDefault(p => p.DeviceId == temp.DeviceId);
if (null != device)
{
if (!device.IsBusy && device.IsHealth)
{
var orderEvent = DoOrderEvent.Make(temp);
orderEvent.Id = device.DeviceId;
orderEvent.Publish();
}
else
{
}
}
}
Thread.Sleep(50);
}
}, "MQTT 消息处理");
}

/// <summary>
@@ -40,6 +69,7 @@ namespace BPASmartClient.Business
/// </summary>
public void Dispose()
{
running = false;
}
}
}

+ 9
- 1
BPASmartClient.Device/BaseDevice.cs 파일 보기

@@ -16,7 +16,7 @@ namespace BPASmartClient.Device
/// <summary>
/// 设备ID
/// </summary>
public string DeviceId { get; set; }
public int DeviceId { get; set; }
/// <summary>
/// 设备所有状态
/// </summary>
@@ -29,6 +29,14 @@ namespace BPASmartClient.Device
/// 设备类型
/// </summary>
public abstract DeviceClientType DeviceType { get; }
/// <summary>
/// 是否忙碌
/// </summary>
public bool IsBusy { get;protected set; }
/// <summary>
/// 是否健康
/// </summary>
public bool IsHealth { get; protected set; }

public void Initliaze()
{


+ 9
- 1
BPASmartClient.Device/IDevice.cs 파일 보기

@@ -16,7 +16,7 @@ namespace BPASmartClient.Device
/// <summary>
/// 设备ID
/// </summary>
string DeviceId { get; set; }
int DeviceId { get; set; }
/// <summary>
/// 设备名称
/// </summary>
@@ -30,6 +30,14 @@ namespace BPASmartClient.Device
/// </summary>
DeviceStatus Status { get; set; }
/// <summary>
/// 是否忙碌
/// </summary>
bool IsBusy { get; }
/// <summary>
/// 是否健康
/// </summary>
bool IsHealth { get; }
/// <summary>
/// 初始化设备加载
/// </summary>
void Initliaze(List<IPeripheral> peripherals);


+ 3
- 3
BPASmartClient.EventBus/EventBus.cs 파일 보기

@@ -30,13 +30,13 @@ namespace BPASmartClient.EventBus
/// <summary>
/// 事件订阅者集合
/// </summary>
private ConcurrentDictionary<string, ConcurrentDictionary<Type, List<EventHandle>>> _eventHandls = new ConcurrentDictionary<string, ConcurrentDictionary<Type, List<EventHandle>>>();
private ConcurrentDictionary<int, ConcurrentDictionary<Type, List<EventHandle>>> _eventHandls = new ConcurrentDictionary<int, ConcurrentDictionary<Type, List<EventHandle>>>();


/// <summary>
/// 事件订阅
/// </summary>
public void Subscribe<TEvent>(string id,EventHandle handle)
public void Subscribe<TEvent>(int id,EventHandle handle)
{
if (!_eventHandls.ContainsKey(id))
_eventHandls.TryAdd(id, new ConcurrentDictionary<Type, List<EventHandle>>());
@@ -49,7 +49,7 @@ namespace BPASmartClient.EventBus
/// <summary>
/// 事件退订
/// </summary>
public void UnSubscribe<TEvent>(string id,EventHandle handle)
public void UnSubscribe<TEvent>(int id,EventHandle handle)
{
if (_eventHandls.ContainsKey(id))
{


+ 1
- 1
BPASmartClient.EventBus/IEvent.cs 파일 보기

@@ -5,6 +5,6 @@
/// </summary>
public interface IEvent
{
string Id { get; set; }
int Id { get; set; }
}
}

+ 2
- 2
BPASmartClient.KLMCoffee/CoffeeMachine.cs 파일 보기

@@ -85,7 +85,7 @@ namespace BPASmartClient.KLMCoffee
/// </summary>
private void MainLoop()
{
ThreadManage.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (!free)
{
@@ -94,7 +94,7 @@ namespace BPASmartClient.KLMCoffee
Thread.Sleep(200);
}),"咖啡机询问线程");

ThreadManage.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ResolveMsg();
}),"咖啡机解析线程");


+ 2
- 0
BPASmartClient.MQTT/BPASmartClient.MQTT.csproj 파일 보기

@@ -5,7 +5,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.MQTTClient" Version="1.0.9" />
<PackageReference Include="BPA.MQTTnet" Version="1.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
</ItemGroup>

<ItemGroup>


+ 14
- 2
BPASmartClient.MQTT/MQTTProxy.cs 파일 보기

@@ -1,5 +1,7 @@
using System;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -14,9 +16,19 @@ namespace BPASmartClient.MQTT

public bool IsConnected { get; set; }

public void Init()
{

//IConfigurationBuilder configurationBuilder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory());
//IConfiguration config = configurationBuilder.Build();
//configurationBuilder.
//var mqttBroker = config.GetSection("BrokerHostSettings");
//MQTT_Config = mqttBroker.Value.FromJSON<MQTT_Entity>();
}

public void Connect(string ip, int port, string clientId)
{
}

public void CloseConnect()


+ 4
- 0
BPASmartClient.Model/BPASmartClient.Model.csproj 파일 보기

@@ -14,4 +14,8 @@
<Folder Include="机器人\Enum\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.9" />
</ItemGroup>

</Project>

+ 1
- 1
BPASmartClient.Model/BaseEvent.cs 파일 보기

@@ -9,6 +9,6 @@ namespace BPASmartClient.Model
{
public class BaseEvent : IEvent
{
public string Id { get; set; }
public int Id { get; set; }
}
}

+ 1
- 1
BPASmartClient.Model/DeviceConfigModel.cs 파일 보기

@@ -15,7 +15,7 @@ namespace BPASmartClient.Model
{
public string Name { get; set; }
public string Module { get; set; }
public string DeviceId { get; set; }
public int DeviceId { get; set; }
public List<Peripheral> Peripherals { get; set; } = new List<Peripheral>();
}



+ 21
- 0
BPASmartClient.Model/DoOrderEvent.cs 파일 보기

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

namespace BPASmartClient.Model
{
/// <summary>
/// 订单制作事件
/// </summary>
public class DoOrderEvent : BaseEvent
{
public MorkOrderPush MorkOrder { get; set; }
public static DoOrderEvent Make(MorkOrderPush temp)
{
return new DoOrderEvent() { MorkOrder = temp };
}
}
}

+ 31
- 0
BPASmartClient.Model/KeepDataBase.cs 파일 보기

@@ -0,0 +1,31 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System.Collections.Concurrent;


namespace BPASmartClient.Model
{
public class KeepDataBase
{
/// <summary>
/// 模拟订单数据的配置
/// </summary>
public ObservableCollection<SimOrderVisibleData> simOrderConfig { get; set; } = new ObservableCollection<SimOrderVisibleData>();

/// <summary>
/// 需要保存的订单数据
/// </summary>
public ObservableCollection<OrderData> orderLists { get; set; } = new ObservableCollection<OrderData>();

/// <summary>
/// 参数设置
/// </summary>
public ObservableCollection<ParSet> parSets { get; set; } = new ObservableCollection<ParSet>();

}
}

+ 34
- 0
BPASmartClient.Model/OrderData.cs 파일 보기

@@ -0,0 +1,34 @@
using BPA.Message;
using BPA.Message.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Model
{
public class OrderData
{
public bool IsSelected { get { return _mIsSelected; } set { _mIsSelected = value; } }
private bool _mIsSelected;

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

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

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

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

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



}
}

+ 29
- 0
BPASmartClient.Model/ParSet.cs 파일 보기

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

namespace BPASmartClient.Model
{
public class ParSet
{
public ushort Minute { get { return _mMinute; } set { _mMinute = value; } }
private ushort _mMinute;

public ushort Second { get { return _mSecond; } set { _mSecond = value; } }
private ushort _mSecond;


public bool IsShield { get { return _mIsShield; } set { _mIsShield = value; } }
private bool _mIsShield;


public string TextBlockContext { get { return _mTextBlockContext; } set { _mTextBlockContext = value; } }
private string _mTextBlockContext;

public string CheckBoxContext { get { return _mCheckBoxContext; } set { _mCheckBoxContext = value; } }
private string _mCheckBoxContext;

}
}

+ 36
- 0
BPASmartClient.Model/SimOrderVisibleData.cs 파일 보기

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

namespace BPASmartClient.Model
{
public class SimOrderVisibleData
{

//public string ClientDeviceType { get { return _mClientDeviceType; } set { _mClientDeviceType = value; } }
//private string _mClientDeviceType;

public ushort Loc { get { return _mLoc; } set { _mLoc = value; } }
private ushort _mLoc;

public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; } }
private bool _mIsEnable;

public bool IsSelected { get { return _mIsSelected; } set { _mIsSelected = value; IsEnable = !value; } }
private bool _mIsSelected;

public string Text { get { return _mText; } set { _mText = value; } }
private string _mText;

public ushort MinValue { get { return _mMinValue; } set { _mMinValue = value; } }
private ushort _mMinValue;

public ushort MaxValue { get { return _mMaxValue; } set { _mMaxValue = value; } }
private ushort _mMaxValue;



}
}

+ 1
- 1
BPASmartClient.Peripheral/BasePeripheral.cs 파일 보기

@@ -22,7 +22,7 @@ namespace BPASmartClient.Peripheral
/// <summary>
/// 归属设备Id
/// </summary>
public string DeviceId { get; set; }
public int DeviceId { get; set; }

/// <summary>
/// 外设状态集合


+ 1
- 1
BPASmartClient.Peripheral/IPeripheral.cs 파일 보기

@@ -14,7 +14,7 @@ namespace BPASmartClient.Peripheral
/// <summary>
/// 设备ID
/// </summary>
string DeviceId { get; set; }
int DeviceId { get; set; }
/// <summary>
/// 获取指定状态值
/// </summary>


+ 3
- 3
BPASmartClient/MainWindow.xaml.cs 파일 보기

@@ -33,9 +33,9 @@ namespace BPASmartClient

private void Button_Click(object sender, RoutedEventArgs e)
{
new Demo_MakeCoffeeEvent() { Id = "1" }.Publish();
new DRCoffee_MakeCoffeeEvent() { Id = "1", DrinkCode= DrCoffeeDrinksCode.两杯意式浓缩 }.Publish();
new DRCoffee_CoffeeCommCmdEvent() { Id = "1",CommCmd = DrCoffeeCommCmd.冲煮系统快速冲洗指令}.Publish();
new Demo_MakeCoffeeEvent() { Id = 1 }.Publish();
new DRCoffee_MakeCoffeeEvent() { Id = 1, DrinkCode= DrCoffeeDrinksCode.两杯意式浓缩 }.Publish();
new DRCoffee_CoffeeCommCmdEvent() { Id = 1,CommCmd = DrCoffeeCommCmd.冲煮系统快速冲洗指令}.Publish();

}
}


불러오는 중...
취소
저장