change-2线成品下线国外产品过滤69码

main
liuwf 7 months ago
parent e370d1460c
commit 39bb6488a9

@ -42,6 +42,7 @@ using Admin.Core.Socket;
using System.Runtime.ConstrainedExecution;
using Aucma.Core.BoxFoam.Config;
using Elasticsearch.Net;
using System.Diagnostics;
/*
*
*/
@ -57,6 +58,11 @@ namespace Aucma.Core.CodeBinding.ViewModels
private readonly IPrintBarCodeServices? _printBarCodeServices;
// 过点数据表物料完成记录MaterialCompletion
private readonly IMaterialCompletionServices? _iMaterialCompletionServices;
// 成品下线操作条码系统接口
private readonly IProductOffLineServices? _productOffLineServices;
private readonly IBaseOrderInfoServices? _baseOrderInfoServices;
// 静态变量存code1,mes条码
private static string code1Str = string.Empty;
@ -85,7 +91,9 @@ namespace Aucma.Core.CodeBinding.ViewModels
{
try
{
_codeBindingRecordServices = App.ServiceProvider.GetService<ICodeBindingRecordServices>();
_baseOrderInfoServices = App.ServiceProvider.GetService<IBaseOrderInfoServices>();
_productOffLineServices = App.ServiceProvider.GetService<IProductOffLineServices>();
_codeBindingRecordServices = App.ServiceProvider.GetService<ICodeBindingRecordServices>();
_baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
_baseMaterialInfoServices = App.ServiceProvider.GetService<IBaseMaterialInfoServices>();
_reportQualityInspectionServices = App.ServiceProvider.GetService<IReportQualityInspectionServices>();
@ -100,7 +108,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
GunBusiness.BindingReceiveCodeEvent += BindingCode;
LoginPageViewModel.RefreshChartsEvent += RefreshCharts;
MsgUIColor = "White";
//刷新页面
RefreshCharts();
@ -655,7 +663,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
/// <param name="flag">1为自动扫描2为手动扫描</param>
public void BindingCode(string code1, string code2,int flag =1)
{
#region 未登录禁止入库
#region 未登录禁止放行
if (string.IsNullOrEmpty(appConfig.TeamName))
{
log.Error($"条码{code1}未登录不做处理,禁止放行");
@ -691,8 +699,20 @@ namespace Aucma.Core.CodeBinding.ViewModels
speechStr.SpeakAsync("终检失败,请终检");
AddExceptionRecord(code1, $"终检失败!! 箱体码{code1}未查询到终检合格记录,请重新终检!", 4);
return;
}
}
#endregion
#region 型号校验
bool checkFlag = CheckModel(code1,code2);
if (!checkFlag)
{
speechStr.SpeakAsync("型号校验失败,请检查成品码是否一致");
RefreshAndWriteLog($"箱体码:{code1},成品码:{code2},型号校验失败,请检查箱体码与成品码是否一致");
SendPlcStop();
return;
}
#endregion
RefreshAndWriteLog("开始绑定MES条码:" + code1 + " SN条码:" + code2);
// 1.数据库查询各个工序质检结果,不合格报警
@ -895,6 +915,67 @@ namespace Aucma.Core.CodeBinding.ViewModels
}
/// <summary>
/// 箱体码和成品码型号校验
/// </summary>
/// <param name="productCode"></param>
/// <param name="BoxCode"></param>
/// <returns></returns>
public bool CheckModel(string BoxCode,string productCode)
{
// 创建 Stopwatch 实例
Stopwatch stopwatch = new Stopwatch();
// 开始计时
stopwatch.Start();
PrintBarCode print = _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == BoxCode).Result;
if (print == null || string.IsNullOrEmpty(print.OrderCode)) return false;
BaseOrderInfo order = _baseOrderInfoServices.FirstAsync(x => x.OrderCode == print.OrderCode).Result;
if (order == null || string.IsNullOrEmpty(order.MaterialName)) return false;
string BoxName = order.MaterialName;
//1.查询条码系统
string result = _productOffLineServices.QueryChecked(productCode);
// result = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000003987@BCD-160C,家电下乡@@BC/BD-206HNE@test皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01";
string[] FArrayList = new string[20];
if (result != null)
{
//用"@"号分隔
FArrayList = result.Split('@');
if (FArrayList[0].ToUpper() == "Y") //查询数据成功
{
log.Info(productCode + "条码系统返回验证信息:" + result);
string TmName = FArrayList[10];
if (BoxName.Contains(TmName))
{
// 停止计时
stopwatch.Stop();
// 输出代码运行时间
Console.WriteLine("代码执行时间: " + stopwatch.Elapsed);
log.Info($"型号校验成功:箱体码:{BoxCode},型号:{BoxName};成品码:{productCode},型号:{TmName},用时:{stopwatch.Elapsed}");
return true;
}
else
{
// 停止计时
stopwatch.Stop();
// 输出代码运行时间
Console.WriteLine("代码执行时间: " + stopwatch.Elapsed);
log.Error($"型号校验失败:型号不一致; 箱体码:{BoxCode},型号:{BoxName};成品码:{productCode},型号:{TmName},用时:{stopwatch.Elapsed}");
return false;
}
}
else
{
return false;
}
}
return false;
}
///// <summary>
///// 下发plc放行信号

@ -91,8 +91,16 @@
"HitRate": 40,
"Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.72.20)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User ID=c##aucma_mes;Password=aucma;",
"ProviderName": "System.Data.SqlClient"
},
{
"ConnId": "AUCMA_TIAOMA",
"DBType": 3,
"Enabled": true,
"HitRate": 40,
// "Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=175.27.215.92)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=helowin)));User ID=aucma_scada;Password=aucma;",
"Connection": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST = 172.16.1.50)(PORT = 1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=tmdata)));User ID=ILS_SORT;Password=Aucma_2019;",
"ProviderName": "System.Data.SqlClient"
}
],
"QuartzNetJob": [
{

@ -214,7 +214,7 @@ namespace Aucma.Core.PalletizCX1.Business
bool result = false;
log.Info($"条码:{asciiStr},区域:{spaceArea}入库申请,下发PLC货道号:{spaceinfo.SpaceCode}");
SendInStoreTask(asciiStr, spaceinfo, ref result, Convert.ToInt32(prodInfo.ProductMasterModel), ref msg, out int range);
#region 添加入库记录
@ -500,20 +500,21 @@ namespace Aucma.Core.PalletizCX1.Business
Task.Delay(500).Wait();
}
Console.WriteLine("下传PLC开始");
log.Info("下传PLC开始");
if (spaceinfo.SpaceArea == "A")
{
if (!_plc.WriteInt16("D2002", spinFlag.ToString()))
{
throw new ArgumentException($"A区域旋转角度下发至PLC失败");
}
log.Info($"A区域旋转角度下发:D2002写{spinFlag.ToString()}");
if (!_plc.WriteInt16("D9", spaceCode.ToString()))
{
throw new ArgumentException($"A区域货道号下发至PLC失败");
}
log.Info($"A区域货道号下发:D9写{spaceCode.ToString()}");
_plc.WriteInt16("B1201", "1");//发送完成信号
log.Info($"A区域发送完成信号下发:B1201写1");
result = true;
}
else if (spaceinfo.SpaceArea == "B")
@ -523,13 +524,14 @@ namespace Aucma.Core.PalletizCX1.Business
{
throw new ArgumentException($"B区域旋转角度下发至PLC失败");
}
log.Info($"B区域旋转角度下发:D1002写{spinFlag.ToString()}");
if (!_plc.WriteInt16("D29", spaceCode.ToString()))
{
throw new ArgumentException($"B区域货道号下发至PLC失败");
}
log.Info($"B区域货道号下发:D29写{spaceCode.ToString()}");
_plc.WriteInt16("B1102", "1");//发送完成信号
log.Info($"B区域发送完成信号下发:B1102写1");
result = true;
}
else if (spaceinfo.SpaceArea == "C")

@ -122,9 +122,10 @@
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding BarCodeCode}" Header="成品条码" Width="3*" />
<DataGridTextColumn Binding="{Binding MaterialName}" Header="成品型号" Width="3*" />
<DataGridTextColumn Binding="{Binding BarCodeCode}" Header="成品条码" Width="2*" />
<DataGridTextColumn Binding="{Binding MaterialName}" Header="成品型号" Width="2*" />
<DataGridTextColumn Binding="{Binding StoreArea}" Header="区域" Width="1*" />
<DataGridTextColumn Binding="{Binding SpaceCode}" Header="货道" Width="1*" />
<DataGridTextColumn Binding="{Binding InStoreAmount}" Header="旋转角度" Width="*" />
<DataGridTextColumn Binding="{Binding InStoreTime,StringFormat=\{0:yyyy-MM-dd HH:mm\}}" Header="入库时间" Width="2*" />
</DataGrid.Columns>

@ -2,6 +2,7 @@
using Aucma.Core.ProductOffLine.Config;
using Aucma.Core.Scanner;
using log4net;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.IO.Ports;
@ -29,19 +30,14 @@ namespace Aucma.Core.ProductOffLine.Business
#region 单例实现
private static readonly GunBusiness lazy = new GunBusiness();
#region 变量定义
//成品码
private static string ProductCode = string.Empty;
// 69码
private static string Code69 = string.Empty;
#endregion
/// <summary>
/// 扫码委托
/// </summary>
/// <param name="materialCodeStr"></param>
/// <param name="ip"></param>
public delegate void RefreshMaterialCodeStr(string ProductCode, string Code69, string ip);
public delegate void RefreshMaterialCodeStr(string Code,string ip="");
public static event RefreshMaterialCodeStr RefreshMaterialCodeStrEvent;
public static GunBusiness Instance
@ -101,25 +97,18 @@ namespace Aucma.Core.ProductOffLine.Business
string str = Encoding.ASCII.GetString(receiveBytes).Replace("\r\n", "");
if(str.Length == 20)
{
ProductCode = str;
}else if(str.Length == 13)
{
Code69 = str;
}
// 业务处理
if(!string.IsNullOrEmpty(ProductCode) && !string.IsNullOrEmpty(Code69))
{
{ //成品码
string ip = DirectionToIP();
if (!string.IsNullOrEmpty(ip))
{
RefreshMaterialCodeStrEvent?.Invoke(ProductCode,Code69, ip);
RefreshMaterialCodeStrEvent?.Invoke(str, ip);
int direction = -1;
appConfig.GunDirection = direction.ToString();
}
// 清空
ProductCode = string.Empty;
Code69 = string.Empty;
}
else if(str.Length == 13)
{ //69码
RefreshMaterialCodeStrEvent?.Invoke(str);
}
sb.Clear();
}

@ -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);

@ -102,6 +102,7 @@
"Connection": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST = 172.16.1.50)(PORT = 1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=tmdata)));User ID=ILS_SORT;Password=Aucma_2019;",
"ProviderName": "System.Data.SqlClient"
}
],
"QuartzNetJob": [
{

Loading…
Cancel
Save