xxe 2 yıl önce
ebeveyn
işleme
a4f49da089
2 değiştirilmiş dosya ile 131 ekleme ve 44 silme
  1. +104
    -29
      HKCardOUT/Logic/Service/HKCore.cs
  2. +27
    -15
      HKCardOUT/ViewModels/RootViewModel.cs

+ 104
- 29
HKCardOUT/Logic/Service/HKCore.cs Dosyayı Görüntüle

@@ -13,55 +13,91 @@ namespace HKCardOUT.Logic.Service
{
public class HKCore
{
List<SaleLog> Commom(SaleLog input)
{
if (!DataBus.IsTest)
if (!Main.GetInstance.GetIsSwipe(input.Location.AsInt())) return null;
var Old = DbContext.Context.Queryable<SaleLog>()
.Where(t => t.CardNo == input.CardNo)
.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();
if (Old.Count > 3) return null;
return Old;
}
/// <summary>
/// 刷卡消费
/// 早上消费
/// </summary>
/// <param name="input"></param>
/// <param name="Old"></param>
/// <returns></returns>
public bool DeviceSale(SaleLog input)
public bool DeviceSaleAM(SaleLog input)
{
try
{
//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).Where(t => t.CreateTime.Day == DateTime.Now.Day).ToList();
if (Old.Count > 3) return false;

var Old = Commom(input);
if (Old == null) 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 AMDay = Old.Where(t => t.CreateTime.Hour >= AM[0] && t.CreateTime.Hour < AM[1])
.Where(t => t.CreateTime.Year == DateTime.Now.Year)
.Where(t => t.CreateTime.Month == DateTime.Now.Month)
.Where(t => t.CreateTime.Day == DateTime.Now.Day)
.Count();
HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}上午消费次数:{AMDay}");

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]);
HKLog.HKLogImport.WriteInfo($"当前刷卡时间_条件1:{condition1}_条件2:{condition2}_条件3:{condition3}");
if (condition1 || condition2 || condition3)
if (AMDay < 1)
{
var AMDay = Old.Where(t => t.CreateTime.Hour >= AM[0] && t.CreateTime.Hour < AM[1]).Count();
HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}上午消费次数:{AMDay}");
var PMDay = Old.Where(t => t.CreateTime.Hour >= PM[0] && t.CreateTime.Hour < PM[1]).Count();
HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}中午消费次数:{AMDay}");
var ATDay = Old.Where(t => t.CreateTime.Hour >= AT[0] && t.CreateTime.Hour < AT[1]).Count();
HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}下午消费次数:{AMDay}");
if (AMDay + PMDay + ATDay >= 3) return false;


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;
}
else return false;
}
return false;
}
catch (Exception ex)
{
HKLog.HKLogImport.WriteError(ex);
return false;
}

}
/// <summary>
/// 中午消费
/// </summary>
/// <param name="input"></param>
/// <param name="Old"></param>
/// <returns></returns>
public bool DeviceSalePM(SaleLog input)
{
try
{
var Old = Commom(input);
if (Old == null) return false;
var PM = DataBus.PM.Split(",").Select(t => t.AsInt()).ToList();
var PMDay = Old.Where(t => t.CreateTime.Hour >= PM[0] && t.CreateTime.Hour < PM[1]).
Where(t => t.CreateTime.Year == DateTime.Now.Year)
.Where(t => t.CreateTime.Month == DateTime.Now.Month)
.Where(t => t.CreateTime.Day == DateTime.Now.Day)
.Count();
HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}中午消费次数:{PMDay}");
if (PMDay < 1)
{
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;
}
}
else return false;
return false;
}
catch (Exception ex)
{
@@ -71,6 +107,45 @@ namespace HKCardOUT.Logic.Service

}
/// <summary>
/// 晚上
/// </summary>
/// <param name="input"></param>
/// <param name="Old"></param>
/// <returns></returns>
public bool DeviceSaleAT(SaleLog input)
{
try
{
var Old = Commom(input);
if (Old == null) return false;
var AT = DataBus.AT.Split(",").Select(t => t.AsInt()).ToList();
var ATDay = Old.Where(t => t.CreateTime.Hour >= AT[0] && t.CreateTime.Hour < AT[1])
.Where(t => t.CreateTime.Year == DateTime.Now.Year)
.Where(t => t.CreateTime.Month == DateTime.Now.Month)
.Where(t => t.CreateTime.Day == DateTime.Now.Day)
.Count();
HKLog.HKLogImport.WriteInfo($"卡号{input.CardNo}下午消费次数:{ATDay}");
if (ATDay < 1)
{
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;
}
catch (Exception ex)
{
HKLog.HKLogImport.WriteError(ex);
return false;
}
}
/// <summary>
/// 获取当天消费前100条展示
/// </summary>
/// <returns></returns>
@@ -86,7 +161,7 @@ namespace HKCardOUT.Logic.Service
{
CardNo = t.Key,
Location = String.Join(",", t.Select(m => m.Location)),
Count =t.Count()
Count = t.Count()
}).ToList();
}
}


+ 27
- 15
HKCardOUT/ViewModels/RootViewModel.cs Dosyayı Görüntüle

@@ -3,26 +3,15 @@ using HKCardOUT.Helper;
using HKCardOUT.Logic.Model;
using HKCardOUT.Logic.Service;
using HKCardOUT.Views;
using ImTools;
using NStandard;
using S7.Net.Types;
using SqlSugar.DistributedSystem.Snowflake;
using Stylet;
using StyletIoC;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Forms;
using UHFHelper;
using XExten.Advance.CacheFramework;
using XExten.Advance.CacheFramework.RunTimeCache;
using XExten.Advance.LinqFramework;

namespace HKCardOUT.ViewModels
@@ -243,11 +232,34 @@ namespace HKCardOUT.ViewModels
{
lock (locker)
{
Container.Get<HKCore>().DeviceSale(new SaleLog
var Core = Container.Get<HKCore>();
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();
if (DateTime.Now.Hour >= AM[0] && DateTime.Now.Hour < AM[1])
{
CardNo = input.ResData.Substring(1, input.ResData.Length - 1),
Location = input.Address.AsInt().ToString()
});
Core.DeviceSaleAM(new SaleLog
{
CardNo = input.ResData.Substring(1, input.ResData.Length - 1),
Location = input.Address.AsInt().ToString()
});
}
if (DateTime.Now.Hour >= PM[0] && DateTime.Now.Hour < PM[1])
{
Core.DeviceSalePM(new SaleLog
{
CardNo = input.ResData.Substring(1, input.ResData.Length - 1),
Location = input.Address.AsInt().ToString()
});
}
if (DateTime.Now.Hour >= AT[0] && DateTime.Now.Hour < AT[1])
{
Core.DeviceSaleAT(new SaleLog
{
CardNo = input.ResData.Substring(1, input.ResData.Length - 1),
Location = input.Address.AsInt().ToString()
});
}
Result = new ObservableCollection<SaleLog>(this.Container.Get<HKCore>().PullDaySaleLog());
}
}


Yükleniyor…
İptal
Kaydet