change - 添加标签算法逻辑

master
wenjy 1 month ago
parent f205fd10c9
commit c7b19faa98

@ -39,5 +39,8 @@ namespace SlnMesnac.Model.domain
[ExcelColumnName("全景图像路径"), ExcelColumnWidth(50)] [ExcelColumnName("全景图像路径"), ExcelColumnWidth(50)]
[SugarColumn(ColumnName = "url")] [SugarColumn(ColumnName = "url")]
public string Url { get; set; } public string Url { get; set; }
[SugarColumn(IsIgnore = true)]
public string Result { get; set; }
} }
} }

@ -70,20 +70,14 @@ namespace SlnMesnac.TouchSocket
_logger.LogInformation("=========================="); _logger.LogInformation("==========================");
if (hk.data_type == 1) if (hk.data_type == 1)
{ {
if(hk.rfid == "noread") BaseLog log = new BaseLog();
{ log.LogLevel = "Info";
hk.rfid = hk.ocr; log.ErrMsg = "";
} log.Content = hk.ToJsonString();
else try
{
string rfidStr = hk.rfid;
if (!string.IsNullOrEmpty(hk.rfid))
{ {
AnasysBuffer(ref rfidStr); FilterBuffer(ref hk);
hk.rfid = rfidStr;
}
}
ScanLogSocket scan = new ScanLogSocket() ScanLogSocket scan = new ScanLogSocket()
{ {
@ -94,7 +88,16 @@ namespace SlnMesnac.TouchSocket
timestamp = hk.timestamp, timestamp = hk.timestamp,
url = hk.url url = hk.url
}; };
ba= ScanBack(scan); ba = ScanBack(scan);
}
catch (Exception e)
{
_logger.LogError(e, e.Message);
log.LogLevel = "Error";
log.ErrMsg = e.Message;
}
_baseLogService.Insert(log);
} }
else else
@ -128,8 +131,8 @@ namespace SlnMesnac.TouchSocket
[WebApi(HttpMethodType.POST)] [WebApi(HttpMethodType.POST)]
public Back ScanStatus(ScanStatusSocket scanStatus) public Back ScanStatus(ScanStatusSocket scanStatus)
{ {
_logger.LogInformation("扫描的状态接口"); //_logger.LogInformation("扫描的状态接口");
_logger.LogInformation("{Data}",scanStatus.ToJsonString()); //_logger.LogInformation("{Data}",scanStatus.ToJsonString());
BaseLog log = new BaseLog BaseLog log = new BaseLog
{ {
LogLevel = "Info", LogLevel = "Info",
@ -180,15 +183,19 @@ namespace SlnMesnac.TouchSocket
public Back ScanBack(ScanLogSocket scanLog) public Back ScanBack(ScanLogSocket scanLog)
{ {
_logger.LogInformation("扫描数据回传接口"); //_logger.LogInformation("扫描数据回传接口");
_logger.LogInformation("{Data}", scanLog.ToJsonString()); //_logger.LogInformation("{Data}", scanLog.ToJsonString());
BaseLog log = new BaseLog(); string result = string.Empty;
log.LogLevel = "Info"; if (string.IsNullOrEmpty(scanLog.code) || scanLog.code == "noread")
log.ErrMsg = "";
log.Content = scanLog.ToJsonString();
try
{ {
result = scanLog.rfid;
}
else
{
result = scanLog.code;
}
var model = new ScanLogModel() var model = new ScanLogModel()
{ {
CreateTime = scanLog.CreateTime, CreateTime = scanLog.CreateTime,
@ -196,21 +203,13 @@ namespace SlnMesnac.TouchSocket
Code = scanLog.code, Code = scanLog.code,
Rfid = scanLog.rfid, Rfid = scanLog.rfid,
Ocr = scanLog.ocr, Ocr = scanLog.ocr,
Url = scanLog.url Url = scanLog.url,
Result = result,
}; };
ScanLogSocketAction?.Invoke(model); ScanLogSocketAction?.Invoke(model);
_scanService.Insert(model); _scanService.Insert(model);
}
catch (Exception e)
{
_logger.LogError(e, e.Message);
log.LogLevel = "Error";
log.ErrMsg = e.Message;
}
_baseLogService.Insert(log);
return new Back(); return new Back();
} }
@ -233,6 +232,63 @@ namespace SlnMesnac.TouchSocket
} }
} }
private void FilterBuffer(ref Hk hk)
{
try
{
if (hk.rfid == "noread" || string.IsNullOrEmpty(hk.rfid))
{
if (!string.IsNullOrEmpty(hk.code) && hk.code != "noread")
{
hk.rfid = hk.code;
}
}
else
{
string[] buffer = hk.rfid.Split(",");
if (buffer.Length > 1)
{
hk.rfid = "多条码";
}
else
{
string rfidStr = hk.rfid;
if (!string.IsNullOrEmpty(hk.rfid))
{
AnasysBuffer(ref rfidStr);
if(rfidStr != hk.code && !string.IsNullOrEmpty(hk.code) && hk.code != "noread")
{
hk.rfid = hk.code;
}
else
{
hk.rfid = rfidStr;
}
}
}
}
//处理ATR数据
if (string.IsNullOrEmpty(hk.code) || hk.code == "noread")
{
if (hk.rfid != "多条码" && hk.rfid != "noread")
{
hk.code = hk.rfid;
}
}
}
catch(Exception ex)
{
throw new InvalidOperationException($"标签处理逻辑异常:{ex.Message}");
}
}
} }
} }

@ -153,7 +153,7 @@
<DataGridTextColumn Binding="{Binding Rfid}" Header="RFID" Width="2*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Rfid}" Header="RFID" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Code}" Header="ATR" Width="2*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Code}" Header="ATR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Ocr}" Header="OCR" Width="2*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Ocr}" Header="OCR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Url}" Header="图像路径" Width="2*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Result}" Header="最终结果" Width="2*" IsReadOnly="True"/>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Border> </Border>

@ -13,7 +13,7 @@
{ {
"configId": "mes", "configId": "mes",
"dbType": 4, "dbType": 4,
"connStr": "PORT=5432;DATABASE=daxing;HOST=127.0.0.1;PASSWORD=123456;USER ID=postgres" "connStr": "PORT=5432;DATABASE=daxing;HOST=192.168.0.103;PASSWORD=123456;USER ID=postgres"
} }
] ]
} }

Loading…
Cancel
Save