fature
This commit is contained in:
@ -51,7 +51,7 @@ namespace 货架标准上位机.ViewModel
|
||||
if (newBytes > 0)
|
||||
{
|
||||
var currentScanedCode = Encoding.UTF8.GetString(e.ByteBlock, 0, e.ByteBlock.Len);
|
||||
Logs.Write($"接收到扫码枪扫码数据{currentScanedCode}");
|
||||
Logs.Write($"接收到扫码枪[{scanner.COM}]扫码数据{currentScanedCode}", LogsType.Scanner);
|
||||
scanner.TempCode += currentScanedCode;
|
||||
//校验末尾码
|
||||
CheckDataCompleteness(scanner);
|
||||
@ -88,11 +88,18 @@ namespace 货架标准上位机.ViewModel
|
||||
var isModuleCode = Regex.IsMatch(scanner.TempCode, ModuleCodePattern);
|
||||
if (isModuleCode)
|
||||
{
|
||||
Logs.Write($"[{scanner.COM}]校验到扫码数据为货架码【{scanner.TempCode}】", LogsType.Scanner);
|
||||
ModuleCodeProcess(scanner);
|
||||
}
|
||||
else if (scanner.TempCode == "shelfGoOutInStore")
|
||||
{
|
||||
Logs.Write($"[{scanner.COM}]校验到扫码数据为结束入库码【{scanner.TempCode}】", LogsType.Scanner);
|
||||
ShelfGoOutInstoreProcess(scanner);
|
||||
}
|
||||
//TODO 增加正则表达式进行判断是否扫到的是物料码
|
||||
else
|
||||
{
|
||||
Logs.Write($"[{scanner.COM}]校验到扫码数据为物料码【{scanner.TempCode}】", LogsType.Scanner);
|
||||
MatSnProcess(scanner);
|
||||
}
|
||||
}
|
||||
@ -118,13 +125,15 @@ namespace 货架标准上位机.ViewModel
|
||||
//如果扫码枪前一个货架未退出入库
|
||||
if (scanner.IsInstoreMode)
|
||||
{
|
||||
//判断当前入库货架是否包含本次扫码的模组
|
||||
//判断当前入库货架是否包含本次扫码的模组 表示用户重复对货架码进行扫码 不能让其多次进入入库
|
||||
if (scanner.ModulesStr.Contains(scanner.TempCode))
|
||||
{
|
||||
Logs.Write($"当前扫码模组{scanner.TempCode},是当前入库货架{scanner.ShelfCode}的模组,不进行操作!", LogsType.Scanner);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logs.Write($"当前扫码模组{scanner.TempCode},不是当前入库货架{scanner.ShelfCode}的模组,先进行当前入库货架的退出入库操作!", LogsType.Scanner);
|
||||
#region 调用接口结束扫码枪占用入库的货架
|
||||
try
|
||||
{
|
||||
@ -135,26 +144,32 @@ namespace 货架标准上位机.ViewModel
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseBase>(LocalFile.Config.ApiIpHost + "instore/shelfGoOutInStore", body, "POST");
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseBase>(LocalFile.Config.ApiIpHost + "instore/shelfGoOutInStore", body, "POST", true);
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
Logs.Write($"货架{scanner.ShelfCode}已成功退出入库!", LogsType.Scanner);
|
||||
scanner.ShelfCode = string.Empty;
|
||||
scanner.ModulesStr = string.Empty;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Logs.Write($"货架{scanner.ShelfCode}退出入库失败!", LogsType.Scanner);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Logs.Write($"货架{scanner.ShelfCode}退出入库失败!发生异常:{ex.Message}", LogsType.Scanner);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
//调用接口 请求进入入库模式
|
||||
//调用接口 本次扫码的货架进入入库模式
|
||||
#region 调用接口进入入库模式
|
||||
try
|
||||
{
|
||||
Logs.Write($"扫码模组{scanner.TempCode},请求进入入库!", LogsType.Scanner);
|
||||
var body = new ShelfGoInInstoreRequest()
|
||||
{
|
||||
ModuleCode = scanner.TempCode,
|
||||
@ -165,20 +180,25 @@ namespace 货架标准上位机.ViewModel
|
||||
var Result = ApiHelp.GetDataFromHttp<ShelfGoInInstoreResponse>(LocalFile.Config.ApiIpHost + "instore/shelfGoInInStore", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
Logs.Write($"扫码模组{scanner.TempCode},进入入库模式成功!", LogsType.Scanner);
|
||||
scanner.IsInstoreMode = true;
|
||||
scanner.ShelfCode = Result.Data.ShelfCode;
|
||||
scanner.ModulesStr = Result.Data.ModulesStr;
|
||||
//TODO 清除其他扫码枪的占用
|
||||
|
||||
//清除其他扫码枪的占用
|
||||
var sacnners = ScannerManager.Scanners
|
||||
.Where(t => ShelfCode == Result.Data.ShelfCode)
|
||||
.Where(t => t.COM != scanner.COM)
|
||||
.ToList();
|
||||
foreach (var item in sacnners)
|
||||
foreach (var scanner1 in sacnners)
|
||||
{
|
||||
item.ShelfCode = string.Empty;
|
||||
scanner1.ShelfCode = string.Empty;
|
||||
scanner1.ModulesStr = string.Empty;
|
||||
}
|
||||
}
|
||||
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
|
||||
{
|
||||
Logs.Write($"扫码模组{scanner.TempCode},进入入库模式失败!{Result.Message}", LogsType.Scanner);
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
}
|
||||
@ -189,6 +209,36 @@ namespace 货架标准上位机.ViewModel
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫码枪扫到结束码
|
||||
/// </summary>
|
||||
/// <param name="scanner"></param>
|
||||
public void ShelfGoOutInstoreProcess(Scanner scanner)
|
||||
{
|
||||
#region 调用接口结束扫码枪占用入库的货架
|
||||
try
|
||||
{
|
||||
var body = new ShelfGoOutInStoreRequest()
|
||||
{
|
||||
ShelfCode = scanner.ShelfCode,
|
||||
IPAdress = scanner.COM,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseBase>(LocalFile.Config.ApiIpHost + "instore/shelfGoOutInStore", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
scanner.ShelfCode = string.Empty;
|
||||
scanner.ModulesStr = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// 扫到物料码的数据处理
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user