From 5cab8d7d23f52629feb41879557c692e0ef3a85a Mon Sep 17 00:00:00 2001 From: xxe Date: Wed, 12 Oct 2022 17:25:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HKCardOUT/Bootstrapper.cs | 5 ++--- HKCardOUT/HKCardOUT.csproj | 4 ++-- HKCardOUT/Helper/DataBus.cs | 5 ++--- HKCardOUT/Logic/Model/CardStutas.cs | 5 ++--- HKCardOUT/Logic/RemoteService.cs | 18 +++++++++++++++++- HKCardOUT/Logic/Service/HKCore.cs | 25 +++++++++++++++++-------- HKCardOUT/MqHandle.cs | 2 +- HKCardOUT/ViewModels/RootViewModel.cs | 12 ++++++------ HKCardOUT/options.json | 6 ------ HKLib/Dto/CardStutasDto.cs | 4 ++++ HKLib/Interfaces/HKLibHelper.cs | 9 ++++++--- HKLib/RabbitMq/Config/MQFactory.cs | 1 - 12 files changed, 59 insertions(+), 37 deletions(-) diff --git a/HKCardOUT/Bootstrapper.cs b/HKCardOUT/Bootstrapper.cs index a74312f..b7abcaf 100644 --- a/HKCardOUT/Bootstrapper.cs +++ b/HKCardOUT/Bootstrapper.cs @@ -65,12 +65,11 @@ namespace HKCardOUT DataBus.COM = configer["COM"]; DataBus.StartDevice = configer["StartDevice"].AsBool(); DataBus.Cancel = configer["Cancel"].AsBool(); - DataBus.AM = configer["AM"]; - DataBus.PM = configer["PM"]; DataBus.Count = configer["Count"].AsInt(); - DataBus.AT = configer["AT"]; HKLib.Configer.SaasRoute = DataBus.SaasRoute; HKLib.Configer.MqAddress = configer["MQ"]; + + RemoteService.GetCardStuatas(); DbContext.InitTable(); RemoteService.PullShopInfo(); base.Configure(); diff --git a/HKCardOUT/HKCardOUT.csproj b/HKCardOUT/HKCardOUT.csproj index 02192a8..4172f6b 100644 --- a/HKCardOUT/HKCardOUT.csproj +++ b/HKCardOUT/HKCardOUT.csproj @@ -14,9 +14,9 @@ 1.0.0.0 AnyCPU;x86 - + TRACE;Core diff --git a/HKCardOUT/Helper/DataBus.cs b/HKCardOUT/Helper/DataBus.cs index d80d49d..cf27c96 100644 --- a/HKCardOUT/Helper/DataBus.cs +++ b/HKCardOUT/Helper/DataBus.cs @@ -1,4 +1,5 @@ using HKCardOUT.Views; +using HKLib.Dto; using Logic.RemoteModel; using System; using System.Collections.Generic; @@ -31,10 +32,8 @@ 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 int Count { get; set; } + public static TimeSpilte Times { get; set; } public static StoreInfoResponse StoreInfo { get; set; } public static Dictionary AdStatus { get; set; } = new Dictionary(); } diff --git a/HKCardOUT/Logic/Model/CardStutas.cs b/HKCardOUT/Logic/Model/CardStutas.cs index 0884c14..2ed7c0f 100644 --- a/HKCardOUT/Logic/Model/CardStutas.cs +++ b/HKCardOUT/Logic/Model/CardStutas.cs @@ -1,10 +1,9 @@ -using HKCardOUT.Logic; -using SqlSugar; +using SqlSugar; using System; using System.Collections.Generic; using System.Text; -namespace Logic.Model +namespace HKCardOUT.Logic.Model { [SugarTable("CardStutas")] public class CardStutas: BaseEntity diff --git a/HKCardOUT/Logic/RemoteService.cs b/HKCardOUT/Logic/RemoteService.cs index e3245cc..695cba3 100644 --- a/HKCardOUT/Logic/RemoteService.cs +++ b/HKCardOUT/Logic/RemoteService.cs @@ -1,4 +1,6 @@ using HKCardOUT.Helper; +using HKCardOUT.Logic.Model; +using HKCardOUT.Logic.Service; using Logic.RemoteModel; using Newtonsoft.Json.Linq; using System; @@ -22,15 +24,29 @@ namespace HKCardOUT.Logic /// 获取所有卡状态和卡号 /// /// - public static int CheckCardStuatas() + public static int GetCardStuatas() { var data = IHttpMultiClient.HttpMulti.AddNode(t => { t.NodePath = ApiRoute.CheckCardStatus; t.ReqType = MultiType.GET; }).Build().RunStringFirst().ToModel()["data"]["cardState"]; + HKCore.AddCard(new CardStutas + { + + }); return data != null ? data.ToString().AsInt() : 0; } + + public static void SyncTime() + { + var data = IHttpMultiClient.HttpMulti.AddNode(t => + { + t.NodePath = ApiRoute.CheckCardStatus; + t.ReqType = MultiType.GET; + }).Build().RunStringFirst().ToModel()["data"]; + } + /// /// 同步消费记录 /// diff --git a/HKCardOUT/Logic/Service/HKCore.cs b/HKCardOUT/Logic/Service/HKCore.cs index b71a8a9..db8575f 100644 --- a/HKCardOUT/Logic/Service/HKCore.cs +++ b/HKCardOUT/Logic/Service/HKCore.cs @@ -2,7 +2,6 @@ using HKCardOUT.Helper; using HKCardOUT.Logic.Model; using HKControl; -using Logic.Model; using System; using System.Collections.Generic; using System.Linq; @@ -36,11 +35,15 @@ namespace HKCardOUT.Logic.Service if (data.Stutas != 1) return false; return true; } + public static void AddCard(CardStutas input) + { + DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand(); + } + /// /// 早上消费 /// /// - /// /// public bool DeviceSaleAM(SaleLog input) { @@ -49,8 +52,10 @@ namespace HKCardOUT.Logic.Service if(!GetCardStutas(input.CardNo)) return false; var Old = Commom(input); if (Old == null) return false; - var AM = DataBus.AM.Split(",").Select(t => t.AsInt()).ToList(); - var AMDay = Old.Where(t => t.CreateTime.Hour >= AM[0] && t.CreateTime.Hour < AM[1]) + var AM = DataBus.Times.AM.Split(","); + var S = DateTime.Parse(AM[0]); + var E = DateTime.Parse(AM[1]); + var AMDay = Old.Where(t => t.CreateTime >=S && t.CreateTime < E) .Where(t => t.CreateTime.Year == DateTime.Now.Year) .Where(t => t.CreateTime.Month == DateTime.Now.Month) .Where(t => t.CreateTime.Day == DateTime.Now.Day) @@ -110,8 +115,10 @@ namespace HKCardOUT.Logic.Service if (!GetCardStutas(input.CardNo)) return false; 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]). + var PM = DataBus.Times.PM.Split(","); + var S = DateTime.Parse(PM[0]); + var E = DateTime.Parse(PM[1]); + var PMDay = Old.Where(t => t.CreateTime >= S && t.CreateTime < E). Where(t => t.CreateTime.Year == DateTime.Now.Year) .Where(t => t.CreateTime.Month == DateTime.Now.Month) .Where(t => t.CreateTime.Day == DateTime.Now.Day) @@ -169,8 +176,10 @@ namespace HKCardOUT.Logic.Service if (!GetCardStutas(input.CardNo)) return false; 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]) + var AT = DataBus.Times.AT.Split(","); + var S = DateTime.Parse(AT[0]); + var E = DateTime.Parse(AT[1]); + var ATDay = Old.Where(t => t.CreateTime >= S && t.CreateTime t.CreateTime.Year == DateTime.Now.Year) .Where(t => t.CreateTime.Month == DateTime.Now.Month) .Where(t => t.CreateTime.Day == DateTime.Now.Day) diff --git a/HKCardOUT/MqHandle.cs b/HKCardOUT/MqHandle.cs index 1e4a846..48846bc 100644 --- a/HKCardOUT/MqHandle.cs +++ b/HKCardOUT/MqHandle.cs @@ -1,7 +1,7 @@ using HKCardOUT.Logic; +using HKCardOUT.Logic.Model; using HKLib.Dto; using HKLib.RabbitMQ.Config; -using Logic.Model; using System; using System.Collections.Generic; using System.Text; diff --git a/HKCardOUT/ViewModels/RootViewModel.cs b/HKCardOUT/ViewModels/RootViewModel.cs index efac990..9ef01da 100644 --- a/HKCardOUT/ViewModels/RootViewModel.cs +++ b/HKCardOUT/ViewModels/RootViewModel.cs @@ -199,10 +199,10 @@ namespace HKCardOUT.ViewModels lock (locker) { var Core = Container.Get(); - 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]) + var AM = DataBus.Times.AM.Split(","); + var PM = DataBus.Times.PM.Split(","); + var AT = DataBus.Times.AT.Split(","); + if (DateTime.Now >= DateTime.Parse(AM[0]) && DateTime.Now < DateTime.Parse(AM[1])) { Core.DeviceSaleAM(new SaleLog { @@ -211,7 +211,7 @@ namespace HKCardOUT.ViewModels IsSync = false }); } - if (DateTime.Now.Hour >= PM[0] && DateTime.Now.Hour < PM[1]) + if (DateTime.Now >= DateTime.Parse(PM[0]) && DateTime.Now < DateTime.Parse(PM[1])) { Core.DeviceSalePM(new SaleLog { @@ -220,7 +220,7 @@ namespace HKCardOUT.ViewModels IsSync = false }); } - if (DateTime.Now.Hour >= AT[0] && DateTime.Now.Hour < AT[1]) + if (DateTime.Now >= DateTime.Parse(AT[0]) && DateTime.Now < DateTime.Parse(AT[1])) { Core.DeviceSaleAT(new SaleLog { diff --git a/HKCardOUT/options.json b/HKCardOUT/options.json index 64b8e5d..2f620dd 100644 --- a/HKCardOUT/options.json +++ b/HKCardOUT/options.json @@ -13,12 +13,6 @@ "ConnectionStrings": { "Sqlite": "HKSQL.db3" }, - //早上 - "AM": "6,9", - //中午 - "PM": "11,14", - //下午 - "AT": "17,20", //每个时间段的刷卡次数 "Count": 1, //取消单卡刷卡限制 diff --git a/HKLib/Dto/CardStutasDto.cs b/HKLib/Dto/CardStutasDto.cs index 8f076e1..3e594a9 100644 --- a/HKLib/Dto/CardStutasDto.cs +++ b/HKLib/Dto/CardStutasDto.cs @@ -14,5 +14,9 @@ namespace HKLib.Dto /// 状态 0.禁用 1.正常 2.挂失 3.作废 /// public int Stutas { get; set; } + /// + /// 手机号 名称 + /// + public string keywrod { get; set; } } } diff --git a/HKLib/Interfaces/HKLibHelper.cs b/HKLib/Interfaces/HKLibHelper.cs index 076fe3e..8696896 100644 --- a/HKLib/Interfaces/HKLibHelper.cs +++ b/HKLib/Interfaces/HKLibHelper.cs @@ -38,7 +38,7 @@ namespace HKLib.Interfaces /// /// 修改机构 /// - public static bool AlterOrg(string input,string Sid) + public static bool AlterOrg(string input, string Sid) { return IHttpMultiClient.HttpMulti.AddNode(t => { @@ -52,13 +52,14 @@ namespace HKLib.Interfaces /// 根据用户命获取下拉用户列表 /// /// - public static void GetUserList(string keyword) + public static string GetUserList(string keyword) { IHttpMultiClient.HttpMulti.AddNode(t => { t.NodePath = $"{Configer.SaasRoute}/{keyword}"; t.ReqType = MultiType.GET; }).Build().RunStringFirst(); + return ""; } /// /// 添加用户 @@ -79,6 +80,8 @@ namespace HKLib.Interfaces /// public static void CardStutasChange(CardStutasDto input) { + input.CardNo = GetUserList(input.keywrod); + IHttpMultiClient.HttpMulti.AddNode(t => { t.NodePath = $"{Configer.SaasRoute}"; @@ -92,7 +95,7 @@ namespace HKLib.Interfaces /// /// /// 1 计次就餐天消费表(每人),2每月餐段消费报表,3月餐段汇总表 - public static void Report(ReportDto input,int type=1) + public static void Report(ReportDto input, int type = 1) { IHttpMultiClient.HttpMulti.AddNode(t => { diff --git a/HKLib/RabbitMq/Config/MQFactory.cs b/HKLib/RabbitMq/Config/MQFactory.cs index df084f0..917fc7d 100644 --- a/HKLib/RabbitMq/Config/MQFactory.cs +++ b/HKLib/RabbitMq/Config/MQFactory.cs @@ -1,6 +1,5 @@ using EasyNetQ; using EasyNetQ.Topology; -using HKLib.DataBus.数据缓存; using System; using System.Collections.Generic; using System.Configuration;