diff --git a/SlnMesnac.TouchSocket/ApiServer.cs b/SlnMesnac.TouchSocket/ApiServer.cs index bb11fc0..f7657c2 100644 --- a/SlnMesnac.TouchSocket/ApiServer.cs +++ b/SlnMesnac.TouchSocket/ApiServer.cs @@ -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"; + + /// + /// RFID信息解析 + /// + /// + 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 device_status { get; set; } + + + public List status_txt { get; set; } } diff --git a/SlnMesnac.TouchSocket/ScanLogSocket.cs b/SlnMesnac.TouchSocket/ScanLogSocket.cs index 32e99ee..3108d98 100644 --- a/SlnMesnac.TouchSocket/ScanLogSocket.cs +++ b/SlnMesnac.TouchSocket/ScanLogSocket.cs @@ -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 device_status { get; set; } - - - public List status_txt { get; set; } -} -