change - 添加RFID信息解析

master
wenjy 2 months ago
parent 376db435c6
commit 12827b1693

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Logging;
@ -69,6 +70,17 @@ namespace SlnMesnac.TouchSocket
_logger.LogInformation("==========================");
if (hk.data_type == 1)
{
if(hk.rfid == "noread")
{
hk.rfid = hk.ocr;
}
else
{
string rfidStr = hk.rfid;
AnasysBuffer(ref rfidStr);
hk.rfid = rfidStr;
}
ScanLogSocket scan = new ScanLogSocket()
{
code = hk.code,
@ -198,5 +210,59 @@ namespace SlnMesnac.TouchSocket
return new Back();
}
private const string bufferStart = "0C1104";
private const string bufferBody = "EE5EFB65";
/// <summary>
/// RFID信息解析
/// </summary>
/// <param name="rfidStr"></param>
private void AnasysBuffer(ref string rfidStr)
{
if(rfidStr != "noread")
{
string bufferHex = rfidStr.Substring(bufferStart.Length, bufferBody.Length);
long decimalValue = Convert.ToInt64(bufferHex, 16);
rfidStr = decimalValue.ToString();
}
}
}
}
public class Hk
{
public DateTime CreateTime
{
get
{
DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeMilliseconds(timestamp);
return dateTimeOffset.UtcDateTime;
}
}
public long timestamp { get; set; }
public int data_type { get; set; }
public string rfid { get; set; }
public string code { get; set; }
public string ocr { get; set; }
public string url { get; set; }
public int is_alarm { get; set; }
public List<string> device_status { get; set; }
public List<string> status_txt { get; set; }
}

@ -33,39 +33,6 @@ public class ScanLogSocket
public class Hk
{
public DateTime CreateTime
{
get
{
DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeMilliseconds(timestamp);
return dateTimeOffset.UtcDateTime;
}
}
public long timestamp { get; set; }
public int data_type { get; set; }
public string rfid { get; set; }
public string code { get; set; }
public string ocr { get; set; }
public string url { get; set; }
public int is_alarm { get; set; }
public List<string> device_status { get; set; }
public List<string> status_txt { get; set; }
}

Loading…
Cancel
Save