diff --git a/HKCardOUT/CardHandle.cs b/HKCardOUT/CardHandle.cs index 494f874..3fa5cdc 100644 --- a/HKCardOUT/CardHandle.cs +++ b/HKCardOUT/CardHandle.cs @@ -1,6 +1,7 @@ using HKCardOUT.Helper; using HKCardOUT.Logic; using HKCardOUT.Logic.Model; +using HKCardOUT.Logic.Service; using HKLib.Dto; using HKLib.RabbitMQ.Config; using System; @@ -18,6 +19,7 @@ namespace HKCardOUT DbContext.Context.Updateable().SetColumns(t => t.Stutas == dto.Stutas).Where(t => t.CardNo == dto.CardNo).ExecuteCommand(); + new HKCore().GetAllCardStatus(); } } public class TimeHandle : IAccept diff --git a/HKCardOUT/Helper/DataBus.cs b/HKCardOUT/Helper/DataBus.cs index 2cad0be..757b17f 100644 --- a/HKCardOUT/Helper/DataBus.cs +++ b/HKCardOUT/Helper/DataBus.cs @@ -91,4 +91,9 @@ namespace HKCardOUT.Helper return value; } } + public class MemoryBus + { + public static List CardStatus { get; set; } = new List(); + public static List CardRecord { get; set; } = new List(); + } } diff --git a/HKCardOUT/Logic/Service/HKCore.cs b/HKCardOUT/Logic/Service/HKCore.cs index 0f378de..024315d 100644 --- a/HKCardOUT/Logic/Service/HKCore.cs +++ b/HKCardOUT/Logic/Service/HKCore.cs @@ -2,6 +2,7 @@ using HKCardOUT.Helper; using HKCardOUT.Logic.Model; using HKControl; +using HKLib.Dto; using HKLog; using System; using System.Collections.Generic; @@ -16,6 +17,13 @@ namespace HKCardOUT.Logic.Service { public class HKCore { + public void GetRecrod() + { + MemoryBus.CardRecord = DbContext.Context.Queryable() + .Where(t => t.CreateTime.Year == DateTime.Now.Year) + .Where(t => t.CreateTime.Month == DateTime.Now.Month) + .Where(t => t.CreateTime.Day == DateTime.Now.Day).ToList(); + } List Commom(SaleLog input) { if (DataBus.StartDevice) @@ -25,7 +33,7 @@ namespace HKCardOUT.Logic.Service HKLogImport.WriteInfo("设备出餐状态:" + checkDevice); if (checkDevice) return null; } - var Old = DbContext.Context.Queryable() + var Old = MemoryBus.CardRecord .Where(t => t.CardNo == input.CardNo) .Where(t => t.CreateTime.Year == DateTime.Now.Year) .Where(t => t.CreateTime.Month == DateTime.Now.Month) @@ -45,11 +53,19 @@ namespace HKCardOUT.Logic.Service bool GetCardStutas(string CardNo) { - var data = DbContext.Context.Queryable().First(t => t.CardNo == CardNo); + var data = MemoryBus.CardStatus.First(t => t.CardNo == CardNo); if (data == null) return false; if (data.Stutas != 1) return false; return true; } + + /// + /// 获取所有的卡状态 + /// + public void GetAllCardStatus() + { + MemoryBus.CardStatus = DbContext.Context.Queryable().ToList(); + } public static void AddCard(List input) { var temp = DbContext.Context.Queryable().Where(t => input.Select(m => m.CardNo).Contains(t.CardNo)).Distinct().ToList(); @@ -292,6 +308,7 @@ namespace HKCardOUT.Logic.Service entity.State = true; HKLogImport.WriteInfo("正在写入数据库,当前数据:" + entity.ToJson()); DbContext.Context.Insertable(entity).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); + GetRecrod(); } } } diff --git a/HKCardOUT/ViewModels/RootViewModel.cs b/HKCardOUT/ViewModels/RootViewModel.cs index 5fa04fa..1bd5026 100644 --- a/HKCardOUT/ViewModels/RootViewModel.cs +++ b/HKCardOUT/ViewModels/RootViewModel.cs @@ -35,6 +35,9 @@ namespace HKCardOUT.ViewModels this.Container = Container; this.Activated += RootViewModel_Activated; this.Closed += RootViewModel_Closed; + var serv = Container.Get(); + serv.GetAllCardStatus(); + serv.GetRecrod(); ProcessCard(); InsertData(); } @@ -216,7 +219,6 @@ namespace HKCardOUT.ViewModels Location = input.Address.AsInt().ToString(), Date = DateTime.Now }; - UHF_RS485_Helper.GetInstance().OpenBeep(mo.Location.AsInt()); HKLogImport.WriteInfo("读卡成功:" + mo.ToJson()); if (Stacks.Count > 0) {