From c7b19faa98e33b6ae540c099daa2bd46623e4dd0 Mon Sep 17 00:00:00 2001 From: wenjy Date: Tue, 8 Oct 2024 13:45:57 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=B7=BB=E5=8A=A0=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E7=AE=97=E6=B3=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Model/domain/ScanLog.cs | 3 + SlnMesnac.TouchSocket/ApiServer.cs | 154 ++++++++++++++++++--------- SlnMesnac.WPF/Page/IndexControl.xaml | 2 +- SlnMesnac.WPF/appsettings.json | 2 +- 4 files changed, 110 insertions(+), 51 deletions(-) diff --git a/SlnMesnac.Model/domain/ScanLog.cs b/SlnMesnac.Model/domain/ScanLog.cs index f727fa3..1ec91ee 100644 --- a/SlnMesnac.Model/domain/ScanLog.cs +++ b/SlnMesnac.Model/domain/ScanLog.cs @@ -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; } } } \ No newline at end of file diff --git a/SlnMesnac.TouchSocket/ApiServer.cs b/SlnMesnac.TouchSocket/ApiServer.cs index 9bd4fde..05aa421 100644 --- a/SlnMesnac.TouchSocket/ApiServer.cs +++ b/SlnMesnac.TouchSocket/ApiServer.cs @@ -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}"); + } + } } } diff --git a/SlnMesnac.WPF/Page/IndexControl.xaml b/SlnMesnac.WPF/Page/IndexControl.xaml index e4a9708..d1eea11 100644 --- a/SlnMesnac.WPF/Page/IndexControl.xaml +++ b/SlnMesnac.WPF/Page/IndexControl.xaml @@ -153,7 +153,7 @@ - + diff --git a/SlnMesnac.WPF/appsettings.json b/SlnMesnac.WPF/appsettings.json index b10cf44..15cfd32 100644 --- a/SlnMesnac.WPF/appsettings.json +++ b/SlnMesnac.WPF/appsettings.json @@ -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" } ] }