提交代码

This commit is contained in:
hehaibing-1996
2024-07-16 16:45:18 +08:00
parent ed3673db03
commit 7b8a885669
64 changed files with 1389 additions and 176 deletions

View File

@ -57,11 +57,12 @@ namespace 货架标准上位机.ViewModel
scanner.TempCode += currentScanedCode;
//校验末尾码
CheckDataCompleteness(scanner);
scanner.ScannerDisplayControl.RefreshValues(scanner.ShelfCode, scanner.MatSn);
scanner.ScannerDisplayControl.RefreshValues(scanner.ShelfCode, scanner.MatSn, scanner.InstoreUser);
}
return EasyTask.CompletedTask;
};
}
RevertScannerStatus();
}
#region Property
@ -77,6 +78,58 @@ namespace 货架标准上位机.ViewModel
#endregion
#region Command
/// <summary>
/// 第一次加载时 获取服务器对应货架是否在入库模式 是否是扫码枪启动的 还原扫码枪的状态
/// </summary>
public void RevertScannerStatus()
{
Task.Run(() =>
{
Thread.Sleep(1000);
try
{
var body = new GetShelfStatusRequest()
{
UserName = LocalStatic.CurrentUser,
DeviceType = "WCS前端",
GroupNames = LocalFile.Config.GroupName,
};
var Result = ApiHelp.Post<GetShelfStatusResponse>([LocalFile.Config.ApiIpHost, "home/getShelfStatus"], body).Result;
if (Result != null && Result.Data != null && Result.Data?.Count > 0)
{
var shelfs = Result.Data.Where(t => t.CurentMode == 1 && !string.IsNullOrEmpty(t.CurrentCom)).ToList();
if (shelfs == null || shelfs.Count == 0)
return;
Logs.Write($"【启动时发现需要恢复扫码枪状态】{string.Join(",", shelfs.Select(t => t.CurrentCom).ToList())}", LogsType.Scanner);
foreach (var shelf in shelfs)
{
var scanner = ScannerManager.Scanners.Where(t => t.COM == shelf.CurrentCom).FirstOrDefault();
if (scanner != null)
{
scanner.IsInstoreMode = true;
scanner.IsInstoreModeTime = shelf.SetCurrentModeTime;
scanner.ShelfCode = shelf.ShelfCode;
scanner.ModulesStr = shelf.ModulesStr;
scanner.ScannerDisplayControl.RefreshValues(scanner.ShelfCode, scanner.MatSn, scanner.InstoreUser);
Logs.Write($"【恢复扫码枪】{scanner.COM}", LogsType.Scanner);
}
}
}
}
catch (Exception ex)
{
}
finally
{
}
});
}
public void CheckDataCompleteness(Scanner scanner)
{
if (scanner.TempCode.EndsWith("\r"))//结束符 TODO结束符是否需要自定义 现场配置
@ -118,7 +171,24 @@ namespace 货架标准上位机.ViewModel
Logs.Write($"[{scanner.COM}]校验到扫码数据为结束入库码【{scanner.TempCode}】", LogsType.Scanner);
ShelfGoOutInstoreProcess(scanner);
}
//TODO 增加正则表达式进行判断是否扫到的是物料码
else if (scanner.TempCode.ToUpper().Contains("MXID") && scanner.TempCode.ToUpper().Contains("NAME"))
{
string pattern = @"\b\d{6}\b"; // 匹配一个完整的6位数字
Match match = Regex.Match(scanner.TempCode, pattern);
if (match.Success)
{
scanner.InstoreUser = match.Value;
}
else
{
//
Logs.Write($"扫码枪扫到{scanner.TempCode},无法解析出工号!", LogsType.Scanner);
}
}
else if (Regex.IsMatch(scanner.TempCode, @"^\d{6}$"))
{
scanner.InstoreUser = scanner.TempCode;
}
else
{
Logs.Write($"[{scanner.COM}]校验到扫码数据为物料码【{scanner.TempCode}】", LogsType.Scanner);
@ -164,7 +234,7 @@ namespace 货架标准上位机.ViewModel
ShelfCode = scanner.ShelfCode,
IPAdress = scanner.COM,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser,
UserName = string.IsNullOrEmpty(scanner.InstoreUser) ? LocalStatic.CurrentUser : scanner.InstoreUser,
};
var Result = ApiHelp.GetDataFromHttp<ResponseBase>(LocalFile.Config.ApiIpHost + "instore/shelfGoOutInStore", body, "POST", true);
if (Result != null && Result.Code == 200)
@ -197,7 +267,7 @@ namespace 货架标准上位机.ViewModel
{
ModuleCode = scanner.TempCode,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser,
UserName = string.IsNullOrEmpty(scanner.InstoreUser) ? LocalStatic.CurrentUser : scanner.InstoreUser,
IpAdress = scanner.COM,
};
var Result = ApiHelp.GetDataFromHttp<ShelfGoInInstoreResponse>(LocalFile.Config.ApiIpHost + "instore/shelfGoInInStore", body, "POST");
@ -247,7 +317,7 @@ namespace 货架标准上位机.ViewModel
ShelfCode = scanner.ShelfCode,
IPAdress = scanner.COM,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser,
UserName = string.IsNullOrEmpty(scanner.InstoreUser) ? LocalStatic.CurrentUser : scanner.InstoreUser,
};
var Result = ApiHelp.GetDataFromHttp<ResponseBase>(LocalFile.Config.ApiIpHost + "instore/shelfGoOutInStore", body, "POST");
if (Result != null && Result.Code == 200)
@ -277,7 +347,7 @@ namespace 货架标准上位机.ViewModel
ShelfCode = scanner.ShelfCode,
IpAddress = scanner.COM,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser,
UserName = string.IsNullOrEmpty(scanner.InstoreUser) ? LocalStatic.CurrentUser : scanner.InstoreUser,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<MatInfoModel>>(LocalFile.Config.ApiIpHost + "instore/queryByMatSn", body, "POST");
if (Result != null && Result.Code == 200)
@ -294,14 +364,14 @@ namespace 货架标准上位机.ViewModel
ShelfCode = scanner.ShelfCode,
IpAddress = scanner.COM,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser,
UserName = string.IsNullOrEmpty(scanner.InstoreUser) ? LocalStatic.CurrentUser : scanner.InstoreUser,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<MatInfoModel>>(LocalFile.Config.ApiIpHost + "instore/queryInstoreStatus", body, "POST");
if (Result != null && !string.IsNullOrEmpty(Result.Message))
{
TextBoxLog.AddLog($"物料[{scanner.MatSn}]" + Result.Message, "InstoreLog", DateTime.Now);
scanner.MatSn = string.Empty;
scanner.ScannerDisplayControl.RefreshValues(scanner.ShelfCode, scanner.MatSn);
scanner.ScannerDisplayControl.RefreshValues(scanner.ShelfCode, scanner.MatSn, scanner.InstoreUser);
}
}
catch (Exception ex)
@ -337,7 +407,7 @@ namespace 货架标准上位机.ViewModel
{
ShelfCode = t.ShelfCode,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser,
UserName = string.IsNullOrEmpty(t.InstoreUser) ? LocalStatic.CurrentUser : t.InstoreUser,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "instore/shelfGoOutInStore", body, "POST");
if (Result != null && Result.Code == 200)
@ -346,7 +416,7 @@ namespace 货架标准上位机.ViewModel
t.ShelfCode = string.Empty;
t.MatSn = string.Empty;
t.ScannerDisplayControl.RefreshValues(t.ShelfCode, t.MatSn);
t.ScannerDisplayControl.RefreshValues(t.ShelfCode, t.MatSn, t.InstoreUser);
Growl.Success(Result.Message);
}
}