@@ -73,13 +73,13 @@ namespace HKCardOUT | |||
/// </summary> | |||
protected override void OnLaunch() | |||
{ | |||
//QuartzCoreFactory.QuartzCore().AddJob<QuartzJob>(new QuartzMap | |||
//{ | |||
// JobDetail = "定时推送订单", | |||
// Cron = DataBus.Cron, | |||
// JobName = "订单", | |||
// JobGroup = "订单" | |||
//}); | |||
QuartzCoreFactory.QuartzCore().AddJob<QuartzJob>(new QuartzMap | |||
{ | |||
JobDetail = "定时推送订单", | |||
Cron = DataBus.Cron, | |||
JobName = "订单", | |||
JobGroup = "订单" | |||
}); | |||
base.OnLaunch(); | |||
} | |||
@@ -37,21 +37,30 @@ namespace HKCardOUT.Logic | |||
/// <param name="Money"></param> | |||
public static bool SyncSaleLog(string CardNo, string StallId) | |||
{ | |||
var GateId = DataBus.StoreInfo.Devices.FirstOrDefault(t => t.Address.AsInt() == StallId.AsInt())?.GateId; | |||
var data = IHttpMultiClient.HttpMulti.AddNode(t => | |||
{ | |||
t.ReqType = MultiType.POST; | |||
t.JsonParam = (new { GateId = GateId, Type = -1, CardNum = CardNo }).ToJson(); | |||
t.NodePath = ApiRoute.SyncSaleLog; | |||
}).Build().RunStringFirst(); | |||
HKLog.HKLogImport.WriteInfo($"同步消费时候调用:{data}"); | |||
var m = bool.Parse(data.ToModel<JObject>()["data"].ToString()); | |||
if (m) | |||
try | |||
{ | |||
var GateId = DataBus.StoreInfo.Devices.FirstOrDefault(t => t.Address.AsInt() == StallId.AsInt())?.GateId; | |||
var data = IHttpMultiClient.HttpMulti.AddNode(t => | |||
{ | |||
t.ReqType = MultiType.POST; | |||
t.JsonParam = (new { GateId = GateId, Type = -1, CardNum = CardNo }).ToJson(); | |||
t.NodePath = ApiRoute.SyncSaleLog; | |||
}).Build().RunStringFirst(); | |||
HKLog.HKLogImport.WriteInfo($"同步消费时候调用:{data}"); | |||
var m = bool.Parse(data.ToModel<JObject>()["data"].ToString()); | |||
if (m) | |||
{ | |||
UHF_RS485_Helper.GetInstance().OpenBeep(StallId.AsInt()); | |||
return m; | |||
} | |||
else return false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
UHF_RS485_Helper.GetInstance().OpenBeep(StallId.AsInt()); | |||
return m; | |||
HKLog.HKLogImport.WriteError(ex); | |||
return false; | |||
} | |||
else return false; | |||
} | |||
/// <summary> | |||
/// 获取店铺信息 | |||
@@ -50,11 +50,23 @@ namespace HKCardOUT.Logic.Service | |||
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; | |||
//有网络直接同步 | |||
if (DataBus.NetWordState) | |||
{ | |||
//先出餐后推数据 | |||
if (!DataBus.IsTest) | |||
Main.GetInstance.Start(input.Location.AsInt()); | |||
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); | |||
if(res) | |||
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); | |||
return res; | |||
} | |||
else | |||
{ | |||
if (!DataBus.IsTest) | |||
Main.GetInstance.Start(input.Location.AsInt()); | |||
return true; | |||
} | |||
} | |||
} | |||
return false; | |||
@@ -90,11 +102,23 @@ namespace HKCardOUT.Logic.Service | |||
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; | |||
//有网络直接同步 | |||
if (DataBus.NetWordState) | |||
{ | |||
//先出餐后推数据 | |||
if (!DataBus.IsTest) | |||
Main.GetInstance.Start(input.Location.AsInt()); | |||
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); | |||
if (res) | |||
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); | |||
return res; | |||
} | |||
else | |||
{ | |||
if (!DataBus.IsTest) | |||
Main.GetInstance.Start(input.Location.AsInt()); | |||
return true; | |||
} | |||
} | |||
} | |||
return false; | |||
@@ -130,11 +154,23 @@ namespace HKCardOUT.Logic.Service | |||
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; | |||
//有网络直接同步 | |||
if (DataBus.NetWordState) | |||
{ | |||
//先出餐后推数据 | |||
if (!DataBus.IsTest) | |||
Main.GetInstance.Start(input.Location.AsInt()); | |||
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); | |||
if (res) | |||
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); | |||
return res; | |||
} | |||
else | |||
{ | |||
if (!DataBus.IsTest) | |||
Main.GetInstance.Start(input.Location.AsInt()); | |||
return true; | |||
} | |||
} | |||
} | |||
return false; | |||
@@ -1,8 +1,6 @@ | |||
using Quartz; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using HKCardOUT.Logic; | |||
using HKCardOUT.Logic.Model; | |||
using Quartz; | |||
using System.Threading.Tasks; | |||
namespace HKCardOUT.QuartzUtil.Job | |||
@@ -14,7 +12,18 @@ namespace HKCardOUT.QuartzUtil.Job | |||
switch (context.JobDetail.Key.Group) | |||
{ | |||
default: | |||
await Task.CompletedTask; | |||
{ | |||
var WaitSync = DbContext.Context.Queryable<SaleLog>().Where(t => t.IsSync == false).ToList(); | |||
if (WaitSync.Count > 0) | |||
{ | |||
foreach (var input in WaitSync) | |||
{ | |||
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); | |||
if (res) | |||
await DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == input.Id).ExecuteCommandAsync(); | |||
} | |||
} | |||
} | |||
break; | |||
} | |||
} | |||
@@ -241,7 +241,8 @@ namespace HKCardOUT.ViewModels | |||
Core.DeviceSaleAM(new SaleLog | |||
{ | |||
CardNo = input.ResData.Substring(1, input.ResData.Length - 1), | |||
Location = input.Address.AsInt().ToString() | |||
Location = input.Address.AsInt().ToString(), | |||
IsSync=false | |||
}); | |||
} | |||
if (DateTime.Now.Hour >= PM[0] && DateTime.Now.Hour < PM[1]) | |||
@@ -249,7 +250,8 @@ namespace HKCardOUT.ViewModels | |||
Core.DeviceSalePM(new SaleLog | |||
{ | |||
CardNo = input.ResData.Substring(1, input.ResData.Length - 1), | |||
Location = input.Address.AsInt().ToString() | |||
Location = input.Address.AsInt().ToString(), | |||
IsSync = false | |||
}); | |||
} | |||
if (DateTime.Now.Hour >= AT[0] && DateTime.Now.Hour < AT[1]) | |||
@@ -257,7 +259,8 @@ namespace HKCardOUT.ViewModels | |||
Core.DeviceSaleAT(new SaleLog | |||
{ | |||
CardNo = input.ResData.Substring(1, input.ResData.Length - 1), | |||
Location = input.Address.AsInt().ToString() | |||
Location = input.Address.AsInt().ToString(), | |||
IsSync = false | |||
}); | |||
} | |||
//Result = new ObservableCollection<SaleLog>(this.Container.Get<HKCore>().PullDaySaleLog()); | |||
@@ -4,7 +4,7 @@ | |||
"IsTest": true, | |||
"COM": "COM4", | |||
//定时任务时间表达式 | |||
"Cron": "0 0 11,15 * * ? ", | |||
"Cron": "0 0 0/1 * * ? ", | |||
//店铺ID | |||
"StoreId": "a19535e8-119f-4b10-a011-6288fd3ddb37", | |||
"ConnectionStrings": { | |||