@@ -14,6 +14,8 @@ using ImTools; | |||||
using XExten.Advance.LinqFramework; | using XExten.Advance.LinqFramework; | ||||
using System.Threading; | using System.Threading; | ||||
using HKLog; | using HKLog; | ||||
using HKLib.RabbitMQ.Config; | |||||
using HKLib.RabbitMQ.Subscriber; | |||||
namespace HKCardOUT | namespace HKCardOUT | ||||
{ | { | ||||
@@ -44,7 +46,7 @@ namespace HKCardOUT | |||||
} | } | ||||
Thread.Sleep(3000); | Thread.Sleep(3000); | ||||
}), "循环状态监测线程", false); | }), "循环状态监测线程", false); | ||||
HKLog.HKLogImport.Init("HKCardOUT"); | |||||
HKLogImport.Init("HKCardOUT"); | |||||
} | } | ||||
protected override void ConfigureIoC(IStyletIoCBuilder builder) | protected override void ConfigureIoC(IStyletIoCBuilder builder) | ||||
@@ -59,6 +61,7 @@ namespace HKCardOUT | |||||
{ | { | ||||
var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build(); | var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build(); | ||||
DataBus.ConnectionString = configer.GetConnectionString("Sqlite"); | DataBus.ConnectionString = configer.GetConnectionString("Sqlite"); | ||||
HKLib.Configer.MqAddress = configer["MQ"]; | |||||
DataBus.Cron = configer["Cron"]; | DataBus.Cron = configer["Cron"]; | ||||
DataBus.SaasRoute = configer["SaasRoute"]; | DataBus.SaasRoute = configer["SaasRoute"]; | ||||
DataBus.StoreId = configer["StoreId"]; | DataBus.StoreId = configer["StoreId"]; | ||||
@@ -67,11 +70,14 @@ namespace HKCardOUT | |||||
DataBus.StartDevice = configer["StartDevice"].AsBool(); | DataBus.StartDevice = configer["StartDevice"].AsBool(); | ||||
DataBus.Cancel = configer["Cancel"].AsBool(); | DataBus.Cancel = configer["Cancel"].AsBool(); | ||||
DataBus.Count = configer["Count"].AsInt(); | DataBus.Count = configer["Count"].AsInt(); | ||||
//初始化表 | |||||
DbContext.InitTable(); | |||||
ServiceQueryExcute.QueryExcute.ExtuteMQ<CardHandle, string>("CardStutasChanged", MQEnum.Push); | |||||
ServiceQueryExcute.QueryExcute.ExtuteMQ<TimeHandle, string>("TimeChanged", MQEnum.Push); | |||||
HKLib.Configer.SaasRoute = DataBus.SaasRoute; | HKLib.Configer.SaasRoute = DataBus.SaasRoute; | ||||
HKLib.Configer.MqAddress = configer["MQ"]; | |||||
//服务器拉取数据 | |||||
RemoteService.SyncTime(); | RemoteService.SyncTime(); | ||||
RemoteService.GetCardStuatas(); | RemoteService.GetCardStuatas(); | ||||
DbContext.InitTable(); | |||||
RemoteService.PullShopInfo(); | RemoteService.PullShopInfo(); | ||||
base.Configure(); | base.Configure(); | ||||
} | } | ||||
@@ -1,4 +1,5 @@ | |||||
using HKCardOUT.Logic; | |||||
using HKCardOUT.Helper; | |||||
using HKCardOUT.Logic; | |||||
using HKCardOUT.Logic.Model; | using HKCardOUT.Logic.Model; | ||||
using HKLib.Dto; | using HKLib.Dto; | ||||
using HKLib.RabbitMQ.Config; | using HKLib.RabbitMQ.Config; | ||||
@@ -9,7 +10,7 @@ using XExten.Advance.LinqFramework; | |||||
namespace HKCardOUT | namespace HKCardOUT | ||||
{ | { | ||||
public class MqHandle : IAccept | |||||
public class CardHandle : IAccept | |||||
{ | { | ||||
public void AcceptMQ<T>(string msg) | public void AcceptMQ<T>(string msg) | ||||
{ | { | ||||
@@ -19,4 +20,11 @@ namespace HKCardOUT | |||||
} | } | ||||
} | } | ||||
public class TimeHandle : IAccept | |||||
{ | |||||
public void AcceptMQ<T>(string msg) | |||||
{ | |||||
DataBus.Times = msg.ToModel<TimeSpilte>(); | |||||
} | |||||
} | |||||
} | } |
@@ -40,7 +40,7 @@ namespace HKCardOUT.Helper | |||||
} | } | ||||
public class ApiRoute | public class ApiRoute | ||||
{ | { | ||||
public static string GetTime = "http://192.168.1.22:5000/api/one-card/eat-time-interval"; | |||||
public static string GetTime = DataBus.SaasRoute + "api/one-card/eat-time-interval"; | |||||
/// <summary> | /// <summary> | ||||
/// 获取所有卡 | /// 获取所有卡 | ||||
/// </summary> | /// </summary> | ||||
@@ -1,6 +1,7 @@ | |||||
using HKCardOUT.Helper; | using HKCardOUT.Helper; | ||||
using HKCardOUT.Logic.Model; | using HKCardOUT.Logic.Model; | ||||
using HKCardOUT.Logic.Service; | using HKCardOUT.Logic.Service; | ||||
using HKLib.Dto; | |||||
using Logic.RemoteModel; | using Logic.RemoteModel; | ||||
using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||
using System; | using System; | ||||
@@ -26,16 +27,18 @@ namespace HKCardOUT.Logic | |||||
/// <param name="input"></param> | /// <param name="input"></param> | ||||
public static int GetCardStuatas() | public static int GetCardStuatas() | ||||
{ | { | ||||
var data = IHttpMultiClient.HttpMulti.AddNode(t => | |||||
{ | |||||
t.NodePath = ApiRoute.CheckCardStatus; | |||||
t.ReqType = MultiType.GET; | |||||
}).Build().RunStringFirst().ToModel<JObject>()["data"]["data"].ToJson().ToModel<HKLib.Dto.CardInfo>(); | |||||
HKCore.AddCard(new CardStutas | |||||
var res = IHttpMultiClient.HttpMulti.AddNode(t => | |||||
{ | { | ||||
CardNo = data.CardNum, | |||||
Stutas = data.State | |||||
}); | |||||
t.NodePath = ApiRoute.CheckCardStatus; | |||||
t.ReqType = MultiType.GET; | |||||
}).Build().RunStringFirst(); | |||||
var data = res.ToModel<JObject>()["data"]["data"].ToJson().ToModel<List<CardInfo>>(); | |||||
var entity = data.Select(t => new CardStutas | |||||
{ | |||||
CardNo = t.CardNum, | |||||
Stutas = t.State | |||||
}).ToList(); | |||||
HKCore.AddCard(entity); | |||||
return data != null ? data.ToString().AsInt() : 0; | return data != null ? data.ToString().AsInt() : 0; | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -51,7 +54,7 @@ namespace HKCardOUT.Logic | |||||
t.NodePath = ApiRoute.GetTime; | t.NodePath = ApiRoute.GetTime; | ||||
t.ReqType = MultiType.GET; | t.ReqType = MultiType.GET; | ||||
}).Build().RunStringFirst(); | }).Build().RunStringFirst(); | ||||
DataBus.Times = data.ToModel<JObject>()["data"]["data"].ToJson().ToModel<TimeSpilte>(); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -35,7 +35,7 @@ namespace HKCardOUT.Logic.Service | |||||
if (data.Stutas != 1) return false; | if (data.Stutas != 1) return false; | ||||
return true; | return true; | ||||
} | } | ||||
public static void AddCard(CardStutas input) | |||||
public static void AddCard(List<CardStutas> input) | |||||
{ | { | ||||
DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand(); | DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand(); | ||||
} | } | ||||
@@ -38,7 +38,13 @@ namespace HKLib.Interfaces | |||||
t.JsonParam = dto.ToJson(); | t.JsonParam = dto.ToJson(); | ||||
t.ReqType = MultiType.PUT; | t.ReqType = MultiType.PUT; | ||||
}).Build().RunStringFirst(); | }).Build().RunStringFirst(); | ||||
return data.ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool(); | |||||
var res = data.ToModel<JObject>()["data"]["isSuccess"].ToString().AsBool(); | |||||
if (res) | |||||
{ | |||||
ServiceQueryPush.QueryPush.PushMQ(input, "TimeChanged", MQEnum.Push); | |||||
return res; | |||||
} | |||||
return false; | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||