78 lines
1.7 KiB
C#
78 lines
1.7 KiB
C#
using Dlhis.Entity.Device.Enums;
|
|
using Kurisu.AspNetCore.Utils.Extensions;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace Dlhis.External.OpenApi.Response;
|
|
|
|
public class DeviceResponse
|
|
{
|
|
public string DeviceNo { get; set; }
|
|
|
|
/// <summary>
|
|
/// 心跳间隔
|
|
/// </summary>
|
|
public int HeartbeatInterval { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// 设备类型, 1:门禁, 3:考勤
|
|
/// </summary>
|
|
public DeviceTypeEnumType Type { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// 部署方向,10:进;20:出
|
|
/// </summary>
|
|
public DeviceDeployDirectionEnumType? DirectionType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 部署点位
|
|
/// </summary>
|
|
public string DeployPlace { get; set; }
|
|
|
|
/// <summary>
|
|
/// 最后心跳时间
|
|
/// </summary>
|
|
public DateTime? LastHeartbeatTime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否在线
|
|
/// </summary>
|
|
public bool IsOnline
|
|
{
|
|
get
|
|
{
|
|
if (!LastHeartbeatTime.HasValue)
|
|
return false;
|
|
|
|
if (HeartbeatInterval <= 0)
|
|
return true;
|
|
|
|
return LastHeartbeatTime.Value.AddSeconds(HeartbeatInterval) >= DateTime.Now;
|
|
}
|
|
}
|
|
|
|
[JsonIgnore]
|
|
public string ConnectionInfo { get; set; }
|
|
|
|
/// <summary>
|
|
/// 设备列表
|
|
/// </summary>
|
|
public string Ip
|
|
{
|
|
get
|
|
{
|
|
if (!ConnectionInfo.IsPresent())
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
var jObj = JObject.Parse(ConnectionInfo);
|
|
|
|
return jObj.TryGetValue("ip", out var ip)
|
|
? ip.Value<string>()
|
|
: string.Empty;
|
|
}
|
|
}
|
|
} |