Quellcode durchsuchen

一卡通MQ 和 接口对接

Lishi
xxe vor 2 Jahren
Ursprung
Commit
2e30211dba
6 geänderte Dateien mit 41 neuen und 18 gelöschten Zeilen
  1. +9
    -3
      HKCardOUT/Bootstrapper.cs
  2. +10
    -2
      HKCardOUT/CardHandle.cs
  3. +1
    -1
      HKCardOUT/Helper/DataBus.cs
  4. +13
    -10
      HKCardOUT/Logic/RemoteService.cs
  5. +1
    -1
      HKCardOUT/Logic/Service/HKCore.cs
  6. +7
    -1
      HKLib/Interfaces/HKLibHelper.cs

+ 9
- 3
HKCardOUT/Bootstrapper.cs Datei anzeigen

@@ -14,6 +14,8 @@ using ImTools;
using XExten.Advance.LinqFramework;
using System.Threading;
using HKLog;
using HKLib.RabbitMQ.Config;
using HKLib.RabbitMQ.Subscriber;

namespace HKCardOUT
{
@@ -44,7 +46,7 @@ namespace HKCardOUT
}
Thread.Sleep(3000);
}), "循环状态监测线程", false);
HKLog.HKLogImport.Init("HKCardOUT");
HKLogImport.Init("HKCardOUT");
}

protected override void ConfigureIoC(IStyletIoCBuilder builder)
@@ -59,6 +61,7 @@ namespace HKCardOUT
{
var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build();
DataBus.ConnectionString = configer.GetConnectionString("Sqlite");
HKLib.Configer.MqAddress = configer["MQ"];
DataBus.Cron = configer["Cron"];
DataBus.SaasRoute = configer["SaasRoute"];
DataBus.StoreId = configer["StoreId"];
@@ -67,11 +70,14 @@ namespace HKCardOUT
DataBus.StartDevice = configer["StartDevice"].AsBool();
DataBus.Cancel = configer["Cancel"].AsBool();
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.MqAddress = configer["MQ"];
//服务器拉取数据
RemoteService.SyncTime();
RemoteService.GetCardStuatas();
DbContext.InitTable();
RemoteService.PullShopInfo();
base.Configure();
}


HKCardOUT/MqHandle.cs → HKCardOUT/CardHandle.cs Datei anzeigen

@@ -1,4 +1,5 @@
using HKCardOUT.Logic;
using HKCardOUT.Helper;
using HKCardOUT.Logic;
using HKCardOUT.Logic.Model;
using HKLib.Dto;
using HKLib.RabbitMQ.Config;
@@ -9,7 +10,7 @@ using XExten.Advance.LinqFramework;

namespace HKCardOUT
{
public class MqHandle : IAccept
public class CardHandle : IAccept
{
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>();
}
}
}

+ 1
- 1
HKCardOUT/Helper/DataBus.cs Datei anzeigen

@@ -40,7 +40,7 @@ namespace HKCardOUT.Helper
}
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>


+ 13
- 10
HKCardOUT/Logic/RemoteService.cs Datei anzeigen

@@ -1,6 +1,7 @@
using HKCardOUT.Helper;
using HKCardOUT.Logic.Model;
using HKCardOUT.Logic.Service;
using HKLib.Dto;
using Logic.RemoteModel;
using Newtonsoft.Json.Linq;
using System;
@@ -26,16 +27,18 @@ namespace HKCardOUT.Logic
/// <param name="input"></param>
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;
}
/// <summary>
@@ -51,7 +54,7 @@ namespace HKCardOUT.Logic
t.NodePath = ApiRoute.GetTime;
t.ReqType = MultiType.GET;
}).Build().RunStringFirst();
DataBus.Times = data.ToModel<JObject>()["data"]["data"].ToJson().ToModel<TimeSpilte>();
}

/// <summary>


+ 1
- 1
HKCardOUT/Logic/Service/HKCore.cs Datei anzeigen

@@ -35,7 +35,7 @@ namespace HKCardOUT.Logic.Service
if (data.Stutas != 1) return false;
return true;
}
public static void AddCard(CardStutas input)
public static void AddCard(List<CardStutas> input)
{
DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand();
}


+ 7
- 1
HKLib/Interfaces/HKLibHelper.cs Datei anzeigen

@@ -38,7 +38,13 @@ namespace HKLib.Interfaces
t.JsonParam = dto.ToJson();
t.ReqType = MultiType.PUT;
}).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>


Laden…
Abbrechen
Speichern