Browse Source

Merge branch 'master' of http://10.2.1.24:10244/xxe/HKCard

master
xxe 2 years ago
parent
commit
994a774122
4 changed files with 112 additions and 146 deletions
  1. +106
    -91
      HKCardOUT/Helper/BigScreen/DataCenter.cs
  2. +0
    -49
      HKCardOUT/Helper/DataBus.cs
  3. +3
    -3
      HKCardOUT/ViewModels/RootViewModel.cs
  4. +3
    -3
      HKCardOUT/options.pro.json

+ 106
- 91
HKCardOUT/Helper/BigScreen/DataCenter.cs View File

@@ -22,13 +22,14 @@ namespace Helper.BigScreen
{ {
public class DataCenter public class DataCenter
{ {
readonly object locker = new();
public static List<string> S1 { get; set; } = new List<string>(2); public static List<string> S1 { get; set; } = new List<string>(2);
public static List<string> S2 { get; set; } = new List<string>(2); public static List<string> S2 { get; set; } = new List<string>(2);
public static List<string> S3 { get; set; } = new List<string>(2); public static List<string> S3 { get; set; } = new List<string>(2);
public static List<string> S4 { get; set; } = new List<string>(2); public static List<string> S4 { get; set; } = new List<string>(2);
public static List<string> S5 { get; set; } = new List<string>(2); public static List<string> S5 { get; set; } = new List<string>(2);
public static List<string> S6 { get; set; } = new List<string>(2); public static List<string> S6 { get; set; } = new List<string>(2);
public static void CreateData()
public void CreateData()
{ {


var sender = new ScreenModelSplitMeals(); var sender = new ScreenModelSplitMeals();
@@ -63,142 +64,153 @@ namespace Helper.BigScreen
sender.WorkStatus_4 = Main.GetInstance.GetIsSwipe(3) ? WorkStatus.工作 : WorkStatus.待机; sender.WorkStatus_4 = Main.GetInstance.GetIsSwipe(3) ? WorkStatus.工作 : WorkStatus.待机;
sender.WorkStatus_5 = Main.GetInstance.GetIsSwipe(2) ? WorkStatus.工作 : WorkStatus.待机; sender.WorkStatus_5 = Main.GetInstance.GetIsSwipe(2) ? WorkStatus.工作 : WorkStatus.待机;
sender.WorkStatus_6 = Main.GetInstance.GetIsSwipe(1) ? WorkStatus.工作 : WorkStatus.待机; sender.WorkStatus_6 = Main.GetInstance.GetIsSwipe(1) ? WorkStatus.工作 : WorkStatus.待机;
sender.SplitMeals_CreditCardCount_1 = model["6"];
if (DataBus.SaleLogDtoList.ContainsKey("6"))
var GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == $"05" || t.Address == $"06").Select(t => t.GateId).FirstOrDefault();
var res = DataBus.Menu.GateFood.Where(t => t.GateId == GateId)?.Select(t => t.Foods)?.FirstOrDefault();
if (model.ContainsKey("6"))
{ {
if (DataBus.SaleLogDtoList["6"].Count > 0)
sender.SplitMeals_CreditCardCount_1 = model["6"];
if (DataBus.SaleLogDtoList.ContainsKey("6"))
{ {
if (DataBus.SaleLogDtoList["6"].TryDequeue(out SaleLogDto info))
if (DataBus.SaleLogDtoList["6"].Count > 0)
{ {
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S1.Count >= 2)
if (DataBus.SaleLogDtoList["6"].TryDequeue(out SaleLogDto info))
{ {
S1.RemoveAt(0);
S1.Add(Name);
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S1.Count >= 2)
{
S1.RemoveAt(0);
S1.Add(Name);
}
else
S1.Add(Name);
sender.SplitMeals_CreditCardNameBefore_1 = S1[0];
sender.SplitMeals_CreditCardName_1 = S1.Count >= 2 ? S1[1] : S1[0];
} }
else
S1.Add(Name);
sender.SplitMeals_CreditCardNameBefore_1 = S1[0];
sender.SplitMeals_CreditCardName_1 = S1.Count >= 2 ? S1[1] : S1[0];
} }
} }
}
var GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == $"05" || t.Address == $"06").Select(t => t.GateId).FirstOrDefault();
var res = DataBus.Menu.GateFood.Where(t => t.GateId == GateId)?.Select(t => t.Foods)?.FirstOrDefault();
sender.SplitMeals_CookType_1 = res;


sender.SplitMeals_CreditCardCount_2 = model["5"];
if (DataBus.SaleLogDtoList.ContainsKey("5"))
sender.SplitMeals_CookType_1 = res;
}
if (model.ContainsKey("5"))
{ {
if (DataBus.SaleLogDtoList["5"].Count > 0)
sender.SplitMeals_CreditCardCount_2 = model["5"];
if (DataBus.SaleLogDtoList.ContainsKey("5"))
{ {
if (DataBus.SaleLogDtoList["5"].TryDequeue(out SaleLogDto info))
if (DataBus.SaleLogDtoList["5"].Count > 0)
{ {
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S2.Count >= 2)
if (DataBus.SaleLogDtoList["5"].TryDequeue(out SaleLogDto info))
{ {
S2.RemoveAt(0);
S2.Add(Name);
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S2.Count >= 2)
{
S2.RemoveAt(0);
S2.Add(Name);
}
else
S2.Add(Name);
sender.SplitMeals_CreditCardNameBefore_2 = S2[0];
sender.SplitMeals_CreditCardName_2 = S2.Count >= 2 ? S2[1] : S2[0];
} }
else
S2.Add(Name);
sender.SplitMeals_CreditCardNameBefore_2 = S2[0];
sender.SplitMeals_CreditCardName_2 = S2.Count >= 2 ? S2[1] : S2[0];
} }
} }
sender.SplitMeals_CookType_2 = res;
} }
sender.SplitMeals_CookType_2 = res;

sender.SplitMeals_CreditCardCount_3 = model["4"];
if (DataBus.SaleLogDtoList.ContainsKey("4"))
if (model.ContainsKey("4"))
{ {
if (DataBus.SaleLogDtoList["4"].Count > 0)
sender.SplitMeals_CreditCardCount_3 = model["4"];
if (DataBus.SaleLogDtoList.ContainsKey("4"))
{ {
if (DataBus.SaleLogDtoList["4"].TryDequeue(out SaleLogDto info))
if (DataBus.SaleLogDtoList["4"].Count > 0)
{ {
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S3.Count >= 2)
if (DataBus.SaleLogDtoList["4"].TryDequeue(out SaleLogDto info))
{ {
S3.RemoveAt(0);
S3.Add(Name);
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S3.Count >= 2)
{
S3.RemoveAt(0);
S3.Add(Name);
}
else
S3.Add(Name);
sender.SplitMeals_CreditCardNameBefore_3 = S3[0];
sender.SplitMeals_CreditCardName_3 = S3.Count >= 2 ? S3[1] : S3[0];
} }
else
S3.Add(Name);
sender.SplitMeals_CreditCardNameBefore_3 = S3[0];
sender.SplitMeals_CreditCardName_3 = S3.Count >= 2 ? S3[1] : S3[0];
} }
} }
sender.SplitMeals_CookType_3 = res;
} }
sender.SplitMeals_CookType_3 = res;

sender.SplitMeals_CreditCardCount_4 = model["3"];
if (DataBus.SaleLogDtoList.ContainsKey("3"))
if (model.ContainsKey("3"))
{ {
if (DataBus.SaleLogDtoList["3"].Count > 0)
sender.SplitMeals_CreditCardCount_4 = model["3"];
if (DataBus.SaleLogDtoList.ContainsKey("3"))
{ {
if (DataBus.SaleLogDtoList["3"].TryDequeue(out SaleLogDto info))
if (DataBus.SaleLogDtoList["3"].Count > 0)
{ {
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S4.Count >= 2)
if (DataBus.SaleLogDtoList["3"].TryDequeue(out SaleLogDto info))
{ {
S4.RemoveAt(0);
S4.Add(Name);
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S4.Count >= 2)
{
S4.RemoveAt(0);
S4.Add(Name);
}
else
S4.Add(Name);
sender.SplitMeals_CreditCardNameBefore_4 = S4[0];
sender.SplitMeals_CreditCardName_4 = S4.Count >= 2 ? S4[1] : S4[0];
} }
else
S4.Add(Name);
sender.SplitMeals_CreditCardNameBefore_4 = S4[0];
sender.SplitMeals_CreditCardName_4 = S4.Count >= 2 ? S4[1] : S4[0];
} }
} }
sender.SplitMeals_CookType_4 = res;
} }
sender.SplitMeals_CookType_4 = res;

sender.SplitMeals_CreditCardCount_5 = model["2"];
if (DataBus.SaleLogDtoList.ContainsKey("2"))
if (model.ContainsKey("2"))
{ {
if (DataBus.SaleLogDtoList["2"].Count > 0)
sender.SplitMeals_CreditCardCount_5 = model["2"];
if (DataBus.SaleLogDtoList.ContainsKey("2"))
{ {
if (DataBus.SaleLogDtoList["2"].TryDequeue(out SaleLogDto info))
if (DataBus.SaleLogDtoList["2"].Count > 0)
{ {
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S5.Count >= 2)
if (DataBus.SaleLogDtoList["2"].TryDequeue(out SaleLogDto info))
{ {
S5.RemoveAt(0);
S5.Add(Name);
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S5.Count >= 2)
{
S5.RemoveAt(0);
S5.Add(Name);
}
else
S5.Add(Name);
sender.SplitMeals_CreditCardNameBefore_5 = S5[0];
sender.SplitMeals_CreditCardName_5 = S5.Count >= 2 ? S5[1] : S5[0];
} }
else
S5.Add(Name);
sender.SplitMeals_CreditCardNameBefore_5 = S5[0];
sender.SplitMeals_CreditCardName_5 = S5.Count >= 2 ? S5[1] : S5[0];
} }
} }
sender.SplitMeals_CookType_5 = res;
} }
sender.SplitMeals_CookType_5 = res;

sender.SplitMeals_CreditCardCount_6 = model["1"];
if (DataBus.SaleLogDtoList.ContainsKey("1"))
if (model.ContainsKey("1"))
{ {
if (DataBus.SaleLogDtoList["1"].Count > 0)
sender.SplitMeals_CreditCardCount_6 = model["1"];
if (DataBus.SaleLogDtoList.ContainsKey("1"))
{ {
if (DataBus.SaleLogDtoList["1"].TryDequeue(out SaleLogDto info))
if (DataBus.SaleLogDtoList["1"].Count > 0)
{ {
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S6.Count >= 2)
if (DataBus.SaleLogDtoList["1"].TryDequeue(out SaleLogDto info))
{ {
S6.RemoveAt(0);
S6.Add(Name);
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S6.Count >= 2)
{
S6.RemoveAt(0);
S6.Add(Name);
}
else
S6.Add(Name);
sender.SplitMeals_CreditCardNameBefore_6 = S6[0];
sender.SplitMeals_CreditCardName_6 = S6.Count >= 2 ? S6[1] : S6[0];
} }
else
S6.Add(Name);
sender.SplitMeals_CreditCardNameBefore_6 = S6[0];
sender.SplitMeals_CreditCardName_6 = S6.Count >= 2 ? S6[1] : S6[0];
} }
} }
sender.SplitMeals_CookType_6 = res;
} }
sender.SplitMeals_CookType_6 = res;

GateId = DataBus.StoreInfo.Devices.Select(t => t.GateId).FirstOrDefault();
var Foods = DataBus.Menu.GateFood.Where(t => t.GateId == GateId)?.Select(t => t.Foods)?.FirstOrDefault(); var Foods = DataBus.Menu.GateFood.Where(t => t.GateId == GateId)?.Select(t => t.Foods)?.FirstOrDefault();
sender.StatsCount = new List<StatsModel>(); sender.StatsCount = new List<StatsModel>();
foreach (var item in Foods) foreach (var item in Foods)
@@ -209,8 +221,11 @@ namespace Helper.BigScreen
Count = model.Values.Sum() Count = model.Values.Sum()
}); });
} }
MQTTCon.Send(sender);
Thread.Sleep(10);
lock (locker)
{
MQTTCon.Send(sender);
}
Thread.Sleep(300);
}, $"屏幕刷卡信息", true); }, $"屏幕刷卡信息", true);
} }
public static void InitQueeue() public static void InitQueeue()


+ 0
- 49
HKCardOUT/Helper/DataBus.cs View File

@@ -149,62 +149,13 @@ namespace HKCardOUT.Helper
} }


} }

public static void Send(ScreenModelSplitMeals screenModel) public static void Send(ScreenModelSplitMeals screenModel)
{ {
if (!IsRunningMqtt) return; if (!IsRunningMqtt) return;
SendScreenDataModel sendScreenData = new SendScreenDataModel(); SendScreenDataModel sendScreenData = new SendScreenDataModel();
sendScreenData.Name = ScreenDeviceType.分餐机; sendScreenData.Name = ScreenDeviceType.分餐机;
sendScreenData.Value = screenModel; sendScreenData.Value = screenModel;
//new ScreenModelSplitMeals
//{
// IsRun = k2 == 0 ? IsRun.运行 : IsRun.停止,
// WorkStatus = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
// RobotStatu = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
// Alarm = new List<AlarmModel> {
// new AlarmModel { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(2).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// },
// FailuresCount = 0,
// StatsCount = new List<StatsModel> {
// new StatsModel { Name = name_s[0], Count = new Random().Next(0, 100) },
// new StatsModel { Name = name_s[1], Count = new Random().Next(0, 100) },
// new StatsModel { Name = name_s[2], Count = new Random().Next(0, 100) },
// new StatsModel { Name = name_s[3], Count = new Random().Next(0, 100) },
// new StatsModel { Name = name_s[4], Count = new Random().Next(0, 100) },
// },
// SplitMeals_CreditCardCount_1 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_1 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_1 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_1 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

// SplitMeals_CreditCardCount_2 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_2 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_2 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_2 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

// SplitMeals_CreditCardCount_3 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_3 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_3 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_3 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

// SplitMeals_CreditCardCount_4 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_4 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_4 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_4 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

// SplitMeals_CreditCardCount_5 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_5 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_5 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_5 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

// SplitMeals_CreditCardCount_6 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_6 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_6 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_6 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },


//};
string message = JsonConvert.SerializeObject(sendScreenData); string message = JsonConvert.SerializeObject(sendScreenData);
mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.分餐机), message); mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.分餐机), message);
} }


+ 3
- 3
HKCardOUT/ViewModels/RootViewModel.cs View File

@@ -42,7 +42,7 @@ namespace HKCardOUT.ViewModels
ProcessCard(); ProcessCard();
InsertData(); InsertData();
DataCenter.InitQueeue(); DataCenter.InitQueeue();
DataCenter.CreateData();
new DataCenter().CreateData();
} }


/// <summary> /// <summary>
@@ -142,13 +142,13 @@ namespace HKCardOUT.ViewModels
Ad = new ObservableCollection<AdDTO>(Init); Ad = new ObservableCollection<AdDTO>(Init);
var route = SyncStatic.CreateFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AD.txt")); var route = SyncStatic.CreateFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AD.txt"));
SyncStatic.WriteFile(Encoding.UTF8.GetBytes(SyncStatic.Compress(Init.ToJson(), SecurityType.Base64)), route); SyncStatic.WriteFile(Encoding.UTF8.GetBytes(SyncStatic.Compress(Init.ToJson(), SecurityType.Base64)), route);
AdOpen();
//AdOpen();
} }
else else
{ {
var jsons = SyncStatic.Decompress(SyncStatic.ReadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AD.txt")), SecurityType.Base64); var jsons = SyncStatic.Decompress(SyncStatic.ReadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AD.txt")), SecurityType.Base64);
Ad = new ObservableCollection<AdDTO>(jsons.ToModel<List<AdDTO>>()); Ad = new ObservableCollection<AdDTO>(jsons.ToModel<List<AdDTO>>());
AdOpen();
//AdOpen();
} }
})); }));




+ 3
- 3
HKCardOUT/options.pro.json View File

@@ -6,8 +6,8 @@
"StartDevice": true, "StartDevice": true,
//串口 //串口
"COM": "COM7", "COM": "COM7",
//定时任务时间表达式 每隔6小时推送一次
"Cron": "0 0 0/6 * * ?",
//定时任务时间表达式 每隔20分钟同步一次
"Cron": "0 0/20 * * * ?",
//店铺ID //店铺ID
"StoreId": "0c32b2e2-0dc9-4941-b73d-3dc91f7268ab", "StoreId": "0c32b2e2-0dc9-4941-b73d-3dc91f7268ab",
//加盟商Id //加盟商Id
@@ -27,7 +27,7 @@
//MQTT //MQTT
"MQTT": "171.221.208.23,11883,admin,public1", "MQTT": "171.221.208.23,11883,admin,public1",
//超级卡 //超级卡
"Admin": [ 6666666666666666666, 8888888888888888888, 9999999999999999999, 1590198360768385024, 1590198442460844032 ],
"Admin": [6666666666666666666,8888888888888888888,9999999999999999999,1590198360768385024,1590198442460844032],
//刷卡间隔 //刷卡间隔
"Span": 5 "Span": 5
} }

Loading…
Cancel
Save