From 12827b1693b46ffba28730499572ea5bb7a93a0b Mon Sep 17 00:00:00 2001 From: wenjy Date: Fri, 27 Sep 2024 11:24:33 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=B7=BB=E5=8A=A0RFID=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.TouchSocket/ApiServer.cs | 66 ++++++++++++++++++++++++++ SlnMesnac.TouchSocket/ScanLogSocket.cs | 33 ------------- 2 files changed, 66 insertions(+), 33 deletions(-) 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; } -} -