Selaa lähdekoodia

修改BUG

Lishi
xxe 2 vuotta sitten
vanhempi
commit
bc6cd18d31
5 muutettua tiedostoa jossa 95 lisäystä ja 9 poistoa
  1. +3
    -3
      HKCardOUT/Bootstrapper.cs
  2. +15
    -0
      HKCardOUT/DTO/SaleDto.cs
  3. +4
    -0
      HKCardOUT/Helper/DataBus.cs
  4. +38
    -1
      HKCardOUT/Logic/RemoteService.cs
  5. +35
    -5
      HKCardOUT/QuartzUtil/Job/QuartzJob.cs

+ 3
- 3
HKCardOUT/Bootstrapper.cs Näytä tiedosto

@@ -65,24 +65,24 @@ namespace HKCardOUT
var configer = (new ConfigurationBuilder()).AddJsonFile("options.pro.json").Build();
#endif
DataBus.ConnectionString = configer.GetConnectionString("Sqlite");
DataBus.SaasRoute = configer["SaasRoute"];
HKLib.Configer.MqAddress = configer["MQ"];
DataBus.Cron = configer["Cron"];
DataBus.SaasRoute = configer["SaasRoute"];
DataBus.StoreId = configer["StoreId"];
DataBus.COM = configer["COM"];
DataBus.TenantId = configer["TenantId"];
DataBus.StartDevice = configer["StartDevice"].AsBool();
DataBus.Cancel = configer["Cancel"].AsBool();
DataBus.Count = configer["Count"].AsInt();
HKLib.Configer.SaasRoute = DataBus.SaasRoute;
RemoteService.PullShopInfo();
//初始化表
DbContext.InitTable();
ServiceQueryExcute.QueryExcute.ExtuteMQ<CardHandle, string>("CardStutasChanged", MQEnum.Push);
ServiceQueryExcute.QueryExcute.ExtuteMQ<TimeHandle, string>("TimeChanged", MQEnum.Push);
HKLib.Configer.SaasRoute = DataBus.SaasRoute;
//服务器拉取数据
RemoteService.SyncTime();
RemoteService.GetCardStuatas();
RemoteService.PullShopInfo();
base.Configure();
}



+ 15
- 0
HKCardOUT/DTO/SaleDto.cs Näytä tiedosto

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace DTO
{
public class SaleDto
{
public int Type { get; set; } = -1;
public string GateId { get; set; }
public string CardNum { get; set; }
public Guid Id { get; set; }
public DateTime CreateAt { get; set; }
}
}

+ 4
- 0
HKCardOUT/Helper/DataBus.cs Näytä tiedosto

@@ -50,6 +50,10 @@ namespace HKCardOUT.Helper
/// </summary>
public static string SyncSaleLog = DataBus.SaasRoute + "api/member-helper/memberconsumptionorrecharge";
/// <summary>
/// 批量消费记录
/// </summary>
public static string SyncSaleLogList = DataBus.SaasRoute + "api/member-helper/memberconsumptionorrechargelist";
/// <summary>
/// 获取店铺信息
/// </summary>
public static string PullShopInfo = DataBus.SaasRoute + $"api/StoreHelper/GeBasisGateList?StoreId={DataBus.StoreId}";


+ 38
- 1
HKCardOUT/Logic/RemoteService.cs Näytä tiedosto

@@ -1,4 +1,5 @@
using HKCardOUT.Helper;
using DTO;
using HKCardOUT.Helper;
using HKCardOUT.Logic.Model;
using HKCardOUT.Logic.Service;
using HKLib.Dto;
@@ -21,6 +22,7 @@ namespace HKCardOUT.Logic
{
public class RemoteService
{
private static readonly object locker = new();
/// <summary>
/// 获取所有卡状态和卡号
/// </summary>
@@ -82,6 +84,41 @@ namespace HKCardOUT.Logic
return false;
}

}
/// <summary>
/// 批量同步同步消费记录
/// </summary>
/// <returns></returns>
public static bool SyncSaleLogList(List<SaleDto> dto)
{
try
{
lock (locker)
{
var Ids = dto.Select(t => t.Id).ToList();
var check = DbContext.Context.Queryable<SaleLog>().Where(t => Ids.Contains(t.Id)).Any(t => t.IsSync);
if (check) return false;
var data = IHttpMultiClient.HttpMulti.AddHeader(t =>
{
t.HeaderKey = "TenantId";
t.HeaderValue = DataBus.TenantId;
}).AddNode(t =>
{
t.ReqType = MultiType.POST;
t.JsonParam = dto.ToJson();
t.NodePath = ApiRoute.SyncSaleLogList;
}).Build().RunStringFirst();
HKLog.HKLogImport.WriteInfo($"批量同步同步消费记录调用:{data}");
return bool.Parse(data.ToModel<JObject>()["data"].ToString());
}
}
catch (Exception ex)
{
HKLog.HKLogImport.WriteError(ex);
return false;
}


}
/// <summary>
/// 获取店铺信息


+ 35
- 5
HKCardOUT/QuartzUtil/Job/QuartzJob.cs Näytä tiedosto

@@ -1,8 +1,14 @@
using HKCardOUT.Logic;
using DTO;
using HKCardOUT.Helper;
using HKCardOUT.Logic;
using HKCardOUT.Logic.Model;
using Quartz;
using S7.Net.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using XExten.Advance.LinqFramework;

namespace HKCardOUT.QuartzUtil.Job
{
@@ -14,18 +20,42 @@ namespace HKCardOUT.QuartzUtil.Job
{
default:
{

var WaitSync = DbContext.Context.Queryable<SaleLog>().Where(t => t.IsSync == false).ToList();
List<SaleDto> dto = new List<SaleDto>();
if (WaitSync.Count > 0)
{
HKLog.HKLogImport.WriteInfo($"订单推送执行,推送数量{WaitSync.Count},推送的卡号:【{string.Join(",", WaitSync.Select(t => t.CardNo))}】");

foreach (var input in WaitSync)
{
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location);

var GateId = DataBus.StoreInfo.Devices.FirstOrDefault(t => t.Address.AsInt() == input.Location.AsInt())?.GateId;

dto.Add(new SaleDto
{
CardNum = input.CardNo,
GateId = GateId,
Id= input.Id,
CreateAt=input.CreateTime
});
}
var db = DbContext.Context;
try
{
db.BeginTran();
var res = RemoteService.SyncSaleLogList(dto);
if (res)
await DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == input.Id).ExecuteCommandAsync();
{
var ids = WaitSync.Select(t => t.Id).ToList();
await DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => ids.Contains(t.Id)).ExecuteCommandAsync();
db.CommitTran();
}
}
catch (Exception)
{
db.RollbackTran();
}
}
}
break;


Ladataan…
Peruuta
Tallenna