change-条码绑定去重,下线扫码加69码

dev
liuwf 10 months ago
parent 8819fdde80
commit 64319bd8e5

@ -3726,6 +3726,11 @@
同步时间
</summary>
</member>
<member name="P:Admin.Core.Model.TemperatureHistory.IsFlag">
<summary>
是否同步给质检
</summary>
</member>
<member name="T:Admin.Core.Model.TestedCode_MES">
<summary>
测温历史记录

@ -575,7 +575,8 @@ namespace Aucma.Core.CodeBinding.ViewModels
RefreshAndWriteLog("开始绑定MES条码:" + code1 + " SN条码:" + code2);
// 1.数据库查询各个工序质检结果,不合格报警
//// 2.查询条码绑定记录表(内胆箱壳绑定处就应该插入记录)绑定SN码
//// 2.查询条码绑定记录表(内胆箱壳绑定处就应该插入记录)绑定SN码
int Repeatflag = 0;
CodeBindingRecord record = _codeBindingRecordServices.FirstAsync(x => x.BoxCode == code1).Result;
if (record == null)
{
@ -584,6 +585,10 @@ namespace Aucma.Core.CodeBinding.ViewModels
// 没有记录重新插入一条
record = new CodeBindingRecord();
}
else
{
Repeatflag = 1;
}
BaseMaterialInfo materialInfo = _baseMaterialInfoServices.FirstAsync(x => x.MaterialCode == code1.Substring(7, 10)).Result;
if(materialInfo == null)
@ -601,11 +606,11 @@ namespace Aucma.Core.CodeBinding.ViewModels
record.isPlcPass = 1;
record.BindingResult = "成功";
bool result = false;
if (string.IsNullOrEmpty(record.LinerCode))
if (Repeatflag==0)
{ // 没有记录,新加
result = _codeBindingRecordServices.AddAsync(record).Result >0? true: false;
}
else
else if(Repeatflag==1)
{
result = _codeBindingRecordServices.UpdateAsync(record).Result;
}

@ -136,7 +136,7 @@
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Margin="15 120 0 0" Width="100" Height="40" FontSize="20" Cursor="Hand" Content="放 行" Background="#FF9900" BorderBrush="#FF9900" Click="Button_Click" />
<!--<Button Grid.Column="0" Margin="15 120 0 0" Width="100" Height="40" FontSize="20" Cursor="Hand" Content="放 行" Background="#FF9900" BorderBrush="#FF9900" Click="Button_Click" />-->
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="100 0 0 0 ">
<Label Content="提示信息 " FontSize="20" Foreground="#FFFFFF"/>

@ -29,12 +29,18 @@ namespace Aucma.Core.ProductOffLine.Business
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MvCodeHelper));
#region 全局变量定义
public static MvCodeReader ShellDevice = null;
public static MvCodeReader ShellDevice = null;
public static MvCodeReader LinerDevice = null;
public static DateTime ShellLiveTime = DateTime.Now;
public static DateTime LinerLiveTime = DateTime.Now;
private static string ShellCode69 = string.Empty;
private static string ShellProductCode = string.Empty;
private static string LinerCode69 = string.Empty;
private static string LinerProductCode = string.Empty;
#endregion
#region 委托事件
@ -65,19 +71,19 @@ namespace Aucma.Core.ProductOffLine.Business
public static void ShellImageCallbackFunc(IntPtr pData, IntPtr pstFrameInfoEx2, IntPtr pUser)
{
string Code69 = string.Empty;
string ProductCode = string.Empty;
var stFrameInfo = (MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2)Marshal.PtrToStructure(pstFrameInfoEx2, typeof(MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2));
MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2 stBcrResult = (MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2)Marshal.PtrToStructure(stFrameInfo.UnparsedBcrList.pstCodeListEx2, typeof(MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2));
//更新扫码器存活时间
ShellLiveTime = DateTime.Now;
if (stBcrResult.nCodeNum <2)
if (stBcrResult.nCodeNum <=0)
{
Console.WriteLine(DateTime.Now + ":外侧--->No Read 处理");
Console.WriteLine(DateTime.Now + ":外侧--->No Read 处理,条码个数:"+ stBcrResult.nCodeNum);
log.Info(DateTime.Now + ":外侧--->No Read 处理");
ShellCode69 = string.Empty;
ShellProductCode = string.Empty;
}
else
{
@ -89,28 +95,32 @@ namespace Aucma.Core.ProductOffLine.Business
string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode);
Console.WriteLine(DateTime.Now + ":外侧扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
log.Info(DateTime.Now + ":外侧扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
if (strCode.Trim().TrimEnd('\0').Length == 20)
if (strCode.Trim().TrimEnd('\0').Replace("\r\n", "").Length == 20)
{
ProductCode = strCode;
// RefreshMaterialCodeStrEvent?.Invoke(strCode.Trim().TrimEnd('\0'), ShellScannerIp);
// 业务处理
ShellProductCode = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
}
if (strCode.Trim().TrimEnd('\0').Length == 13)
if (strCode.Trim().TrimEnd('\0').Replace("\r\n", "").Length == 13)
{
ShellCode69 = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
}
if(!string.IsNullOrEmpty(ShellProductCode)&& !string.IsNullOrEmpty(ShellCode69))
{
Code69 = strCode;
// RefreshMaterialCodeStrEvent?.Invoke(strCode.Trim().TrimEnd('\0'), ShellScannerIp);
// 业务处理
Console.WriteLine("69码:" + ShellCode69 + ";成品:" + ShellProductCode + "=====>业务处理");
RefreshMaterialCodeStrEvent?.Invoke(ShellProductCode, ShellCode69, ShellScannerIp);
ShellCode69 = string.Empty;
ShellProductCode = string.Empty;
}
}
}
Console.WriteLine("69:" + Code69);
Console.WriteLine("成品:" + ProductCode);
RefreshMaterialCodeStrEvent?.Invoke(ProductCode,Code69, ShellScannerIp);
}
MvCodeReader.MV_CODEREADER_OCR_INFO_LIST stOcrInfo = (MvCodeReader.MV_CODEREADER_OCR_INFO_LIST)Marshal.PtrToStructure(stFrameInfo.UnparsedOcrList.pstOcrList, typeof(MvCodeReader.MV_CODEREADER_OCR_INFO_LIST));
}
@ -124,11 +134,12 @@ namespace Aucma.Core.ProductOffLine.Business
//更新扫码器存活时间
LinerLiveTime = DateTime.Now;
if (stBcrResult.nCodeNum < 2)
if (stBcrResult.nCodeNum <=0)
{
Console.WriteLine(DateTime.Now + ":内侧--->No Read 处理");
log.Info(DateTime.Now + ":内侧--->No Read 处理");
LinerCode69 = string.Empty;
LinerProductCode = string.Empty;
}
else
{
@ -141,24 +152,29 @@ namespace Aucma.Core.ProductOffLine.Business
string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode);
Console.WriteLine(DateTime.Now + ":内侧扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
log.Info(DateTime.Now + ":内侧扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
// RefreshMaterialCodeStrEvent?.Invoke(strCode.Trim().TrimEnd('\0'), LinerScannerIp);
if (strCode.Trim().TrimEnd('\0').Length == 20)
if (strCode.Trim().TrimEnd('\0').Replace("\r\n", "").Length == 20)
{
LinerProductCode = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
}
if (strCode.Trim().TrimEnd('\0').Replace("\r\n", "").Length == 13)
{
ProductCode = strCode;
LinerCode69 = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
}
if (strCode.Trim().TrimEnd('\0').Length == 13)
if (!string.IsNullOrEmpty(LinerProductCode) && !string.IsNullOrEmpty(LinerCode69))
{
Code69 = strCode;
Console.WriteLine("69码:" + LinerCode69 + ";成品:" + LinerProductCode + "=====>业务处理");
RefreshMaterialCodeStrEvent?.Invoke(LinerProductCode, LinerCode69, LinerScannerIp);
LinerCode69 = string.Empty;
LinerProductCode = string.Empty;
}
}
}
Console.WriteLine("69:" + Code69);
Console.WriteLine("成品:" + ProductCode);
RefreshMaterialCodeStrEvent?.Invoke(ProductCode,Code69, LinerScannerIp);
}
MvCodeReader.MV_CODEREADER_OCR_INFO_LIST stOcrInfo = (MvCodeReader.MV_CODEREADER_OCR_INFO_LIST)Marshal.PtrToStructure(stFrameInfo.UnparsedOcrList.pstOcrList, typeof(MvCodeReader.MV_CODEREADER_OCR_INFO_LIST));
}

@ -511,17 +511,25 @@ namespace Aucma.Core.ProductOffLine.Business
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
log.Info("69码校验失败:" + code69 + "未在mes数据库找到信息!");
return false;
// return false; 因为没有录69码校验失败暂不处理允许下线等69码录全就禁止下线
}
if(!TempOffLineInfo.ProductName.Contains(materialInfo.ProductName))
if(materialInfo!=null)
{
TempOffLineInfo.MsgInfo = "69码校验失败,69码名称:" + materialInfo.ProductName + ";成品码名称:"+ TempOffLineInfo.ProductName;
TempOffLineInfo.MsgAlarmFlag = true;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
log.Info("69码校验失败,69码名称:" + materialInfo.ProductName + ";成品码名称:" + TempOffLineInfo.ProductName);
return false;
if (!TempOffLineInfo.ProductName.Contains(materialInfo.ProductName))
{
TempOffLineInfo.MsgInfo = "69码校验失败,69码名称:" + materialInfo.ProductName + ";成品码名称:" + TempOffLineInfo.ProductName;
TempOffLineInfo.MsgAlarmFlag = true;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
log.Info("69码校验失败,69码:"+code69+";69码名称:" + materialInfo.ProductName + ";成品码名称:" + TempOffLineInfo.ProductName);
return false;
}
else
{
log.Info("69码校验成功,69码:" + code69 + ";69码名称:" + materialInfo.ProductName + ";成品码名称:" + TempOffLineInfo.ProductName);
}
}
#endregion
//界面刷新
// TempOffLineInfo.ProductRefreshFlag = true;

Loading…
Cancel
Save