xxe 2 år sedan
förälder
incheckning
367c8fc1f1
5 ändrade filer med 57 tillägg och 4 borttagningar
  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 Visa fil

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


+ 2
- 0
HKCardOUT/HKCardOUT.csproj Visa fil

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

+ 1
- 0
HKCardOUT/Helper/DataBus.cs Visa fil

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


+ 52
- 4
HKCardOUT/ViewModels/RootViewModel.cs Visa fil

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

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

@@ -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
}
}

+ 1
- 0
HKCardOUT/options.json Visa fil

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


Laddar…
Avbryt
Spara