Browse Source

订单调试修改

master
pry 2 years ago
parent
commit
988e7a75b1
10 changed files with 82 additions and 88 deletions
  1. +16
    -2
      HBLConsole.Business/AbstractServer/Base.cs
  2. +1
    -1
      HBLConsole.Business/M2MqttHelper.cs
  3. +1
    -1
      HBLConsole.Business/ServerData.cs
  4. +17
    -3
      HBLConsole.Communication/ModbusTcpHelper.cs
  5. +28
    -23
      HBLConsole.MORKS/Control_MORKS.cs
  6. +1
    -1
      HBLConsole.Model/KeepParameter/MorkOrderPushPar.cs
  7. +11
    -5
      HBLConsole.Service/ThreadManage.cs
  8. +1
    -1
      HBLConsole/App.config
  9. +2
    -49
      HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs
  10. +4
    -2
      HBLConsole/ViewModel/ViewModelBase.cs

+ 16
- 2
HBLConsole.Business/AbstractServer/Base.cs View File

@@ -22,10 +22,24 @@ namespace HBLConsole.Business.AbstractServer
if (orderInfo == null) return;
if (orderInfo is MorkOrderPush morkOrderpush)
{
OrderData order = Json<MorkOrderPushPar>.Data.morkOrderPushes.Find(par => par.OrderPush?.SuborderId == morkOrderpush.SuborderId);
//OrderData order = Json<MorkOrderPushPar>.Data.morkOrderPushes.Find(par => par.OrderPush?.SuborderId == morkOrderpush.SuborderId);
//if (order == null)//防止重复订单
//{
// Json<MorkOrderPushPar>.Data.morkOrderPushes.Add(new OrderData()
// {
// OrderStatus = ORDER_STATUS.WAIT,
// IsSelected = true,
// OrderPush = morkOrderpush
// });
// ActionManage.GetInstance.Send("AddOrder", morkOrderpush);
// ActionManage.GetInstance.Send("DataParse", morkOrderpush);
//}


OrderData order = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(par => par.OrderPush?.SuborderId == morkOrderpush.SuborderId);
if (order == null)//防止重复订单
{
Json<MorkOrderPushPar>.Data.morkOrderPushes.Add(new OrderData()
Json<KeepDataBase>.Data.orderLists.Add(new OrderData()
{
OrderStatus = ORDER_STATUS.WAIT,
IsSelected = true,


+ 1
- 1
HBLConsole.Business/M2MqttHelper.cs View File

@@ -68,7 +68,7 @@ namespace HBLConsole.Business
MqttM2.GetInstance.PublishInfo(PublishContent);
//mqttClient.Publish($"/sys/grgp0rFA2uu/{deviceName}/thing/event/property/post", Encoding.UTF8.GetBytes(PublishContent), 0, false);

}), "阿里云数据上报", new Action(() => { MqttM2.GetInstance.DisConnect(); }));
}), "阿里云数据上报", false, new Action(() => { MqttM2.GetInstance.DisConnect(); }));
}

}


+ 1
- 1
HBLConsole.Business/ServerData.cs View File

@@ -41,7 +41,7 @@ namespace HBLConsole.Business
}
}
Thread.Sleep(100);
}), "mqtt消息处理");
}), "mqtt消息处理", true);
}




+ 17
- 3
HBLConsole.Communication/ModbusTcpHelper.cs View File

@@ -79,19 +79,33 @@ namespace HBLConsole.Communication

public int GetBoolAddress(string address)
{
if (address != null && address.Length > 4)
if (address != null && address.Length >= 4)
{
var res = address.Substring(1).Split('.');
if (res != null && res.Length == 2)
{

if (int.TryParse(res[0], out int firstAddress) && int.TryParse(res[1], out int ExitAddress))
{
if (ExitAddress >= 0 && ExitAddress <= 7)
{
return (firstAddress * 8) + 320 + ExitAddress;
}
}
}
}
return 0;
return -1;
}

public int GetWordAddress(string address)
{
if (address != null && address.Length > 3)
{
var res = address.Substring(2);
if (res != null && int.TryParse(res, out int tempAddress))
{
return (tempAddress / 2) + 100;
}
}
return -1;
}



+ 28
- 23
HBLConsole.MORKS/Control_MORKS.cs View File

@@ -135,14 +135,14 @@ namespace HBLConsole.MORKS
}));


//var ResLoc = ModbusTcpHelper.GetInstance.Read(286, ReadType.HoldingRegisters);
//if (ResLoc != null)
//{
// if (ResLoc is ushort loc)
// {
// mORKS.TurntableFeedbackloc = loc;
// }
//}
var ResLoc = ModbusTcpHelper.GetInstance.Read(286, ReadType.HoldingRegisters);
if (ResLoc != null)
{
if (ResLoc is ushort loc)
{
mORKS.TurntableFeedbackloc = loc;
}
}

Thread.Sleep(500);
}), "ReadPLCData");
@@ -236,22 +236,22 @@ namespace HBLConsole.MORKS
{
if (loc >= 1 && loc <= 5)
{
//mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(res.BatchingLoc), SuborderId = morkOrderPush.SuborderId, BatchingId = res.BatchingId });
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(res.BatchingLoc), SuborderId = morkOrderPush.SuborderId, BatchingId = res.BatchingId });
}
else if (loc >= 10 && loc <= 11)
{
//int index = 0;
//if (Json<BatchingInfoPar>.Data.recipeBoms != null)
//{
// index = Array.FindIndex(Json<BatchingInfoPar>.Data.recipeBoms?.RecipeIds.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId);
// index++;
//}
//mORKS.TakeBowlTask.Enqueue(new OrderLocInfo()
//{
// Loc = ushort.Parse(res.BatchingLoc),
// SuborderId = morkOrderPush.SuborderId,
// RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0
//});
int index = 0;
if (Json<BatchingInfoPar>.Data.recipeBoms != null)
{
index = Array.FindIndex(Json<BatchingInfoPar>.Data.recipeBoms?.RecipeIds.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId);
index++;
}
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo()
{
Loc = ushort.Parse(res.BatchingLoc),
SuborderId = morkOrderPush.SuborderId,
RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0
});
}
}
}
@@ -493,10 +493,15 @@ namespace HBLConsole.MORKS
{
SimpleFactory.GetInstance.OrderChanged(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE);
MessageLog.GetInstance.Show($"订单【{mORKS.OutMealId}】取餐完成");
var RemoveItem = Json<MorkOrderPushPar>.Data.morkOrderPushes.FirstOrDefault(p => p.OrderPush.SuborderId == mORKS.OutMealId);
//var RemoveItem = Json<MorkOrderPushPar>.Data.morkOrderPushes.FirstOrDefault(p => p.OrderPush.SuborderId == mORKS.OutMealId);
//if (RemoveItem != null)
//{
// Json<MorkOrderPushPar>.Data.morkOrderPushes.Remove(RemoveItem);
//}
var RemoveItem = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(p => p.OrderPush.SuborderId == mORKS.OutMealId);
if (RemoveItem != null)
{
Json<MorkOrderPushPar>.Data.morkOrderPushes.Remove(RemoveItem);
Json<KeepDataBase>.Data.orderLists.Remove(RemoveItem);
}
ResetCookComplete();
mORKS.OutMealId = string.Empty;


+ 1
- 1
HBLConsole.Model/KeepParameter/MorkOrderPushPar.cs View File

@@ -9,6 +9,6 @@ namespace HBLConsole.Model
{
public class MorkOrderPushPar
{
public List<OrderData> morkOrderPushes = new List<OrderData>();
public List<OrderData> morkOrderPushes { get; set; } = new List<OrderData>();
}
}

+ 11
- 5
HBLConsole.Service/ThreadManage.cs View File

@@ -41,11 +41,12 @@ namespace HBLConsole.Service
/// </summary>
/// <param name="action"></param>
/// <param name="key"></param>
public void StartLong(Action action, string key, Action RunComplete = null)
public void StartLong(Action action, string key, bool IsRestart = false, Action RunComplete = null)
{
CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource());
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(async () =>
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() =>
{
ccc:
try
{
while (!CancellationTokenSources[guid + key].IsCancellationRequested)
@@ -58,11 +59,16 @@ namespace HBLConsole.Service
}
catch (Exception ex)
{

MessageLog.GetInstance.Show(ex.ToString());
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启");
CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp);
Threads.TryRemove(guid + key, out Task temp1);

if (IsRestart) goto ccc;
else
{
CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp);
Threads.TryRemove(guid + key, out Task temp1);
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启");
}
}
}), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) =>
{


+ 1
- 1
HBLConsole/App.config View File

@@ -11,7 +11,7 @@

<!--客户端ID-->
<!--MorkD = 2,MorkS 且时且多 = 8,MorkS 珠海 = 9,冰淇淋 = 4,咖啡机 = 13-->
<add key="ClientId" value="5"/>
<add key="ClientId" value="9"/>

<add key="COM_Coffee" value="COM8"/>
<add key="BAUD_Coffee" value="115200"/>


+ 2
- 49
HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs View File

@@ -20,51 +20,6 @@ namespace HBLConsole.DialogWindow.ViewModel
public static bool IsAutoClose = false;
public ListDialogViewModel()
{
//CloseCommand = new RelayCommand(() =>
//{
// Json<MorkOrderPushPar>.Data.morkOrderPushes.Clear();
// orderStatusLists.Clear();
// WeakReferenceMessenger.Default.Send("false", "Close");
//});

//CancelCommand = new RelayCommand(() =>
//{
// Json<MorkOrderPushPar>.Data.morkOrderPushes.Clear();
// orderStatusLists.Clear();
// WeakReferenceMessenger.Default.Send("false", "Close");
//});

//ConfirmCommand = new RelayCommand(() =>
//{
// foreach (var item in orderStatusLists)
// {
// if (!item.IsSelected)
// {
// var reslut = Json<MorkOrderPushPar>.Data.morkOrderPushes.FirstOrDefault(p => p.OrderPush.SuborderId == item.OrderPush.SuborderId);
// if (reslut != null) Json<MorkOrderPushPar>.Data.morkOrderPushes.Remove(reslut);
// }
// }
// foreach (var item in Json<MorkOrderPushPar>.Data.morkOrderPushes)
// {
// orderStatusLists.Add(new OrderData() { IsSelected = true, OrderPush = item.OrderPush, OrderStatus = item.OrderStatus });
// }
// WeakReferenceMessenger.Default.Send("true", "Close");
//});

//foreach (var item in Json<MorkOrderPushPar>.Data.morkOrderPushes)
//{
// orderStatusLists.Add(new OrderData() { IsSelected = true, OrderPush = item.OrderPush, OrderStatus = item.OrderStatus });
//}

//if (Json<MorkOrderPushPar>.Data.morkOrderPushes.Count > 0)
//{
// ThreadManage.GetInstance.Start(new Action(() =>
// {
// Thread.Sleep(10000);
// if (!IsAutoClose) WeakReferenceMessenger.Default.Send("false", "Close");
// }), "延时退出");
//}
//AllSelected = true;
Init();
}

@@ -86,8 +41,6 @@ namespace HBLConsole.DialogWindow.ViewModel

ConfirmCommand = new RelayCommand(() =>
{
//if (Json<KeepDataBase>.Data.orderLists.ContainsKey(GVL.GeneralConfig.DeviceType.ToString()))
//{
var res = orderStatusLists.Where(p => p.IsSelected == true).ToList();
if (res != null)
{
@@ -99,11 +52,11 @@ namespace HBLConsole.DialogWindow.ViewModel
ActionManage.GetInstance.Send("DataParse", item.OrderPush);
}
}
//}
WeakReferenceMessenger.Default.Send("true", "Close");
});

if (Json<MorkOrderPushPar>.Data.morkOrderPushes.Count > 0)
//if (Json<MorkOrderPushPar>.Data.morkOrderPushes.Count > 0)
if (Json<KeepDataBase>.Data.orderLists.Count > 0)
{
ThreadManage.GetInstance.Start(new Action(() =>
{


+ 4
- 2
HBLConsole/ViewModel/ViewModelBase.cs View File

@@ -30,7 +30,8 @@ namespace HBLConsole.ViewModel
{
LogMessage = MessageLog.GetInstance.LogInfo;

IotReport.GetInstance.SendLogMessage(new BPA.Message.API请求.LogTable {
IotReport.GetInstance.SendLogMessage(new BPA.Message.API请求.LogTable
{
ClientId = InternetInfo.ClientId.ToString(),
LogTime = DateTime.Now,
LogType = "1",
@@ -201,7 +202,8 @@ namespace HBLConsole.ViewModel
if (re != null)
{
WaitTakeMeal.Remove(re);
Json<MorkOrderPushPar>.Data.morkOrderPushes.Remove(re);
//Json<MorkOrderPushPar>.Data.morkOrderPushes.Remove(re);
Json<KeepDataBase>.Data.orderLists.Remove(re);
}

break;


Loading…
Cancel
Save