|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
|
|
|
|
using SlnMesnac.Repository.service.LogImpl;
|
|
|
|
using SlnMesnac.Repository.service.ScanLog;
|
|
|
|
using SlnMesnac.Repository.service.ScanLog;
|
|
|
|
using TouchSocket.Core;
|
|
|
|
using TouchSocket.Core;
|
|
|
|
using TouchSocket.Rpc;
|
|
|
|
using TouchSocket.Rpc;
|
|
|
@ -16,15 +17,18 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
private readonly IScanLogService _scanService;
|
|
|
|
private readonly IScanLogService _scanService;
|
|
|
|
|
|
|
|
|
|
|
|
private readonly IBaseCodeService _baseCodeService;
|
|
|
|
private readonly IBaseCodeService _baseCodeService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IBaseLogService _baseLogService;
|
|
|
|
|
|
|
|
|
|
|
|
public Action<ScanLogSocket>? ScanLogSocketAction;
|
|
|
|
public Action<ScanLogSocket>? ScanLogSocketAction;
|
|
|
|
public Action<ScanStatusSocket>? ScanStatusSocketAction;
|
|
|
|
public Action<ScanStatusSocket>? ScanStatusSocketAction;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ApiServer(IScanLogService scanService, IBaseCodeService baseCodeService)
|
|
|
|
public ApiServer(IScanLogService scanService, IBaseCodeService baseCodeService, IBaseLogService baseLogService)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_scanService = scanService;
|
|
|
|
_scanService = scanService;
|
|
|
|
_baseCodeService = baseCodeService;
|
|
|
|
_baseCodeService = baseCodeService;
|
|
|
|
|
|
|
|
_baseLogService = baseLogService;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -37,27 +41,40 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
[WebApi(HttpMethodType.POST)]
|
|
|
|
[WebApi(HttpMethodType.POST)]
|
|
|
|
public Back ScanStatus(ScanStatusSocket scanStatus)
|
|
|
|
public Back ScanStatus(ScanStatusSocket scanStatus)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
BaseLog log = new BaseLog();
|
|
|
|
if (scanStatus.is_alarm == 1 && scanStatus.device_status != null && scanStatus.device_status.Count > 0)
|
|
|
|
log.LogLevel = "Info";
|
|
|
|
|
|
|
|
log.ErrMsg = "";
|
|
|
|
|
|
|
|
log.Content = scanStatus.ToJsonString();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<string> ls = new List<string>();
|
|
|
|
if (scanStatus.is_alarm == 1 && scanStatus.device_status != null && scanStatus.device_status.Count > 0)
|
|
|
|
var baseCodes = _baseCodeService.QuListCache();
|
|
|
|
|
|
|
|
foreach (var baseCode in scanStatus.device_status)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var enBaseCode = baseCodes.FirstOrDefault(x=>x.Code==baseCode);
|
|
|
|
List<string> ls = new List<string>();
|
|
|
|
if (enBaseCode != null)
|
|
|
|
var baseCodes = _baseCodeService.QuListCache();
|
|
|
|
|
|
|
|
foreach (var baseCode in scanStatus.device_status)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ls.Add(enBaseCode.State);
|
|
|
|
var enBaseCode = baseCodes.FirstOrDefault(x => x.Code == baseCode);
|
|
|
|
|
|
|
|
if (enBaseCode != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ls.Add(enBaseCode.State);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scanStatus.status_txt = ls;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
scanStatus.status_txt = ls;
|
|
|
|
|
|
|
|
|
|
|
|
ScanStatusSocketAction?.Invoke(scanStatus);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
ScanStatusSocketAction?.Invoke(scanStatus);
|
|
|
|
{
|
|
|
|
|
|
|
|
log.LogLevel = "Error";
|
|
|
|
|
|
|
|
log.ErrMsg=e.Message;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_baseLogService.Insert(log);
|
|
|
|
|
|
|
|
|
|
|
|
return new Back();
|
|
|
|
return new Back();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,20 +86,35 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
[EnableCors("cors")]
|
|
|
|
[EnableCors("cors")]
|
|
|
|
[WebApi(HttpMethodType.POST)]
|
|
|
|
[WebApi(HttpMethodType.POST)]
|
|
|
|
public Back ScanBack(ScanLogSocket scanStatus)
|
|
|
|
public Back ScanBack(ScanLogSocket scanLogStatus)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ScanLogSocketAction?.Invoke(scanStatus);
|
|
|
|
BaseLog log = new BaseLog();
|
|
|
|
_scanService.Insert(new ScanLogModel()
|
|
|
|
log.LogLevel = "Info";
|
|
|
|
|
|
|
|
log.ErrMsg = "";
|
|
|
|
|
|
|
|
log.Content = scanLogStatus.ToJsonString();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CreateTime = scanStatus.CreateTime,
|
|
|
|
ScanLogSocketAction?.Invoke(scanLogStatus);
|
|
|
|
DataType = scanStatus.data_type,
|
|
|
|
_scanService.Insert(new ScanLogModel()
|
|
|
|
Code = scanStatus.code,
|
|
|
|
{
|
|
|
|
Rfid = scanStatus.rfid,
|
|
|
|
CreateTime = scanLogStatus.CreateTime,
|
|
|
|
Ocr = scanStatus.ocr,
|
|
|
|
DataType = scanLogStatus.data_type,
|
|
|
|
Url = scanStatus.url
|
|
|
|
Code = scanLogStatus.code,
|
|
|
|
|
|
|
|
Rfid = scanLogStatus.rfid,
|
|
|
|
});
|
|
|
|
Ocr = scanLogStatus.ocr,
|
|
|
|
|
|
|
|
Url = scanLogStatus.url
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log.LogLevel = "Error";
|
|
|
|
|
|
|
|
log.ErrMsg = e.Message;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_baseLogService.Insert(log);
|
|
|
|
return new Back();
|
|
|
|
return new Back();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|