1.解析失败抛异常就不上传了 避免一直上传造成的日志记录繁多 以及请求次数过多

2.增加物料规格的显示
This commit is contained in:
hehaibing-1996
2025-06-06 08:12:28 +08:00
parent 18be7b8119
commit b64103e6f3
3 changed files with 24 additions and 3 deletions

View File

@ -355,7 +355,18 @@ namespace WCS.BLL.HardWare
jsonString.Replace("\\\\\"\\", string.Empty);
// 去除所有双引号前面的反斜杠
jsonString = Regex.Replace(jsonString, @"\\(.)", "$1"); ;
var data = JsonConvert.DeserializeObject<List<StockQueryResponseDataItem>>(jsonString);
List<StockQueryResponseDataItem>? data = null;
try
{
data = JsonConvert.DeserializeObject<List<StockQueryResponseDataItem>>(jsonString);
}
catch (Exception ex)
{
Logs.Write($"【库存信息反序列化失败】返回的json字符串为:\r\n{jsonString},无法成功反序列化");
module.IsNeedRefresh = false;
continue;
}
if (data != null && data.Count > 0)
{
//硬件只能显示7个 只保留前7个
@ -371,7 +382,7 @@ namespace WCS.BLL.HardWare
module.SendTaskId(taskid++, TcpCleint);
module.SendMatCode(item.material_code, TcpCleint);
module.SendMatName(item.material_name, TcpCleint);
module.SendMatSpec("-", TcpCleint);
module.SendMatSpec(item.material_spec, TcpCleint);
module.SendMatBatch(item.batch_no, TcpCleint);
module.SendMatQty((int)item.qty, TcpCleint);
}

View File

@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
@ -27,5 +28,11 @@ namespace WCS.Model.ApiModel.MKYBackgroundThread
public string material_name { get; set; } = "-";
public string material_code { get; set; } = "-";
/// <summary>
/// 物料规格
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string material_spec { get; set; } = "-";
}
}

View File

@ -3,4 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>