@ -64,6 +64,12 @@ namespace Aucma.Core.ProductOffLine.Business
private SpeechStr speechStr = SpeechStr . Instance ;
#region 扫码枪扫描数据变量定义
//成品码
private static string GunProductCode = string . Empty ;
// 69码
private static string GunCode69 = string . Empty ;
#endregion
// 扫码器标准返回数据长度
@ -170,10 +176,13 @@ namespace Aucma.Core.ProductOffLine.Business
/// <param name="asciiStr"></param>
public void ReceiveAndConsumption ( string ip , string asciiStr )
{
log . Info ( $"=====>扫码器ip: {ip} 扫码到条码: {asciiStr}" ) ;
// 内侧
try
{
if ( asciiStr . Contains ( ";" ) & & asciiStr . Length = = BarcodeRef . Length )
{
Console . WriteLine ( "需要检测69码:" + asciiStr ) ;
string [ ] splitStr = asciiStr . Split ( ";" ) ;
if ( splitStr . Count ( ) < 2 ) return ;
string code69 = string . Empty ;
@ -192,35 +201,84 @@ namespace Aucma.Core.ProductOffLine.Business
{
Task . Run ( ( ) = >
{
MaterialBarScanHandle ( productCode , code69 , ip ) ;
//1.查询条码系统
string result = _productOffLineServices . QueryChecked ( productCode ) ;
MaterialBarScanHandle ( productCode , ip , result , code69 ) ;
} ) ;
}
}
else
{
Console . WriteLine ( "不检测69码:" + asciiStr ) ;
Task . Run ( ( ) = >
{
//1.查询条码系统
string result = _productOffLineServices . QueryChecked ( asciiStr ) ;
if ( result . Contains ( "出口" ) )
{
MaterialBarScanHandle ( asciiStr , ip , result , "" ) ;
}
} ) ;
}
}
catch ( Exception ex )
{
log . Error ( "接收条码处理异常:" + ex . Message . ToString ( ) ) ;
}
}
public void MaterialBarScan ( string ProductCode , string Code69 , string scannerIp )
#region 扫码枪接收条码处理
public void MaterialBarScan ( string Code, string ip = "" )
{
if ( ip = = "" )
{
GunCode69 = Code ;
}
else
{
GunProductCode = Code ;
//1.查询条码系统
string result = _productOffLineServices . QueryChecked ( GunProductCode ) ;
if ( result . Contains ( "出口" ) )
{
Task . Run ( ( ) = >
{
MaterialBarScanHandle ( GunProductCode , ip , result , "" ) ;
} ) ;
return ;
}
Task . Run ( ( ) = >
}
if ( ! string . IsNullOrEmpty ( GunCode69 ) & & ! string . IsNullOrEmpty ( GunProductCode ) )
{
MaterialBarScanHandle ( ProductCode , Code69 , scannerIp ) ;
} ) ;
Task . Run ( ( ) = >
{
//1.查询条码系统
string result = _productOffLineServices . QueryChecked ( GunProductCode ) ;
MaterialBarScanHandle ( GunProductCode , ip , result , GunCode69 ) ;
} ) ;
return ;
}
}
# endregion
/// <summary>
/// 条码处理
/// </summary>
/// <param name="code">成品码</param>
/// <param name="code69">69码</param>
/// <param name="code69">69码 , 国外产品无需校验, 则69码空 </param>
/// <param name="scannerIp"></param>
public void MaterialBarScanHandle ( string code , string code69 , string scannerIp )
public void MaterialBarScanHandle ( string code , string scannerIp, string result , string code69 = "" )
{
#region 扫码枪数据清空
GunProductCode = "" ;
GunCode69 = "" ;
# endregion
try
{
#region 未登录禁止下线
@ -241,7 +299,7 @@ namespace Aucma.Core.ProductOffLine.Business
if ( ScannerNo = = 1 ) //内侧
{
//1.扫描的SN条码去条码系统校验
BackResult = HandleMaterialBarCode ( code , code69 , TempOffLineInfo1 , out CodeBindingRecord bindingRecord1 ) ; //扫码器1
BackResult = HandleMaterialBarCode ( code , code69 , result , TempOffLineInfo1 , out CodeBindingRecord bindingRecord1 ) ; //扫码器1
materialType = TempOffLineInfo1 . ProductCode ;
if ( ! BackResult )
{
@ -298,7 +356,7 @@ namespace Aucma.Core.ProductOffLine.Business
// 扫码器2
else if ( ScannerNo = = 2 ) // 外侧
{
BackResult = HandleMaterialBarCode ( code , code69 , TempOffLineInfo2, out CodeBindingRecord bindingRecord1 ) ; //扫码器2
BackResult = HandleMaterialBarCode ( code , code69 , result, TempOffLineInfo2, out CodeBindingRecord bindingRecord1 ) ; //扫码器2
materialType = TempOffLineInfo2 . ProductCode ;
if ( ! BackResult )
{
@ -535,7 +593,7 @@ namespace Aucma.Core.ProductOffLine.Business
/// <param name="code69"> 69码</param>
/// <param name="TempOffLineInfo"></param>
/// <returns></returns>
public bool HandleMaterialBarCode ( string BarCode , string code69 , TempInfo TempOffLineInfo , out CodeBindingRecord bindingRecord1 )
public bool HandleMaterialBarCode ( string BarCode , string code69 , string result , TempInfo TempOffLineInfo , out CodeBindingRecord bindingRecord1 )
{
try
{
@ -585,8 +643,8 @@ namespace Aucma.Core.ProductOffLine.Business
log . Info ( "条码系统查询开始:" + BarCode ) ;
//1.查询条码系统
string result = _productOffLineServices . QueryChecked ( BarCode ) ;
////1.查询条码系统 移动到最前面查询,先判断是否出口
//string result = _productOffLineServices.QueryChecked(BarCode) ;
//string result = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000003987@BCD-160C,家电下乡@@BCD-160C@test皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01";
@ -628,36 +686,39 @@ namespace Aucma.Core.ProductOffLine.Business
TempOffLineInfo . ProductCreateDate = FArrayList [ 17 ] ;
# endregion
#region 成品条码与69码校验
BaseMaterialInfo materialInfo = _baseMaterialInfoServices . FirstAsync ( x = > x . ProductCode = = code69 ) . Result ;
if ( materialInfo = = null )
if ( code69 ! = "" )
{
TempOffLineInfo . MsgInfo = "69码校验失败:" + code69 + "未维护69码信息!" ;
TempOffLineInfo . MsgAlarmFlag = true ;
AddExceptionRecord ( TempOffLineInfo . ProductSNCode , TempOffLineInfo . ProductSNCode + TempOffLineInfo . MsgInfo , 1 ) ;
RefreshScanMateriaCodeEvent ? . Invoke ( TempOffLineInfo ) ;
log . Info ( "69码校验失败:" + code69 + "未维护69码信息!" ) ;
return false ; // 因为没有录69码校验失败暂不处理, 允许下线, 等69码录全就禁止下线
}
if ( materialInfo ! = null )
{
if ( ! TempOffLineInfo . ProductName . Contains ( materialInfo . ProductName ) )
#region 成品条码与69码校验
BaseMaterialInfo materialInfo = _baseMaterialInfoServices . FirstAsync ( x = > x . ProductCode = = code69 ) . Result ;
if ( materialInfo = = null )
{
TempOffLineInfo . MsgInfo = "69码校验失败 ,69码名称:" + materialInfo . ProductName + ";成品码名称:" + TempOffLineInfo . ProductName ;
TempOffLineInfo . MsgInfo = "69码校验失败:" + code69 + "未维护69码信息!" ;
TempOffLineInfo . MsgAlarmFlag = true ;
AddExceptionRecord ( TempOffLineInfo . ProductSNCode , TempOffLineInfo . ProductSNCode + TempOffLineInfo . MsgInfo , 1 ) ;
RefreshScanMateriaCodeEvent ? . Invoke ( TempOffLineInfo ) ;
log . Info ( "69码校验失败,69码:" + code69 + ";69码名称:" + materialInfo . ProductName + ";成品码名称:" + TempOffLineInfo . ProductName ) ;
AddExceptionRecord ( TempOffLineInfo . ProductSNCode , TempOffLineInfo . ProductSNCode + TempOffLineInfo . MsgInfo , 1 ) ;
return false ;
log . Info ( "69码校验失败:" + code69 + "未维护69码信息!" ) ;
return false ; // 因为没有录69码校验失败暂不处理, 允许下线, 等69码录全就禁止下线
}
else
if ( materialInfo ! = null )
{
log . Info ( "69码校验成功,69码:" + code69 + ";69码名称:" + materialInfo . ProductName + ";成品码名称:" + TempOffLineInfo . ProductName ) ;
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 ) ;
AddExceptionRecord ( TempOffLineInfo . ProductSNCode , TempOffLineInfo . ProductSNCode + TempOffLineInfo . MsgInfo , 1 ) ;
return false ;
}
else
{
log . Info ( "69码校验成功,69码:" + code69 + ";69码名称:" + materialInfo . ProductName + ";成品码名称:" + TempOffLineInfo . ProductName ) ;
}
}
# endregion
}
# endregion
//界面刷新
// TempOffLineInfo.ProductRefreshFlag = true;
RefreshScanMateriaCodeEvent ? . Invoke ( TempOffLineInfo ) ;