Ver código fonte

测试

Lishi
xxe 2 anos atrás
pai
commit
1327d296e3
5 arquivos alterados com 64 adições e 45 exclusões
  1. +3
    -0
      HKCardOUT/Bootstrapper.cs
  2. +3
    -0
      HKCardOUT/Helper/DataBus.cs
  3. +25
    -20
      HKCardOUT/Logic/Service/HKCore.cs
  4. +26
    -24
      HKCardOUT/ViewModels/RootViewModel.cs
  5. +7
    -1
      HKCardOUT/options.json

+ 3
- 0
HKCardOUT/Bootstrapper.cs Ver arquivo

@@ -42,6 +42,9 @@ namespace HKCardOUT
DataBus.StoreId = configer["StoreId"];
DataBus.COM = configer["COM"];
DataBus.IsTest = configer["IsTest"].AsBool();
DataBus.AM = configer["AM"];
DataBus.PM = configer["PM"];
DataBus.AT = configer["AT"];
DbContext.InitTable();
RemoteService.PullShopInfo();
base.Configure();


+ 3
- 0
HKCardOUT/Helper/DataBus.cs Ver arquivo

@@ -30,6 +30,9 @@ namespace HKCardOUT.Helper
public static string StoreId { get; set; }
public static string COM { get; set; }
public static string SaasRoute { get; set; }
public static string AM { get; set; }
public static string PM { get; set; }
public static string AT { get; set; }
public static StoreInfoResponse StoreInfo { get; set; }
public static Dictionary<string, AdWindow> AdStatus { get; set; } = new Dictionary<string, AdWindow>();
}


+ 25
- 20
HKCardOUT/Logic/Service/HKCore.cs Ver arquivo

@@ -22,26 +22,30 @@ namespace HKCardOUT.Logic.Service
{
try
{
if (RemoteService.CheckCardStuatas(input.CardNo) != 1) return false;
//if (RemoteService.CheckCardStuatas(input.CardNo) != 1) return false;
if (!DataBus.IsTest)
if (!Main.GetInstance.GetIsSwipe(input.Location.AsInt())) return false;
var Old = DbContext.Context.Queryable<SaleLog>()
.Where(t => t.CardNo == input.CardNo).OrderByDescending(t => t.CreateTime).First();
if (Old != null)
{
var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity();
if (entity.Id != Guid.Empty)
{
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location);
if (!DataBus.IsTest)
Main.GetInstance.Start(input.Location.AsInt());
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand();
return res;
}
return false;
}
else
var Old = DbContext.Context.Queryable<SaleLog>().Where(t => t.CardNo == input.CardNo).Where(t => t.CreateTime.Day == DateTime.Now.Day).ToList();
if (Old.Count > 3) return false;

var AM = DataBus.AM.Split(",").Select(t => t.AsInt()).ToList();
var PM = DataBus.PM.Split(",").Select(t => t.AsInt()).ToList();
var AT = DataBus.AT.Split(",").Select(t => t.AsInt()).ToList();

var condition1 = (DateTime.Now.Hour >= AM[0] && DateTime.Now.Hour < AM[1]);
var condition2 = (DateTime.Now.Hour >= PM[0] && DateTime.Now.Hour < PM[1]);
var condition3 = (DateTime.Now.Hour >= AT[0] && DateTime.Now.Hour < AT[1]);

if (condition1 || condition2 || condition1)
{
var AMDay = Old.Where(t => t.CreateTime.Hour >= AM[0] && t.CreateTime.Hour < AM[1]).Count();
if (AMDay > 0) return false;
var PMDay = Old.Where(t => t.CreateTime.Hour >= PM[0] && t.CreateTime.Hour < PM[1]).Count();
if (PMDay > 0) return false;
var ATDay = Old.Where(t => t.CreateTime.Hour >= AT[0] && t.CreateTime.Hour < AT[1]).Count();
if (ATDay > 0) return false;


var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity();
if (entity.Id != Guid.Empty)
{
@@ -51,16 +55,17 @@ namespace HKCardOUT.Logic.Service
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand();
return res;
}
return false;
}
else return false;

}
else return false;
}
catch (Exception ex)
{
HKLog.HKLogImport.WriteError(ex);
return false;
}
}
/// <summary>
/// 获取当天消费前100条展示


+ 26
- 24
HKCardOUT/ViewModels/RootViewModel.cs Ver arquivo

@@ -2,11 +2,14 @@
using HKCardOUT.Helper;
using HKCardOUT.Logic.Model;
using HKCardOUT.Logic.Service;
using NStandard;
using SqlSugar.DistributedSystem.Snowflake;
using Stylet;
using StyletIoC;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Documents;
using UHFHelper;
@@ -21,7 +24,7 @@ namespace HKCardOUT.ViewModels
public delegate void ReadCardFunc(DKoutput? input);
public event ReadCardFunc ReadFunc;
private readonly object locker = new object();
IContainer Container;
private IContainer Container;
public RootViewModel(IContainer Container)
{
this.Container = Container;
@@ -30,11 +33,13 @@ namespace HKCardOUT.ViewModels

protected override void OnViewLoaded()
{
ThreadManage.GetInstance().Start(() =>
System.Timers.Timer timer = new System.Timers.Timer(500);
timer.Enabled = true;
timer.Elapsed += (s, e) =>
{
Result = new ObservableCollection<SaleLog>(this.Container.Get<HKCore>().PullDaySaleLog());
Thread.Sleep(500);
}, "消费记录查询");
};
timer.Start();
//广告初始化
var Init = DataBus.StoreInfo?.Devices.Join(DataBus.StoreInfo?.Stalls, t => t.GateId, x => x.Id, (t, x) => new AdDTO
{
@@ -102,22 +107,26 @@ namespace HKCardOUT.ViewModels
}
if (!UHF_RS485_Helper.GetInstance().GetSerialPortState())
HandyControl.Controls.Growl.InfoGlobal("串口打开失败");
//读取读卡器
ThreadManage.GetInstance().StartLong(new Action(() =>
DataBus.StoreInfo.Devices.ForEach(item =>
{
DataBus.StoreInfo.Devices.ForEach(async item =>
System.Timers.Timer timer = new System.Timers.Timer(500);
timer.Enabled = true;
timer.Elapsed += (sender, eve) =>
{
if (!UHF_RS485_Helper.GetInstance().GetSerialPortState())
return;
else
{
var x = await UHF_RS485_Helper.GetInstance().ReadCard(item.Address.AsInt());
if (x != null)
ReadFunc?.Invoke(x);
var res = UHF_RS485_Helper.GetInstance().ReadCard(item.Address.AsInt()).Result;
if (res != null)
{
if (!res.ResData.IsMatch(new Regex("0{20}")))
ReadFunc?.Invoke(res);
}
}
});
Thread.Sleep(500);
}), "循环读取卡片内容", false);
};
timer.Start();
});
}
#endregion

@@ -155,18 +164,11 @@ namespace HKCardOUT.ViewModels
{
lock (locker)
{
var key = input.Address + ":" + input.ResData;
//没有超时第一是刷
if (Caches.RunTimeCacheGet<DKoutput>(key) == null)
Container.Get<HKCore>().DeviceSale(new SaleLog
{
Caches.RunTimeCacheSet(key, input, 10, true);
Container.Get<HKCore>().DeviceSale(new SaleLog
{
CardNo = input.ResData.Substring(1, input.ResData.Length - 1),
Location = input.Address.AsInt().ToString()

});
}
CardNo = input.ResData.Substring(1, input.ResData.Length - 1),
Location = input.Address.AsInt().ToString()
});
}
}
#endregion


+ 7
- 1
HKCardOUT/options.json Ver arquivo

@@ -9,5 +9,11 @@
"StoreId": "a19535e8-119f-4b10-a011-6288fd3ddb37",
"ConnectionStrings": {
"Sqlite": "HKSQL.db3"
}
},
//早上
"AM": "6,11",
//中午
"PM": "11,14",
//下午
"AT": "17,20"
}

Carregando…
Cancelar
Salvar