master
nodyang@aliyun.com 2 months ago
parent 3ef6d79288
commit cd916cd323

@ -20,7 +20,7 @@ public class ScanLogSocket
public int data_type { get; set; }
public string ffid { get; set; }
public string rfid { get; set; }
public string code { get; set; }

@ -12,6 +12,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SlnMesnac.Repository\SlnMesnac.Repository.csproj" />
<ProjectReference Include="..\SlnMesnac.Serilog\SlnMesnac.Serilog.csproj" />
</ItemGroup>

@ -4,6 +4,8 @@ using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.ScanLog;
using TouchSocket.Core;
using TouchSocket.Sockets;
using JsonSerializer = System.Text.Json.JsonSerializer;
@ -36,6 +38,8 @@ namespace SlnMesnac.TouchSocket
{
private ILogger<TcpServer> _logger;
private readonly TcpService _service;
private IScanLogService _scanService;
/// <summary>
/// 接收客户端指令委托
/// </summary>
@ -45,10 +49,11 @@ namespace SlnMesnac.TouchSocket
public delegate void RefreshClientInfo(TcpService tcpService);
public event RefreshClientInfo? RefreshClientInfoEvent;
public TcpServer(ILogger<TcpServer> logger,TcpService tcpService)
public TcpServer(ILogger<TcpServer> logger,TcpService tcpService, IScanLogService scan)
{
_logger = logger;
_service = tcpService;
_scanService = scan;
}
public void Init(int serverPort)
@ -87,20 +92,35 @@ namespace SlnMesnac.TouchSocket
if (dataType == 1)
{
ScanStatusSocket scanStatus= JsonConvert.DeserializeObject<ScanStatusSocket>(mes);
ScanLogSocket scanStatus= JsonConvert.DeserializeObject<ScanLogSocket>(mes);
_scanService.Insert(new ScanLogModel()
{
CreateTime = scanStatus.CreateTime,
DataType = scanStatus.data_type,
Code = scanStatus.code,
Rfid = scanStatus.rfid,
Ocr = scanStatus.ocr,
Url = scanStatus.url
});
}
else
{
if (dataType == 2)
{
ScanLogSocket scanStatus= JsonConvert.DeserializeObject<ScanLogSocket>(mes);
ScanStatusSocket scanStatus= JsonConvert.DeserializeObject<ScanStatusSocket>(mes);
}
}
// DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeSeconds(timestamp);
// DateTime dateTime = dateTimeOffset.UtcDateTime;
client.SendAsync(mes);
client.SendAsync(new Back().ToJsonString());
return EasyTask.CompletedTask;
};

Loading…
Cancel
Save