Browse Source

内存读取

Lishi
xxe 2 years ago
parent
commit
5f590094d6
4 changed files with 29 additions and 3 deletions
  1. +2
    -0
      HKCardOUT/CardHandle.cs
  2. +5
    -0
      HKCardOUT/Helper/DataBus.cs
  3. +19
    -2
      HKCardOUT/Logic/Service/HKCore.cs
  4. +3
    -1
      HKCardOUT/ViewModels/RootViewModel.cs

+ 2
- 0
HKCardOUT/CardHandle.cs View File

@@ -1,6 +1,7 @@
using HKCardOUT.Helper; using HKCardOUT.Helper;
using HKCardOUT.Logic; using HKCardOUT.Logic;
using HKCardOUT.Logic.Model; using HKCardOUT.Logic.Model;
using HKCardOUT.Logic.Service;
using HKLib.Dto; using HKLib.Dto;
using HKLib.RabbitMQ.Config; using HKLib.RabbitMQ.Config;
using System; using System;
@@ -18,6 +19,7 @@ namespace HKCardOUT


DbContext.Context.Updateable<CardStutas>().SetColumns(t => t.Stutas == dto.Stutas).Where(t => t.CardNo == dto.CardNo).ExecuteCommand(); DbContext.Context.Updateable<CardStutas>().SetColumns(t => t.Stutas == dto.Stutas).Where(t => t.CardNo == dto.CardNo).ExecuteCommand();


new HKCore().GetAllCardStatus();
} }
} }
public class TimeHandle : IAccept public class TimeHandle : IAccept


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

@@ -91,4 +91,9 @@ namespace HKCardOUT.Helper
return value; 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>();
}
} }

+ 19
- 2
HKCardOUT/Logic/Service/HKCore.cs View File

@@ -2,6 +2,7 @@
using HKCardOUT.Helper; using HKCardOUT.Helper;
using HKCardOUT.Logic.Model; using HKCardOUT.Logic.Model;
using HKControl; using HKControl;
using HKLib.Dto;
using HKLog; using HKLog;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -16,6 +17,13 @@ namespace HKCardOUT.Logic.Service
{ {
public class HKCore public class HKCore
{ {
public void GetRecrod()
{
MemoryBus.CardRecord = DbContext.Context.Queryable<SaleLog>()
.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<SaleLog> Commom(SaleLog input) List<SaleLog> Commom(SaleLog input)
{ {
if (DataBus.StartDevice) if (DataBus.StartDevice)
@@ -25,7 +33,7 @@ namespace HKCardOUT.Logic.Service
HKLogImport.WriteInfo("设备出餐状态:" + checkDevice); HKLogImport.WriteInfo("设备出餐状态:" + checkDevice);
if (checkDevice) return null; if (checkDevice) return null;
} }
var Old = DbContext.Context.Queryable<SaleLog>()
var Old = MemoryBus.CardRecord
.Where(t => t.CardNo == input.CardNo) .Where(t => t.CardNo == input.CardNo)
.Where(t => t.CreateTime.Year == DateTime.Now.Year) .Where(t => t.CreateTime.Year == DateTime.Now.Year)
.Where(t => t.CreateTime.Month == DateTime.Now.Month) .Where(t => t.CreateTime.Month == DateTime.Now.Month)
@@ -45,11 +53,19 @@ namespace HKCardOUT.Logic.Service


bool GetCardStutas(string CardNo) bool GetCardStutas(string CardNo)
{ {
var data = DbContext.Context.Queryable<CardStutas>().First(t => t.CardNo == CardNo);
var data = MemoryBus.CardStatus.First(t => t.CardNo == CardNo);
if (data == null) return false; if (data == null) return false;
if (data.Stutas != 1) return false; if (data.Stutas != 1) return false;
return true; return true;
} }

/// <summary>
/// 获取所有的卡状态
/// </summary>
public void GetAllCardStatus()
{
MemoryBus.CardStatus = DbContext.Context.Queryable<CardStutas>().ToList();
}
public static void AddCard(List<CardStutas> input) public static void AddCard(List<CardStutas> input)
{ {
var temp = DbContext.Context.Queryable<CardStutas>().Where(t => input.Select(m => m.CardNo).Contains(t.CardNo)).Distinct().ToList(); var temp = DbContext.Context.Queryable<CardStutas>().Where(t => input.Select(m => m.CardNo).Contains(t.CardNo)).Distinct().ToList();
@@ -292,6 +308,7 @@ namespace HKCardOUT.Logic.Service
entity.State = true; entity.State = true;
HKLogImport.WriteInfo("正在写入数据库,当前数据:" + entity.ToJson()); HKLogImport.WriteInfo("正在写入数据库,当前数据:" + entity.ToJson());
DbContext.Context.Insertable(entity).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); DbContext.Context.Insertable(entity).CallEntityMethod(t => t.Create()).ExecuteReturnEntity();
GetRecrod();
} }
} }
} }


+ 3
- 1
HKCardOUT/ViewModels/RootViewModel.cs View File

@@ -35,6 +35,9 @@ namespace HKCardOUT.ViewModels
this.Container = Container; this.Container = Container;
this.Activated += RootViewModel_Activated; this.Activated += RootViewModel_Activated;
this.Closed += RootViewModel_Closed; this.Closed += RootViewModel_Closed;
var serv = Container.Get<HKCore>();
serv.GetAllCardStatus();
serv.GetRecrod();
ProcessCard(); ProcessCard();
InsertData(); InsertData();
} }
@@ -216,7 +219,6 @@ namespace HKCardOUT.ViewModels
Location = input.Address.AsInt().ToString(), Location = input.Address.AsInt().ToString(),
Date = DateTime.Now Date = DateTime.Now
}; };
UHF_RS485_Helper.GetInstance().OpenBeep(mo.Location.AsInt());
HKLogImport.WriteInfo("读卡成功:" + mo.ToJson()); HKLogImport.WriteInfo("读卡成功:" + mo.ToJson());
if (Stacks.Count > 0) if (Stacks.Count > 0)
{ {


Loading…
Cancel
Save