change - 添加标签算法逻辑

master
wenjy 1 month ago
parent f205fd10c9
commit c7b19faa98

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

@ -70,31 +70,34 @@ namespace SlnMesnac.TouchSocket
_logger.LogInformation("==========================");
if (hk.data_type == 1)
{
if(hk.rfid == "noread")
BaseLog log = new BaseLog();
log.LogLevel = "Info";
log.ErrMsg = "";
log.Content = hk.ToJsonString();
try
{
hk.rfid = hk.ocr;
}
else
{
string rfidStr = hk.rfid;
if (!string.IsNullOrEmpty(hk.rfid))
FilterBuffer(ref hk);
ScanLogSocket scan = new ScanLogSocket()
{
AnasysBuffer(ref rfidStr);
hk.rfid = rfidStr;
}
}
code = hk.code,
data_type = hk.data_type,
ocr = hk.ocr,
rfid = hk.rfid,
timestamp = hk.timestamp,
url = hk.url
};
ba = ScanBack(scan);
ScanLogSocket scan = new ScanLogSocket()
}
catch (Exception e)
{
code = hk.code,
data_type = hk.data_type,
ocr = hk.ocr,
rfid = hk.rfid,
timestamp = hk.timestamp,
url = hk.url
};
ba= ScanBack(scan);
_logger.LogError(e, e.Message);
log.LogLevel = "Error";
log.ErrMsg = e.Message;
}
_baseLogService.Insert(log);
}
else
@ -128,8 +131,8 @@ namespace SlnMesnac.TouchSocket
[WebApi(HttpMethodType.POST)]
public Back ScanStatus(ScanStatusSocket scanStatus)
{
_logger.LogInformation("扫描的状态接口");
_logger.LogInformation("{Data}",scanStatus.ToJsonString());
//_logger.LogInformation("扫描的状态接口");
//_logger.LogInformation("{Data}",scanStatus.ToJsonString());
BaseLog log = new BaseLog
{
LogLevel = "Info",
@ -180,37 +183,33 @@ namespace SlnMesnac.TouchSocket
public Back ScanBack(ScanLogSocket scanLog)
{
_logger.LogInformation("扫描数据回传接口");
_logger.LogInformation("{Data}", scanLog.ToJsonString());
//_logger.LogInformation("扫描数据回传接口");
//_logger.LogInformation("{Data}", scanLog.ToJsonString());
BaseLog log = new BaseLog();
log.LogLevel = "Info";
log.ErrMsg = "";
log.Content = scanLog.ToJsonString();
try
string result = string.Empty;
if (string.IsNullOrEmpty(scanLog.code) || scanLog.code == "noread")
{
var model = new ScanLogModel()
{
CreateTime = scanLog.CreateTime,
DataType = scanLog.data_type,
Code = scanLog.code,
Rfid = scanLog.rfid,
Ocr = scanLog.ocr,
Url = scanLog.url
};
ScanLogSocketAction?.Invoke(model);
_scanService.Insert(model);
result = scanLog.rfid;
}
catch (Exception e)
else
{
_logger.LogError(e, e.Message);
log.LogLevel = "Error";
log.ErrMsg = e.Message;
result = scanLog.code;
}
_baseLogService.Insert(log);
var model = new ScanLogModel()
{
CreateTime = scanLog.CreateTime,
DataType = scanLog.data_type,
Code = scanLog.code,
Rfid = scanLog.rfid,
Ocr = scanLog.ocr,
Url = scanLog.url,
Result = result,
};
ScanLogSocketAction?.Invoke(model);
_scanService.Insert(model);
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 Code}" Header="ATR" 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>
</Border>

@ -13,7 +13,7 @@
{
"configId": "mes",
"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