|
|
|
@ -49,6 +49,10 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
private readonly IMaterialCompletionServices? _iMaterialCompletionServices;
|
|
|
|
|
// 静态变量存code1
|
|
|
|
|
private static string code1Str = string.Empty;
|
|
|
|
|
|
|
|
|
|
// 静态变量存code2
|
|
|
|
|
private static string code2Str = string.Empty;
|
|
|
|
|
|
|
|
|
|
// 定时检测数据库有没有pad绑定未放行的数据
|
|
|
|
|
System.Timers.Timer timer = new System.Timers.Timer(1000);
|
|
|
|
|
public IndexPageViewModel()
|
|
|
|
@ -61,19 +65,61 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
|
|
|
|
|
_printBarCodeServices = App.ServiceProvider.GetService<IPrintBarCodeServices>();
|
|
|
|
|
_iMaterialCompletionServices = App.ServiceProvider.GetService<IMaterialCompletionServices>();
|
|
|
|
|
MvCodeHelper.ReceiveCode1Event += receiveCode1;
|
|
|
|
|
MvCodeHelper.ReceiveCode1Event += receiveCode1;
|
|
|
|
|
MvCodeHelper.ReceiveCode2Event += receiveCode2;
|
|
|
|
|
// pda手持检测plc放行定时器
|
|
|
|
|
// StartPlcTimer();
|
|
|
|
|
LoadData();
|
|
|
|
|
//receiveCode2("B23000000824");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 实时绑定两个条码
|
|
|
|
|
realBinding();
|
|
|
|
|
// pda手持检测plc放行定时器
|
|
|
|
|
StartPlcTimer();
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
receiveCode1("L23000000899");
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
|
receiveCode2("B23000000824");
|
|
|
|
|
//Thread.Sleep(6000);
|
|
|
|
|
//receiveCode1("993000000899");
|
|
|
|
|
//receiveCode2("993000000824");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void realBinding()
|
|
|
|
|
{
|
|
|
|
|
string tempCode1 ;
|
|
|
|
|
string tempCode2;
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
while(true)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(code1Str) && !string.IsNullOrEmpty(code2Str))
|
|
|
|
|
{
|
|
|
|
|
tempCode1 = code1Str;
|
|
|
|
|
tempCode2 = code2Str;
|
|
|
|
|
code1Str = string.Empty;
|
|
|
|
|
code2Str = string.Empty;
|
|
|
|
|
BindingCode(tempCode1, tempCode2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 开启定时器定时读取数据库并下发plc放行信号
|
|
|
|
|
/// </summary>
|
|
|
|
@ -348,33 +394,33 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
//log.Info("条码1记录更新");
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 条码绑定,条码2处理
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
private async void receiveCode2(string code2)
|
|
|
|
|
{
|
|
|
|
|
log.Info("进入条码2处理函数receiveCode2,code2:" + code2);
|
|
|
|
|
|
|
|
|
|
// 1.刷新界面条码信息
|
|
|
|
|
// 全局变量赋值,SN码扫描后使用
|
|
|
|
|
code2Str = code2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void BindingCode(string code1,string code2)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
log.Info("进入条码2处理函数receiveCode1,code2:" + code2);
|
|
|
|
|
// 取之前读出来的code1
|
|
|
|
|
string code1 = code1Str;
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(code1))
|
|
|
|
|
{
|
|
|
|
|
// 刷新页面提示信息
|
|
|
|
|
BindingInfo = "箱体码还未扫码";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
log.Info("开始处理条码绑定:");
|
|
|
|
|
|
|
|
|
|
// 1.数据库查询各个工序质检结果,不合格报警
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2.查询条码绑定记录表(内胆箱壳绑定处就应该插入记录),绑定SN码
|
|
|
|
|
List<CodeBindingRecord> list = await _codeBindingRecordServices.QueryAsync(x => x.BoxCode == code1);
|
|
|
|
|
CodeBindingRecord record = list.FirstOrDefault();
|
|
|
|
|
List<BaseMaterialInfo> materialInfoList = await _baseMaterialInfoServices.QueryAsync(x => x.MaterialCode == code2.Substring(2, 10));
|
|
|
|
|
record.BoxName = materialInfoList.FirstOrDefault().MaterialName;
|
|
|
|
|
CodeBindingRecord record = _codeBindingRecordServices.FirstAsync(x => x.BoxCode == code1).Result;
|
|
|
|
|
|
|
|
|
|
BaseMaterialInfo materialInfo = _baseMaterialInfoServices.FirstAsync(x => x.MaterialCode == code2.Substring(2, 10)).Result;
|
|
|
|
|
record.BoxName = materialInfo.MaterialName;
|
|
|
|
|
record.ProductCode = code2;
|
|
|
|
|
record.RecordTime1 = System.DateTime.Now;
|
|
|
|
|
record.RecordTime2 = System.DateTime.Now;
|
|
|
|
@ -385,31 +431,38 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
{
|
|
|
|
|
record.isPlcPass = 2;
|
|
|
|
|
}
|
|
|
|
|
await _codeBindingRecordServices.UpdateAsync(record);
|
|
|
|
|
_codeBindingRecordServices.UpdateAsync(record);
|
|
|
|
|
|
|
|
|
|
#region 更新过点数据,插入记录到MATERIAL_COMPLETION表
|
|
|
|
|
PrintBarCode print = await _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == code1);
|
|
|
|
|
if (print != null) return;
|
|
|
|
|
MaterialCompletion completion = new MaterialCompletion();
|
|
|
|
|
completion.OrderCode = print.OrderCode;
|
|
|
|
|
completion.MaterialBarcode = code1;
|
|
|
|
|
completion.MaterialCode = print.MaterialCode;
|
|
|
|
|
completion.MaterialName = print.MaterialName;
|
|
|
|
|
completion.StationName = "1007";
|
|
|
|
|
completion.CompleteDate = DateTime.Now;
|
|
|
|
|
await _iMaterialCompletionServices.AddAsync(completion);
|
|
|
|
|
//PrintBarCode print = await _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == code1);
|
|
|
|
|
//if (print != null) return;
|
|
|
|
|
//MaterialCompletion completion = new MaterialCompletion();
|
|
|
|
|
//completion.OrderCode = print.OrderCode;
|
|
|
|
|
//completion.MaterialBarcode = code1;
|
|
|
|
|
//completion.MaterialCode = print.MaterialCode;
|
|
|
|
|
//completion.MaterialName = print.MaterialName;
|
|
|
|
|
//completion.StationName = "1007";
|
|
|
|
|
//completion.CompleteDate = DateTime.Now;
|
|
|
|
|
//await _iMaterialCompletionServices.AddAsync(completion);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// 2.刷新界面信息
|
|
|
|
|
code1Str = string.Empty;
|
|
|
|
|
|
|
|
|
|
RefreshCode2(record);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
code1Str = string.Empty;
|
|
|
|
|
code2Str = string.Empty;
|
|
|
|
|
Console.WriteLine(ex.Message.ToString());
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
code1Str = string.Empty;
|
|
|
|
|
code2Str = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region plc交互
|
|
|
|
|