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

dev
liuwf 10 months ago
parent 8819fdde80
commit 64319bd8e5

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

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

@ -136,7 +136,7 @@
<ColumnDefinition Width="7*"/> <ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions> </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 "> <StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="100 0 0 0 ">
<Label Content="提示信息 " FontSize="20" Foreground="#FFFFFF"/> <Label Content="提示信息 " FontSize="20" Foreground="#FFFFFF"/>

@ -30,11 +30,17 @@ namespace Aucma.Core.ProductOffLine.Business
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MvCodeHelper)); private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MvCodeHelper));
#region 全局变量定义 #region 全局变量定义
public static MvCodeReader ShellDevice = null; public static MvCodeReader ShellDevice = null;
public static MvCodeReader LinerDevice = null; public static MvCodeReader LinerDevice = null;
public static DateTime ShellLiveTime = DateTime.Now; public static DateTime ShellLiveTime = DateTime.Now;
public static DateTime LinerLiveTime = 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 #endregion
#region 委托事件 #region 委托事件
@ -65,19 +71,19 @@ namespace Aucma.Core.ProductOffLine.Business
public static void ShellImageCallbackFunc(IntPtr pData, IntPtr pstFrameInfoEx2, IntPtr pUser) 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)); 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)); 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; 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 处理"); log.Info(DateTime.Now + ":外侧--->No Read 处理");
ShellCode69 = string.Empty;
ShellProductCode = string.Empty;
} }
else else
{ {
@ -89,26 +95,30 @@ namespace Aucma.Core.ProductOffLine.Business
string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode); string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode);
Console.WriteLine(DateTime.Now + ":外侧扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]"); 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') + "]"); 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; ShellProductCode = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
// RefreshMaterialCodeStrEvent?.Invoke(strCode.Trim().TrimEnd('\0'), ShellScannerIp);
// 业务处理
} }
if (strCode.Trim().TrimEnd('\0').Length == 13) if (strCode.Trim().TrimEnd('\0').Replace("\r\n", "").Length == 13)
{ {
Code69 = strCode; ShellCode69 = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
// RefreshMaterialCodeStrEvent?.Invoke(strCode.Trim().TrimEnd('\0'), ShellScannerIp); }
// 业务处理 if(!string.IsNullOrEmpty(ShellProductCode)&& !string.IsNullOrEmpty(ShellCode69))
{
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; LinerLiveTime = DateTime.Now;
if (stBcrResult.nCodeNum < 2) if (stBcrResult.nCodeNum <=0)
{ {
Console.WriteLine(DateTime.Now + ":内侧--->No Read 处理"); Console.WriteLine(DateTime.Now + ":内侧--->No Read 处理");
log.Info(DateTime.Now + ":内侧--->No Read 处理"); log.Info(DateTime.Now + ":内侧--->No Read 处理");
LinerCode69 = string.Empty;
LinerProductCode = string.Empty;
} }
else else
{ {
@ -141,24 +152,29 @@ namespace Aucma.Core.ProductOffLine.Business
string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode); string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode);
Console.WriteLine(DateTime.Now + ":内侧扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]"); 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') + "]"); 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').Replace("\r\n", "").Length == 20)
if (strCode.Trim().TrimEnd('\0').Length == 20)
{ {
ProductCode = strCode; LinerProductCode = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
} }
if (strCode.Trim().TrimEnd('\0').Length == 13) if (strCode.Trim().TrimEnd('\0').Replace("\r\n", "").Length == 13)
{ {
Code69 = strCode; LinerCode69 = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
} }
if (!string.IsNullOrEmpty(LinerProductCode) && !string.IsNullOrEmpty(LinerCode69))
{
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); RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
log.Info("69码校验失败:" + code69 + "未在mes数据库找到信息!"); log.Info("69码校验失败:" + code69 + "未在mes数据库找到信息!");
return false; // return false; 因为没有录69码校验失败暂不处理允许下线等69码录全就禁止下线
} }
if(materialInfo!=null)
{
if (!TempOffLineInfo.ProductName.Contains(materialInfo.ProductName)) if (!TempOffLineInfo.ProductName.Contains(materialInfo.ProductName))
{ {
TempOffLineInfo.MsgInfo = "69码校验失败,69码名称:" + materialInfo.ProductName + ";成品码名称:" + TempOffLineInfo.ProductName; TempOffLineInfo.MsgInfo = "69码校验失败,69码名称:" + materialInfo.ProductName + ";成品码名称:" + TempOffLineInfo.ProductName;
TempOffLineInfo.MsgAlarmFlag = true; TempOffLineInfo.MsgAlarmFlag = true;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
log.Info("69码校验失败,69码名称:" + materialInfo.ProductName + ";成品码名称:" + TempOffLineInfo.ProductName); log.Info("69码校验失败,69码:"+code69+";69码名称:" + materialInfo.ProductName + ";成品码名称:" + TempOffLineInfo.ProductName);
return false; return false;
} }
else
{
log.Info("69码校验成功,69码:" + code69 + ";69码名称:" + materialInfo.ProductName + ";成品码名称:" + TempOffLineInfo.ProductName);
}
}
#endregion #endregion
//界面刷新 //界面刷新
// TempOffLineInfo.ProductRefreshFlag = true; // TempOffLineInfo.ProductRefreshFlag = true;

Loading…
Cancel
Save