Browse Source

测试

Lishi
xxe 2 years ago
parent
commit
367c8fc1f1
5 changed files with 57 additions and 4 deletions
  1. +1
    -0
      HKCardOUT/Bootstrapper.cs
  2. +2
    -0
      HKCardOUT/HKCardOUT.csproj
  3. +1
    -0
      HKCardOUT/Helper/DataBus.cs
  4. +52
    -4
      HKCardOUT/ViewModels/RootViewModel.cs
  5. +1
    -0
      HKCardOUT/options.json

+ 1
- 0
HKCardOUT/Bootstrapper.cs View File

@@ -39,6 +39,7 @@ namespace HKCardOUT
DataBus.Cron = configer["Cron"]; DataBus.Cron = configer["Cron"];
DataBus.SaasRoute = configer["SaasRoute"]; DataBus.SaasRoute = configer["SaasRoute"];
DataBus.StoreId = configer["StoreId"]; DataBus.StoreId = configer["StoreId"];
DataBus.COM = configer["COM"];
DbContext.InitTable(); DbContext.InitTable();
RemoteService.PullShopInfo(); RemoteService.PullShopInfo();
base.Configure(); base.Configure();


+ 2
- 0
HKCardOUT/HKCardOUT.csproj View File

@@ -51,5 +51,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\HKControl\HKControl.csproj" /> <ProjectReference Include="..\HKControl\HKControl.csproj" />
<ProjectReference Include="..\HKLog\HKLog.csproj" /> <ProjectReference Include="..\HKLog\HKLog.csproj" />
<ProjectReference Include="..\UHFHelper\UHFHelper.csproj" />
</ItemGroup> </ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
</Project> </Project>

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

@@ -27,6 +27,7 @@ namespace HKCardOUT.Helper
public static bool NetWordState { get; set; } = false; public static bool NetWordState { get; set; } = false;
public static string Cron { get; set; } public static string Cron { get; set; }
public static string StoreId { get; set; } public static string StoreId { get; set; }
public static string COM { get; set; }
public static string SaasRoute { get; set; } public static string SaasRoute { get; set; }
public static StoreInfoResponse StoreInfo { get; set; } public static StoreInfoResponse StoreInfo { get; set; }
public static Dictionary<string, AdWindow> AdStatus { get; set; } = new Dictionary<string, AdWindow>(); public static Dictionary<string, AdWindow> AdStatus { get; set; } = new Dictionary<string, AdWindow>();


+ 52
- 4
HKCardOUT/ViewModels/RootViewModel.cs View File

@@ -1,21 +1,25 @@
using DTO; using DTO;
using HKCardOUT.Helper; using HKCardOUT.Helper;
using HKCardOUT.Logic;
using HKCardOUT.Logic.Model; using HKCardOUT.Logic.Model;
using HKCardOUT.Logic.Service; using HKCardOUT.Logic.Service;
using Stylet; using Stylet;
using StyletIoC; using StyletIoC;
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Windows.Documents; using System.Windows.Documents;
using UHFHelper;
using XExten.Advance.CacheFramework;
using XExten.Advance.CacheFramework.RunTimeCache;
using XExten.Advance.LinqFramework;


namespace HKCardOUT.ViewModels namespace HKCardOUT.ViewModels
{ {
public class RootViewModel : Conductor<IScreen> public class RootViewModel : Conductor<IScreen>
{ {
public delegate void ReadCardFunc(DKoutput? input);
public event ReadCardFunc ReadFunc;
IContainer Container; IContainer Container;
public RootViewModel(IContainer Container) public RootViewModel(IContainer Container)
{ {
@@ -35,8 +39,8 @@ namespace HKCardOUT.ViewModels
{ {
Ad = x.Remaek, Ad = x.Remaek,
IsActive = false, IsActive = false,
Device =t.Name,
Stalls=x.Name
Device = t.Name,
Stalls = x.Name
}).ToList(); }).ToList();
if (Init != null) if (Init != null)
Ad = new ObservableCollection<AdDTO>(Init); Ad = new ObservableCollection<AdDTO>(Init);
@@ -60,6 +64,8 @@ namespace HKCardOUT.ViewModels
#region 方法 #region 方法
private void MainThread() private void MainThread()
{ {
ReadFunc -= ReadCard;
ReadFunc += ReadCard;
ThreadManage.GetInstance().StartLong(new Action(() => ThreadManage.GetInstance().StartLong(new Action(() =>
{ {
try try
@@ -79,6 +85,34 @@ namespace HKCardOUT.ViewModels
HandyControl.Controls.Growl.InfoGlobal(ex.Message); HandyControl.Controls.Growl.InfoGlobal(ex.Message);
} }
}), "循环状态监测线程", false); }), "循环状态监测线程", false);
// 初始化 串口
UHF_RS485_Helper.GetInstance().Open(new SerialParam
{
PortName = DataBus.COM,
BaudRate = 57600,
DataBits = 8
});

if (!UHF_RS485_Helper.GetInstance().GetSerialPortState())
HandyControl.Controls.Growl.InfoGlobal("串口打开失败");
//读取读卡器
ThreadManage.GetInstance().StartLong(new Action(() =>
{
DataBus.StoreInfo.Devices.ForEach(async item =>
{
if (UHF_RS485_Helper.GetInstance().GetSerialPortState())
{
HandyControl.Controls.Growl.InfoGlobal("串口未链接");
}
else
{
var x = await UHF_RS485_Helper.GetInstance().ReadCard(item.Address.AsInt());
if (x != null)
ReadFunc?.Invoke(x);
}
});
Thread.Sleep(300);
}), "循环读取卡片内容", false);
} }
#endregion #endregion


@@ -112,6 +146,20 @@ namespace HKCardOUT.ViewModels
} }
} }
} }
public void ReadCard(DKoutput input)
{
var key = input.Address + ":" + input.ResData;
//没有超时第一是刷
if (Caches.RunTimeCacheGet<DKoutput>(key) == null)
{
Container.Get<HKCore>().DeviceSale(new SaleLog
{
CardNo = input.ResData.Substring(1, input.ResData.Length),
Location = input.Address.AsInt().ToString()
});
Caches.RunTimeCacheSet(key, input, 10, true);
}
}
#endregion #endregion
} }
} }

+ 1
- 0
HKCardOUT/options.json View File

@@ -1,6 +1,7 @@
{ {
//服务地址 //服务地址
"SaasRoute": "https://bpa.black-pa.com:21527/kitchen/", "SaasRoute": "https://bpa.black-pa.com:21527/kitchen/",
"COM": "COM5",
//定时任务时间表达式 //定时任务时间表达式
"Cron": "0 0 11,15 * * ? ", "Cron": "0 0 11,15 * * ? ",
//店铺ID //店铺ID


Loading…
Cancel
Save