|
|
|
@ -68,6 +68,16 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
// sn扫码器ip
|
|
|
|
|
private static string SnScannerIp = allScanners.First(x => x.Name == "sn扫码器").Ip;
|
|
|
|
|
|
|
|
|
|
private SpeechStr speechStr = SpeechStr.Instance;
|
|
|
|
|
|
|
|
|
|
private string ProductLineCode = Appsettings.app("StationInfo", "ProductLineCode");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 质检记录
|
|
|
|
|
private readonly IReportQualityInspectionServices? _reportQualityInspectionServices;
|
|
|
|
|
//异常记录,记录质检失败情况
|
|
|
|
|
private readonly IExceptionRecordServices? exceptionRecordServices;
|
|
|
|
|
|
|
|
|
|
public IndexPageViewModel()
|
|
|
|
|
{
|
|
|
|
@ -76,9 +86,10 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
_codeBindingRecordServices = App.ServiceProvider.GetService<ICodeBindingRecordServices>();
|
|
|
|
|
_baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
|
|
|
|
|
_baseMaterialInfoServices = App.ServiceProvider.GetService<IBaseMaterialInfoServices>();
|
|
|
|
|
|
|
|
|
|
_reportQualityInspectionServices = App.ServiceProvider.GetService<IReportQualityInspectionServices>();
|
|
|
|
|
_printBarCodeServices = App.ServiceProvider.GetService<IPrintBarCodeServices>();
|
|
|
|
|
_iMaterialCompletionServices = App.ServiceProvider.GetService<IMaterialCompletionServices>();
|
|
|
|
|
exceptionRecordServices = App.ServiceProvider.GetService<IExceptionRecordServices>();
|
|
|
|
|
// Business.MvCodeHelper.ReceiveCodeEvent += ReceiveCode;
|
|
|
|
|
// Business.MvCodeHelper.BindingCodeEvent += BindingCode;
|
|
|
|
|
// Business.MvCodeHelper.NoReadEvent += ReceiveNoRead;
|
|
|
|
@ -86,7 +97,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
TouchSocketService.NoReadReceiveEvent += ReceiveNoRead;
|
|
|
|
|
GunBusiness.BindingReceiveCodeEvent += BindingCode;
|
|
|
|
|
GunBusiness.RefreshMaterialCodeStrEvent += ReceiveCode;
|
|
|
|
|
|
|
|
|
|
MsgUIColor = "White";
|
|
|
|
|
LoadData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -94,11 +105,6 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
realBindingAndSendPlc();
|
|
|
|
|
LoadCharts();
|
|
|
|
|
|
|
|
|
|
//Task.Run(() =>
|
|
|
|
|
//{
|
|
|
|
|
// Thread.Sleep(4000);
|
|
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -109,7 +115,6 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 实时绑定条码和实时下发plc放行信号
|
|
|
|
|
/// </summary>
|
|
|
|
@ -465,16 +470,18 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
|
|
|
|
|
SendPlcStop();
|
|
|
|
|
Clear();
|
|
|
|
|
RefreshAndWriteLog("MES条码未扫描到,NoRead报警,线体停止,请重新扫描!");
|
|
|
|
|
RefreshAndWriteLog("MES条码未扫描到,NoRead报警,线体停止,请重新扫描!",true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (SnScannerIp == scannerIp)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SendPlcStop();
|
|
|
|
|
Clear();
|
|
|
|
|
RefreshAndWriteLog("SN条码未扫描到,NoRead报警,线体停止,请重新扫描!");
|
|
|
|
|
RefreshAndWriteLog("SN条码未扫描到,NoRead报警,线体停止,请重新扫描!", true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
speechStr.SpeakAsync("扫码失败,请补扫");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -577,15 +584,33 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
/// 提示信息刷新并且存日志
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logStr"></param>
|
|
|
|
|
private void RefreshAndWriteLog(string logStr)
|
|
|
|
|
private void RefreshAndWriteLog(string logStr,bool warnflag=false)
|
|
|
|
|
{
|
|
|
|
|
TimeSpan currentTime = DateTime.Now.TimeOfDay;
|
|
|
|
|
// DateTime time = System.DateTime.Now;
|
|
|
|
|
string timeString = currentTime.ToString(@"hh\:mm\:ss");
|
|
|
|
|
BindingInfo = timeString + ":" + logStr;
|
|
|
|
|
if(warnflag)
|
|
|
|
|
{
|
|
|
|
|
MsgUIColor = "Red";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MsgUIColor = "White";
|
|
|
|
|
}
|
|
|
|
|
log.Info(BindingInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提示信息-颜色
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string msgUIColor;
|
|
|
|
|
public string MsgUIColor
|
|
|
|
|
{
|
|
|
|
|
get => msgUIColor;
|
|
|
|
|
set => SetProperty(ref msgUIColor, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 条码绑定
|
|
|
|
|
/// </summary>
|
|
|
|
@ -598,16 +623,30 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
{
|
|
|
|
|
if (code1.Substring(0, 1) != "B")
|
|
|
|
|
{
|
|
|
|
|
speechStr.SpeakAsync("扫码失败,请补扫");
|
|
|
|
|
RefreshAndWriteLog("MES码:" + code1 + ",扫描错误,请重新扫描!");
|
|
|
|
|
SendPlcStop();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (code2.Length != 20)
|
|
|
|
|
{
|
|
|
|
|
speechStr.SpeakAsync("扫码失败,请补扫");
|
|
|
|
|
RefreshAndWriteLog("SN码:" + code2 + ",扫描错误,请重新扫描!");
|
|
|
|
|
SendPlcStop();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#region 终检校验-未查到终检合格记录即为质检不合格
|
|
|
|
|
|
|
|
|
|
ReportQualityInsPection qualityList = _reportQualityInspectionServices.JudgeIsQualified(code1);
|
|
|
|
|
if (qualityList == null)
|
|
|
|
|
{
|
|
|
|
|
SendPlcStop();
|
|
|
|
|
RefreshAndWriteLog($"终检失败!! 箱体码{code1}未查询到终检合格记录,请重新终检!",true);
|
|
|
|
|
speechStr.SpeakAsync("终检失败,请终检");
|
|
|
|
|
AddExceptionRecord(code1, $"终检失败!! 箱体码{code1}未查询到终检合格记录,请重新终检!", 4);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
RefreshAndWriteLog("开始绑定MES条码:" + code1 + " SN条码:" + code2);
|
|
|
|
|
// 1.数据库查询各个工序质检结果,不合格报警
|
|
|
|
|
|
|
|
|
@ -677,7 +716,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RefreshAndWriteLog("条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】绑定失败");
|
|
|
|
|
RefreshAndWriteLog("条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】绑定失败", true);
|
|
|
|
|
if (SendPlcStop())
|
|
|
|
|
{
|
|
|
|
|
RefreshAndWriteLog("条码绑定失败,线体停止");
|
|
|
|
@ -697,6 +736,31 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 往mes数据库添加异常记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="SNCode"></param>
|
|
|
|
|
/// <param name="Msg"></param>
|
|
|
|
|
/// <param name="Type">1=69码校验;2=重复扫描;3=未绑条码;4=未终检</param>
|
|
|
|
|
public async void AddExceptionRecord(string BoxCode, string Msg, int Type)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ExceptionRecord record = new ExceptionRecord();
|
|
|
|
|
record.ProductSnCode = BoxCode;
|
|
|
|
|
record.ProductScanTime = DateTime.Now;
|
|
|
|
|
record.ProductLineCode = ProductLineCode;
|
|
|
|
|
record.ExceptionMsg = Msg;
|
|
|
|
|
record.ExceptionType = Type;
|
|
|
|
|
record.Position = "条码绑定";
|
|
|
|
|
await exceptionRecordServices.AddAsync(record);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Info("添加异常记录方法AddExceptionRecord异常:" + ex.Message.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region plc交互
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|