|
- using BPA.Communication;
- using BPA.Helper;
- using BPA.Message.Enum;
- using BPA.Message;
- using DTO;
- using HKCardOUT.Logic.Model;
- using HKCardOUT.Views;
- using HKLib.Dto;
- using Logic.RemoteModel;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Globalization;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Data;
- using System.Xml.Linq;
- using XExten.Advance.StaticFramework;
- using static System.Net.Mime.MediaTypeNames;
-
- namespace HKCardOUT.Helper
- {
- public class DataBus
- {
- private static string _ConnectionString;
- public static string ConnectionString
- {
- get => _ConnectionString;
- set
- {
- var Route = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DATA");
- _ConnectionString = $"DataSource={SyncStatic.CreateFile(Path.Combine(SyncStatic.CreateDir(Route), value))}";
- }
- }
- public static bool NetWordState { get; set; } = false;
- public static string Cron { get; set; }
- public static bool StartDevice { get; set; }
- public static bool Cancel { get; set; }
- public static string StoreId { get; set; }
- public static string TenantId { get; set; }
- public static string COM { get; set; }
- public static string SaasRoute { get; set; }
- public static int Span { get; set; }
- public static int Count { get; set; }
- public static string MQTT { get; set; }
- public static List<string> Admin { get; set; }
- public static TimeSpilte Times { get; set; }
- public static StoreInfoResponse StoreInfo { get; set; }
- public static Dictionary<string, AdWindow> AdStatus { get; set; } = new Dictionary<string, AdWindow>();
- public static List<UserListDto> UserListDto { get; set; }
- public static ConcurrentQueue<SaleLogDto> saleLogDtos { get; set; }
-
- public static ConcurrentDictionary<string, ConcurrentQueue<SaleLogDto>> SaleLogDtoList { get; set; } = new ConcurrentDictionary<string, ConcurrentQueue<SaleLogDto>>();
-
- public static ConcurrentQueue<SaleLog> Entitys { get; set; }
- public static FoodDto Menu { get; set; }
- public static List<GateSetUp> RangeCtrl { get; set; }
- }
- public class ApiRoute
- {
- public static string GetTime = DataBus.SaasRoute + "api/one-card/eat-time-interval";
- /// <summary>
- /// 获取所有卡
- /// </summary>
- public static string CheckCardStatus = DataBus.SaasRoute + "api/one-card/card-list";
- /// <summary>
- /// 同步消费记录
- /// </summary>
- public static string SyncSaleLog = DataBus.SaasRoute + "api/member-helper/memberconsumptionorrecharge";
- /// <summary>
- /// 批量消费记录
- /// </summary>
- public static string SyncSaleLogList = DataBus.SaasRoute + "api/member-helper/memberconsumptionorrechargelist";
- /// <summary>
- /// 获取店铺信息
- /// </summary>
- public static string PullShopInfo = DataBus.SaasRoute + $"api/StoreHelper/GeBasisGateList?StoreId={DataBus.StoreId}";
- /// <summary>
- /// 区域控制
- /// </summary>
- public static string RangCtrl = DataBus.SaasRoute + $"api/StoreHelper/GetBasisGateSetUp?StoreId={DataBus.StoreId}";
- /// <summary>
- /// 菜品数据
- /// </summary>
- public static string FoodCtrl = DataBus.SaasRoute + $"api/StoreHelper/GetBasisGateFoodList?StoreId={DataBus.StoreId}";
- }
- public class HKConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return (bool)value ? "启用" : "禁用";
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value;
- }
- }
- public class MemoryBus
- {
- public static List<CardStutas> CardStatus { get; set; } = new List<CardStutas>();
- public static List<SaleLog> CardRecord { get; set; } = new List<SaleLog>();
- }
-
- public static class MQTTCon
- {
- static MqttHelper mqttHelper;
- static MQTTCon()
- {
- mqttHelper = new MqttHelper();
- }
- /// <summary>
- /// Mqtt是否运行
- /// </summary>
- static bool IsRunningMqtt = false;
- public static void Connection()
- {
- try
- {
- //2.Mqtt连接
- if (!string.IsNullOrEmpty(DataBus.MQTT) && DataBus.MQTT.Contains(','))
- {
- string[] mqttcom = DataBus.MQTT.Split(',');
- if (mqttcom != null && mqttcom.Count() == 4)
- {
- mqttHelper.Connect(mqttcom[2], mqttcom[3], mqttcom[0], int.Parse(mqttcom[1]), $"分餐机{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
- }
- }
- mqttHelper.Disconnect = new Action(() =>
- {
- IsRunningMqtt = false;
- MessageLog.GetInstance.ShowEx($"分餐机MQTT异常断开....");
- });
- mqttHelper.ConnectOk = new Action(() =>
- {
- IsRunningMqtt = true;//连接成功
- });
- }
- catch (Exception ex)
- {
- MessageLog.GetInstance.ShowEx($"分餐机初始化连接 MQTT,原因:{ex.Message}");
- }
-
- }
-
- public static void Send(ScreenModelSplitMeals screenModel)
- {
- SendScreenDataModel sendScreenData = new SendScreenDataModel();
- sendScreenData.Name = ScreenDeviceType.分餐机;
- 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);
- mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.分餐机), message);
- }
- }
- }
|