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,31 +70,34 @@ 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";
log.ErrMsg = "";
log.Content = hk.ToJsonString();
try
{ {
hk.rfid = hk.ocr; FilterBuffer(ref hk);
}
else
{ ScanLogSocket scan = new ScanLogSocket()
string rfidStr = hk.rfid;
if (!string.IsNullOrEmpty(hk.rfid))
{ {
AnasysBuffer(ref rfidStr); code = hk.code,
hk.rfid = rfidStr; 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, _logger.LogError(e, e.Message);
data_type = hk.data_type, log.LogLevel = "Error";
ocr = hk.ocr, log.ErrMsg = e.Message;
rfid = hk.rfid, }
timestamp = hk.timestamp, _baseLogService.Insert(log);
url = hk.url
};
ba= ScanBack(scan);
} }
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,37 +183,33 @@ 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
{ {
var model = new ScanLogModel() result = scanLog.rfid;
{
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);
} }
catch (Exception e) else
{ {
_logger.LogError(e, e.Message); result = scanLog.code;
log.LogLevel = "Error";
log.ErrMsg = e.Message;
} }
_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(); 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