@ -4,12 +4,14 @@ using Admin.Core.IService;
using Admin.Core.Model ;
using Admin.Core.Model.Model_New ;
using Admin.Core.Service ;
using Admin.Core.Socket ;
using Aucma.Core.HwPLc ;
using Aucma.Core.ProductOffLine ;
using Aucma.Core.ProductOffLine.Config ;
using Aucma.Core.ProductOffLine.Models ;
using Aucma.Core.ProductOffLine.Views ;
using Aucma.Core.Scanner ;
using Castle.Core.Internal ;
using log4net ;
using Microsoft.Extensions.DependencyInjection ;
using Microsoft.Extensions.Hosting ;
@ -53,7 +55,19 @@ namespace Aucma.Core.ProductOffLine.Business
// public OffLineBusiness(){}
#region 变量定义
private readonly List < ScannerModel > allScanners = Appsettings . app < ScannerModel > ( "ScannerServer" ) . ToList ( ) ;
private static List < ScannerModel > allScanners = Appsettings . app < ScannerModel > ( "ScannerServer" ) . ToList ( ) ;
// 内胆扫码器ip
private static string LinerScannerIp = allScanners . First ( x = > x . Name = = "内侧扫码器1" ) . Ip ;
// 箱壳扫码器ip
private static string ShellScannerIp = allScanners . First ( x = > x . Name = = "外侧扫码器2" ) . Ip ;
// 扫码器标准返回数据长度
private const string BarcodeRef = "6933973114570;1621240AP0098E3D3497" ;
/// <summary>
/// 扫码器1扫到条码的临时数据
/// </summary>
@ -111,11 +125,12 @@ namespace Aucma.Core.ProductOffLine.Business
public OffLineBusiness ( )
{
MvCodeHelper . RefreshMaterialCodeStrEvent + = MaterialBarScan ;
// MvCodeHelper.RefreshMaterialCodeStrEvent += MaterialBarScan;
GunBusiness . RefreshMaterialCodeStrEvent + = MaterialBarScan ;
HandSendPlcWindow . SendPlcPassEvent + = DownLoadPassFlag ;
// test();
TouchSocketService . ReceiveCodeDelegateEvent + = ReceiveAndConsumption ;
TouchSocketService . NoReadReceiveEvent + = NoRead ;
}
#region 变量定义
/// <summary>
@ -125,17 +140,69 @@ namespace Aucma.Core.ProductOffLine.Business
# endregion
public void test ( )
/// <summary>
/// TCP接收NoRead提醒
/// </summary>
public void NoRead ( string ip )
{
// 内侧
if ( LinerScannerIp = = ip )
{
Console . WriteLine ( $"内侧扫码器ip: {ip} 未扫描到条码" ) ;
}
else if ( ShellScannerIp = = ip )
{
Console . WriteLine ( $"外侧扫码器ip: {ip} 未扫描到条码" ) ;
}
}
#region 成品条码与69码校验
MaterialBarScan ( "15147X0CD0099E3W03410" , "12344" , "10.10.92.141" ) ;
# endregion
/// <summary>
/// TCP接收条码并分割处理
/// </summary>
/// <param name="ip"></param>
/// <param name="asciiStr"></param>
public void ReceiveAndConsumption ( string ip , string asciiStr )
{
try
{
if ( asciiStr . Contains ( ";" ) & & asciiStr . Length = = BarcodeRef . Length )
{
string [ ] splitStr = asciiStr . Split ( ";" ) ;
if ( splitStr . Count ( ) < 2 ) return ;
string code69 = string . Empty ;
string productCode = string . Empty ;
if ( splitStr [ 0 ] . Length = = 13 )
{
code69 = splitStr [ 0 ] ;
productCode = splitStr [ 1 ] ;
}
else if ( splitStr [ 0 ] . Length = = 20 )
{
productCode = splitStr [ 0 ] ;
code69 = splitStr [ 1 ] ;
}
if ( ! code69 . IsNullOrEmpty ( ) & & ! productCode . IsNullOrEmpty ( ) )
{
Task . Run ( ( ) = >
{
MaterialBarScanHandle ( productCode , code69 , ip ) ;
} ) ;
}
}
}
catch ( Exception ex )
{
log . Error ( "接收条码处理异常:" + ex . Message . ToString ( ) ) ;
}
}
public void MaterialBarScan ( string ProductCode , string Code69 , string scannerIp )
{
Task . Run ( ( ) = >
{
MaterialBarScanHandle ( ProductCode , Code69 , scannerIp ) ;
@ -151,10 +218,10 @@ namespace Aucma.Core.ProductOffLine.Business
{
try
{
ScannerModel model = allScanners . FirstOrDefault ( x = > x . Ip = = scannerIp ) ;
int ScannerNo = model . Id ; // 确定是哪个扫码器
log . Info ( "扫码器ip:" + scannerIp + "编号:[" + ScannerNo + "]扫描到条码:" + code ) ;
// ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == scannerIp) ;
// int ScannerNo = model.Id; // 确定是哪个扫码器
// log.Info("扫码器ip:" + scannerIp + "编号:[" + ScannerNo + "]扫描到条码:" + code) ;
int ScannerNo = LinerScannerIp = = scannerIp ? 1 : 2 ;
string materialType = "" ;
bool BackResult = false ;
if ( ScannerNo = = 1 ) //内侧
@ -330,14 +397,18 @@ namespace Aucma.Core.ProductOffLine.Business
try
{
OffLineInfo info11 = MapperTwo ( TempOffLineInfo ) ;
// log.Info("条码绑定表查到记录:"+JsonHelper.ObjectToJson(bindingRecord1));
info11 . BoxCode = bindingRecord1 . BoxCode ;
// log.Info("条码绑定表查到记录:"+JsonHelper.ObjectToJson(bindingRecord1));
if ( bindingRecord1 ! = null )
{
info11 . BoxCode = bindingRecord1 . BoxCode ;
}
else
{
info11 . BoxCode = "" ;
}
// 产线
info11 . ProductLineCode = appConfig . ProductlineCode . ToString ( ) ;
@ -428,8 +499,7 @@ namespace Aucma.Core.ProductOffLine.Business
return false ;
}
}
@ -468,29 +538,30 @@ namespace Aucma.Core.ProductOffLine.Business
RefreshScanMateriaCodeEvent ? . Invoke ( TempOffLineInfo ) ;
log . Info ( TempOffLineInfo . ProductSNCode + "条码绑定工位未查询到条码绑定记录,请拆掉包装重新绑定" ) ;
AddExceptionRecord ( TempOffLineInfo . ProductSNCode , TempOffLineInfo . MsgInfo , 3 ) ;
return false ;
// return false;
}
#region 1.质检-未查到终检合格记录即为质检不合格
ReportQualityInsPection qualityList = _reportQualityInspectionServices . JudgeIsQualified ( bindingRecord1 . BoxCode ) ;
if ( qualityList = = null )
if ( bindingRecord1 ! = null )
{
TempOffLineInfo . QualityResult = "失败" ;
TempOffLineInfo . ProductSNCode = BarCode . Trim ( ) ; //产品SN条码*1
TempOffLineInfo . ProductScanTime = System . DateTime . Now ; // 扫码时间*2
TempOffLineInfo . MsgInfo = TempOffLineInfo . ProductSNCode + ":条码终检失败或未终检,请回到终检工位重新检查!" ;
TempOffLineInfo . MsgAlarmFlag = true ;
//界面刷新
// TempOffLineInfo.ProductRefreshFlag = true;
RefreshScanMateriaCodeEvent ? . Invoke ( TempOffLineInfo ) ;
AddExceptionRecord ( TempOffLineInfo . ProductSNCode , TempOffLineInfo . MsgInfo , 4 ) ;
return false ;
}
# endregion
#region 1.质检-未查到终检合格记录即为质检不合格
ReportQualityInsPection qualityList = _reportQualityInspectionServices . JudgeIsQualified ( bindingRecord1 . BoxCode ) ;
if ( qualityList = = null )
{
TempOffLineInfo . QualityResult = "失败" ;
TempOffLineInfo . ProductSNCode = BarCode . Trim ( ) ; //产品SN条码*1
TempOffLineInfo . ProductScanTime = System . DateTime . Now ; // 扫码时间*2
TempOffLineInfo . MsgInfo = TempOffLineInfo . ProductSNCode + ":条码终检失败或未终检,请回到终检工位重新检查!" ;
TempOffLineInfo . MsgAlarmFlag = true ;
//界面刷新
// TempOffLineInfo.ProductRefreshFlag = true;
RefreshScanMateriaCodeEvent ? . Invoke ( TempOffLineInfo ) ;
AddExceptionRecord ( TempOffLineInfo . ProductSNCode , TempOffLineInfo . MsgInfo , 4 ) ;
// return false;
}
# endregion
}
TempOffLineInfo . QualityResult = "成功" ;