diff --git a/SlnMesnac.TouchSocket/ApiServer.cs b/SlnMesnac.TouchSocket/ApiServer.cs index 459913f..1d4f4f9 100644 --- a/SlnMesnac.TouchSocket/ApiServer.cs +++ b/SlnMesnac.TouchSocket/ApiServer.cs @@ -35,6 +35,52 @@ namespace SlnMesnac.TouchSocket _logger=logger; } + + + [EnableCors("cors")] + [WebApi(HttpMethodType.POST)] + + public Back Back(Hk hk) + { + Back ba=new Back(); + _logger.LogInformation("海康回调接口"); + _logger.LogInformation("{Data}", hk.ToJsonString()); + if (hk.data_type == 1) + { + ScanLogSocket scan = new ScanLogSocket() + { + code = hk.code, + data_type = hk.data_type, + ocr = hk.ocr, + rfid = hk.rfid, + timestamp = hk.timestamp, + url = hk.url + }; + ba= ScanBack(scan); + + } + else + { + if (hk.data_type == 2) + { + ScanStatusSocket scan = new ScanStatusSocket() + { + + data_type = hk.data_type, + is_alarm = hk.is_alarm, + device_status = hk.device_status, + timestamp = hk.timestamp, + + }; + ba = ScanStatus(scan); + + } + } + + return ba; + } + + /// /// 扫描的状态回传 /// diff --git a/SlnMesnac.TouchSocket/ScanLogSocket.cs b/SlnMesnac.TouchSocket/ScanLogSocket.cs index c0fa47d..32e99ee 100644 --- a/SlnMesnac.TouchSocket/ScanLogSocket.cs +++ b/SlnMesnac.TouchSocket/ScanLogSocket.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; public class ScanLogSocket { @@ -27,4 +28,45 @@ public class ScanLogSocket public string ocr { get; set; } public string url { get; set; } -} \ No newline at end of file +} + + + + +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; } +} + + + + +