闸机驱动及api

master
CZ 1 month ago
parent 9e03894f4f
commit c9311417ea

@ -0,0 +1,98 @@
namespace Service.Bramek.Bramek;
/// <summary>
/// 获取车道信息返回
/// </summary>
public class GetLaneInformationResp
{
/// <summary>
/// 返回状态 0失败1成功
/// </summary>
public string code {get;set;}
/// <summary>
/// 提示信息
/// </summary>
public string msg {get;set;}
/// <summary>
/// 随机数
/// </summary>
public string rand {get;set;}
/// <summary>
/// 签名字符串
/// </summary>
public string sign {get;set;}
/// <summary>
/// 返回数据中data的参数
/// </summary>
public List<GetLaneInformationRespData> data { get; set; }
}
public class GetLaneInformationRespData
{
/// <summary>
/// 索引ID
/// </summary>
public string indexId {get;set;}
/// <summary>
/// 车道编号
/// </summary>
public string vehNumber {get;set;}
/// <summary>
/// 岗亭编号
/// </summary>
public string sentryboxNo{get;set;}
/// <summary>
/// 车场唯一编号
/// </summary>
public string parkKey {get;set;}
/// <summary>
/// 车场规模 0:大车场 1:小车场
/// </summary>
public string parkScale {get;set;}
/// <summary>
/// 车道类型 0:入口 1:出口
/// </summary>
public string vehType {get;set;}
/// <summary>
/// 车道名称
/// </summary>
public string vehName {get;set;}
/// <summary>
/// 控制机机号
/// </summary>
public string vehCtrlNo {get;set;}
/// <summary>
/// 摄像机IP
/// </summary>
public string vehVideoIp{get;set;}
/// <summary>
/// 控制板IP
/// </summary>
public string vehCtrlIp {get;set;}
/// <summary>
/// 车道状态 0:禁用 1:启用
/// </summary>
public string vehStatus {get;set;}
/// <summary>
/// 识别区域坐标点A
/// </summary>
public string vehPointA {get;set;}
/// <summary>
/// 识别区域坐标点B
/// </summary>
public string vehPointB {get;set;}
/// <summary>
/// 识别区域坐标点C
/// </summary>
public string vehPointC {get;set;}
/// <summary>
/// 识别区域坐标点D
/// </summary>
public string vehPointD {get;set;}
/// <summary>
/// 车道授权码
/// </summary>
public string vehKey {get;set;}
}

@ -0,0 +1,47 @@
namespace Service.Bramek.Bramek;
/// <summary>
/// 远程开闸应答
/// </summary>
public class RemoteShutdownResp
{
/// <summary>
/// 返回状态 0失败1成功
/// </summary>
public int code { get; set; }
/// <summary>
/// 提示信息
/// </summary>
public string msg { get; set; }
/// <summary>
/// 随机数
/// </summary>
public string rand { get; set; }
/// <summary>
/// 签名字符串
/// </summary>
public string sign { get; set; }
/// <summary>
/// 返回数据中data的参数
/// </summary>
public RemoteShutdownRespData RemoteShutdownRespData { get; set; }
}
public class RemoteShutdownRespData
{
/// <summary>
/// 车场唯一编号
/// </summary>
public string parkKey { get; set; }
/// <summary>
/// 控制机号
/// </summary>
public string vlCtrNo { get; set; }
}

@ -0,0 +1,42 @@
namespace Service.Bramek;
/// <summary>
/// 获取车道信息
/// </summary>
public class GetLaneInformation
{
/// <summary>
/// 发者应用ID
/// </summary>
public string appid { get; set; }
/// <summary>
/// 车场唯一编号
/// </summary>
public string parkKey { get; set; }
/// <summary>
/// 随机数 请求接口时随机产生的小数与上次请求不能重复否则认为是非法请求如9.949955201
/// </summary>
public string rand { get; set; }
/// <summary>
/// 版本号 目前支持版本 v1.0 / v1.1
/// </summary>
public string version { get; set; }
/// <summary>
/// ①已经发送数据索引最大id 可为空默认从0开始v1.0 ②查询第几页数据默认0为第一页1为第二页以此类推v1.1)
/// </summary>
public string indexId { get; set; }
/// <summary>
/// 返回查询记录条数默认20条最大20条
/// </summary>
public string size { get; set; }
/// <summary>
/// 签名字符串
/// </summary>
public string sign { get; set; }
}

@ -0,0 +1,37 @@
namespace Service.Bramek;
/// <summary>
/// 远程关闸
/// </summary>
public class RemoteShutdown
{
/// <summary>
/// 发者应用ID
/// </summary>
public string appid { get; set; }
/// <summary>
/// 车场唯一编号
/// </summary>
public string parkKey { get; set; }
/// <summary>
/// 随机数 请求接口时随机产生的小数与上次请求不能重复否则认为是非法请求如9.949955201
/// </summary>
public string rand { get; set; }
/// <summary>
/// 版本号 目前支持版本 v1.0 / v1.1
/// </summary>
public string version { get; set; }
/// <summary>
/// 控制机号
/// </summary>
public string vlCtrNo { get; set; }
/// <summary>
/// 签名字符串
/// </summary>
public string sign { get; set; }
}

@ -0,0 +1,121 @@
using HybirdFrameworkCore.Entity;
using log4net;
using Newtonsoft.Json;
using Service.Bramek.Bramek;
namespace Service.Execute.Api;
public class BramekApi
{
private static readonly ILog Log = LogManager.GetLogger("BramekApi");
private static readonly string GetLaneInformationOpenBASE_URL = "http://openapi.szymzh.com/Api/Inform/OpenGate";
private static readonly string GetLaneInformationDownBASE_URL = "http://openapi.szymzh.com/Api/Inform/CloseGate";
private static readonly string RemoteShutdownBASE_URL = "http://openapi.szymzh.com/Api/Inquire/GetVehicleInfo";
private static readonly HttpClient _httpClient = new ()
{
Timeout = TimeSpan.FromSeconds(60)
};
/// <summary>
/// 闸机开
/// </summary>
/// <returns></returns>
public static async Task<bool> GetLaneInformationOpen()
{
Log.Info($" BramekApi GetLaneInformationOpen");
string url = GetLaneInformationOpenBASE_URL;
try
{
string s = await _httpClient.GetStringAsync(url);
if (!String.IsNullOrWhiteSpace(s))
{
Log.Info($" BramekApi GetLaneInformationOpen recesive{s}");
RemoteShutdownResp? succ = JsonConvert.DeserializeObject<RemoteShutdownResp>(s);
if (succ.code == 1)
{
return true;
}
else
{
return false;
}
}
return false;
}
catch (Exception e)
{
Log.Error($" BramekApi GetLaneInformationOpen ,e={e}");
return false;
}
}
/// <summary>
/// 闸机关
/// </summary>
/// <returns></returns>
public static async Task<bool> GetLaneInformationDown()
{
Log.Info($" BramekApi GetLaneInformationDown");
string url = GetLaneInformationDownBASE_URL;
try
{
string s = await _httpClient.GetStringAsync(url);
if (!String.IsNullOrWhiteSpace(s))
{
Log.Info($" BramekApi GetLaneInformationDown recesive{s}");
RemoteShutdownResp? succ = JsonConvert.DeserializeObject<RemoteShutdownResp>(s);
if (succ.code == 1)
{
return true;
}
else
{
return false;
}
}
return false;
}
catch (Exception e)
{
Log.Error($" BramekApi GetLaneInformationDown ,e={e}");
return false;
}
}
/// <summary>
/// 获取车道信息
/// </summary>
/// <returns></returns>
public static async Task<GetLaneInformationResp> GetLaneInformation()
{
Log.Info($" BramekApi GetLaneInformation");
string url = RemoteShutdownBASE_URL;
try
{
string s = await _httpClient.GetStringAsync(url);
if (!String.IsNullOrWhiteSpace(s))
{
Log.Info($" BramekApi GetLaneInformation recesive{s}");
GetLaneInformationResp? succ = JsonConvert.DeserializeObject<GetLaneInformationResp>(s);
if (succ != null)
{
return succ;
}
else
{
return null;
}
}
return null;
}
catch (Exception e)
{
Log.Error($" BramekApi GetLaneInformation ,e={e}");
return null;
}
}
}
Loading…
Cancel
Save