|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
|
using SlnMesnac.Repository.service.LogImpl;
|
|
|
|
|
using SlnMesnac.Repository.service.ScanLog;
|
|
|
|
|
using TouchSocket.Core;
|
|
|
|
|
using TouchSocket.Rpc;
|
|
|
|
@ -17,27 +18,36 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
|
|
|
|
|
private readonly IBaseCodeService _baseCodeService;
|
|
|
|
|
|
|
|
|
|
public Action<ScanLogModel>? ScanLogSocketAction; //Update By WenJY 2024-09-19将返回值改为ScanLogModel
|
|
|
|
|
IBaseLogService _baseLogService;
|
|
|
|
|
|
|
|
|
|
public Action<ScanLogModel>? ScanLogSocketAction;
|
|
|
|
|
public Action<ScanStatusSocket>? ScanStatusSocketAction;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ApiServer(IScanLogService scanService, IBaseCodeService baseCodeService)
|
|
|
|
|
public ApiServer(IScanLogService scanService, IBaseCodeService baseCodeService, IBaseLogService baseLogService)
|
|
|
|
|
{
|
|
|
|
|
_scanService = scanService;
|
|
|
|
|
_baseCodeService = baseCodeService;
|
|
|
|
|
_baseLogService = baseLogService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扫描的状态回传
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="messageHeader"></param>
|
|
|
|
|
/// <param name="containerRegisterQuery"></param>
|
|
|
|
|
/// <param name="scanStatus"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[EnableCors("cors")]
|
|
|
|
|
[WebApi(HttpMethodType.POST)]
|
|
|
|
|
public Back ScanStatus(ScanStatusSocket scanStatus)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
BaseLog log = new BaseLog
|
|
|
|
|
{
|
|
|
|
|
LogLevel = "Info",
|
|
|
|
|
ErrMsg = "",
|
|
|
|
|
Content = scanStatus.ToJsonString()
|
|
|
|
|
};
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (scanStatus.is_alarm == 1 && scanStatus.device_status != null && scanStatus.device_status.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
List<string> ls = new List<string>();
|
|
|
|
@ -55,35 +65,58 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
|
|
|
|
|
ScanStatusSocketAction?.Invoke(scanStatus);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
log.LogLevel = "Error";
|
|
|
|
|
log.ErrMsg=e.Message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_baseLogService.Insert(log);
|
|
|
|
|
|
|
|
|
|
return new Back();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 入库开始
|
|
|
|
|
/// 扫描数据回传接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="messageHeader"></param>
|
|
|
|
|
/// <param name="containerRegisterQuery"></param>
|
|
|
|
|
/// <param name="scanLog"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[EnableCors("cors")]
|
|
|
|
|
[WebApi(HttpMethodType.POST)]
|
|
|
|
|
public Back ScanBack(ScanLogSocket scanStatus)
|
|
|
|
|
public Back ScanBack(ScanLogSocket scanLog)
|
|
|
|
|
{
|
|
|
|
|
BaseLog log = new BaseLog();
|
|
|
|
|
log.LogLevel = "Info";
|
|
|
|
|
log.ErrMsg = "";
|
|
|
|
|
log.Content = scanLog.ToJsonString();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var scan = new ScanLogModel()
|
|
|
|
|
var model = new ScanLogModel()
|
|
|
|
|
{
|
|
|
|
|
CreateTime = scanStatus.CreateTime,
|
|
|
|
|
DataType = scanStatus.data_type,
|
|
|
|
|
Code = scanStatus.code,
|
|
|
|
|
Rfid = scanStatus.rfid,
|
|
|
|
|
Ocr = scanStatus.ocr,
|
|
|
|
|
Url = scanStatus.url
|
|
|
|
|
CreateTime = scanLog.CreateTime,
|
|
|
|
|
DataType = scanLog.data_type,
|
|
|
|
|
Code = scanLog.code,
|
|
|
|
|
Rfid = scanLog.rfid,
|
|
|
|
|
Ocr = scanLog.ocr,
|
|
|
|
|
Url = scanLog.url
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
ScanLogSocketAction?.Invoke(scan); //Update By WenJY 2024-09-19将返回值改为ScanLogModel
|
|
|
|
|
_scanService.Insert(scan);
|
|
|
|
|
|
|
|
|
|
ScanLogSocketAction?.Invoke(model);
|
|
|
|
|
_scanService.Insert(model);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
log.LogLevel = "Error";
|
|
|
|
|
log.ErrMsg = e.Message;
|
|
|
|
|
}
|
|
|
|
|
_baseLogService.Insert(log);
|
|
|
|
|
return new Back();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|