liulb@mesnac.com 10 months ago
parent 7d68a3ad51
commit cf85055ea4

@ -9,6 +9,7 @@ using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using log4net;
using Microsoft.Extensions.DependencyInjection;
using NPOI.Util;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -164,7 +165,7 @@ namespace Aucma.Core.PrintTo.ViewModels
/// 打印
/// </summary>
[RelayCommand]
private void Print(string obj)
private async void Print(string obj)
{
if (string.IsNullOrEmpty(obj))
{
@ -184,7 +185,7 @@ namespace Aucma.Core.PrintTo.ViewModels
}
if (SelectedCells.PlanAmount < PrintAmount)
{
MessageBox.Show("打印数量能高于计划数量!", "系统提醒");
MessageBox.Show("打印数量能高于计划数量!", "系统提醒");
return;
}
if (printType==0)
@ -192,6 +193,7 @@ namespace Aucma.Core.PrintTo.ViewModels
MessageBox.Show("请选择打印类型!", "系统提醒");
return;
}
try
{
@ -202,8 +204,34 @@ namespace Aucma.Core.PrintTo.ViewModels
//string material_name = SelectedCells.MaterialName;
int standard_amount = PrintAmount;
string printName = SelectedCells.PrintName;
PrintIsEnabled = "False";
int type = 0;
if (printType == 500)
{
type = 2;
}
if (printType == 200)
{
type = 1;
}
var list= await _printBarCodeServices.QueryAsync(d => d.OrderCode == order_code&&d.PrintBarType== printType);
if (list!=null||list.Count!= 0)
{
int num= list.Count;//已经打印数量
int residue= SelectedCells.PlanAmount - num;//剩余打印数量
if (residue == standard_amount)
{
MessageBox.Show("订单数量已经打印到规定订单数量!", "系统提醒");
return;
}
if ((residue- standard_amount)< 1)
{
MessageBox.Show("订单数量已经打印到规定订单数量!", "系统提醒");
return;
}
}
//更新打印名称
var baseOrder = _baseOrderInfoServices.FirstAsync(d => d.OrderCode == order_code).Result;
if (string.IsNullOrEmpty(baseOrder.PrintName))

@ -235,7 +235,7 @@
<TextBlock Text="&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;打印数量" FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Slider x:Name="PlanAmount" FontSize="18" Minimum="0" Maximum="500" BorderBrush="White" Value="{Binding PrintAmount,Mode=TwoWay}" Foreground="White" Height="30" VerticalContentAlignment="Center"
HorizontalContentAlignment="Left" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="15 0 0 0" Width="{Binding Path=ActualWidth, ElementName=ProductNo}"/>
<!--<TextBlock Text="1~500" Width="60" Margin="10 0 0 0" Foreground="White" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" />-->
<TextBlock Text="{Binding SelectedItem.PlanAmount, ElementName=dgvMH}" />
</WrapPanel>
<Border Grid.Row="5" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Width="420" >
<StackPanel >

@ -36,7 +36,7 @@ namespace Aucma.Core.ProductOffLine.Business
/// <summary>
/// 成品下线业务逻辑
/// </summary>
public class OffLineBusiness
public class OffLineBusiness
{
#region 单例实现
@ -78,7 +78,7 @@ namespace Aucma.Core.ProductOffLine.Business
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
// 过点数据表物料完成记录MaterialCompletion
private readonly IMaterialCompletionServices? _iMaterialCompletionServices = App.ServiceProvider.GetService<IMaterialCompletionServices>();
private readonly ICodeBindingRecordServices? _codeBindingServices = App.ServiceProvider.GetService<ICodeBindingRecordServices>();
// 质检记录
private readonly IReportQualityInspectionServices? _reportQualityInspectionServices = App.ServiceProvider.GetService<IReportQualityInspectionServices>();
@ -89,10 +89,10 @@ namespace Aucma.Core.ProductOffLine.Business
/// <summary>
/// 扫码信息刷新
/// </summary>
public delegate void RefreshScanMateriaCode(TempInfo tempInfo);
public delegate void RefreshScanMateriaCode(TempInfo tempInfo);
public static event RefreshScanMateriaCode? RefreshScanMateriaCodeEvent;
/// <summary>
/// 图表刷新
/// </summary>
@ -106,13 +106,13 @@ namespace Aucma.Core.ProductOffLine.Business
public event getDirection getDirectioneEvent;
#endregion
public OffLineBusiness()
public OffLineBusiness()
{
MvCodeHelper.RefreshMaterialCodeStrEvent += MaterialBarScan;
GunBusiness.RefreshMaterialCodeStrEvent += MaterialBarScan;
HandSendPlcWindow.SendPlcPassEvent += DownLoadPassFlag;
// test();
// test();
}
#region 变量定义
/// <summary>
@ -122,7 +122,7 @@ namespace Aucma.Core.ProductOffLine.Business
#endregion
public void test()
public void test()
{
Task.Run(() =>
@ -177,7 +177,11 @@ namespace Aucma.Core.ProductOffLine.Business
// Thread.Sleep(1000);
// MaterialBarScanEvent("33160030000000910780", "192.168.1.20");
}
/// <summary>
/// 开始扫码约我处理
/// </summary>
/// <param name="code"></param>
/// <param name="scannerIp"></param>
public void MaterialBarScan(string code, string scannerIp)
{
Task.Run(() =>
@ -185,15 +189,15 @@ namespace Aucma.Core.ProductOffLine.Business
MaterialBarScanHandle(code, scannerIp);
});
}
/// <summary>
/// 处理条码
/// </summary>
/// <param name="code"></param>
/// <param name="scannerIp">扫码器IP</param>
public void MaterialBarScanHandle(string code,string scannerIp)
{
/// <summary>
/// 处理条码
/// </summary>
/// <param name="code"></param>
/// <param name="scannerIp">扫码器IP</param>
public void MaterialBarScanHandle(string code, string scannerIp)
{
try
{
{
ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == scannerIp);
int ScannerNo = model.Id; // 确定是哪个扫码器
log.Info("扫码器ip:" + scannerIp + "编号:[" + ScannerNo + "]扫描到条码:" + code);
@ -211,10 +215,10 @@ namespace Aucma.Core.ProductOffLine.Business
return;
}
// TempOffLineInfo1.ProductRefreshFlag = true;
// TempOffLineInfo1.ProductRefreshFlag = true;
// 2.更新mes数据库
bool MesResult = updateMesData(TempOffLineInfo1);
bool MesResult = updateMesData(TempOffLineInfo1);
// 3.plc放行
if (MesResult)
{
@ -241,10 +245,10 @@ namespace Aucma.Core.ProductOffLine.Business
log.Info("更新mes数据库应答字为2失败");
}
}
}
log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo1.ProductOrderNo, TempOffLineInfo1.OrderQty));
}
else
{
@ -269,7 +273,7 @@ namespace Aucma.Core.ProductOffLine.Business
// TempOffLineInfo2.ProductRefreshFlag = true;
// 2.更新mes数据库
bool MesResult = updateMesData(TempOffLineInfo2);
//BackResult = true;
// 3.plc放行
if (MesResult)
@ -301,7 +305,7 @@ namespace Aucma.Core.ProductOffLine.Business
}
log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo2.ProductOrderNo, TempOffLineInfo2.OrderQty));
}
else
{
@ -316,7 +320,7 @@ namespace Aucma.Core.ProductOffLine.Business
}
catch (Exception ex)
{
log.Error("MaterialBarScanHandle异常:"+ex.Message.ToString());
log.Error("MaterialBarScanHandle异常:" + ex.Message.ToString());
}
}
@ -347,9 +351,9 @@ namespace Aucma.Core.ProductOffLine.Business
try
{
OffLineInfo info11 = MapperTwo(TempOffLineInfo);
CodeBindingRecord bindingRecord1 = _codeBindingServices.FirstAsync(x=>x.ProductCode == info11.ProductSNCode).Result;
CodeBindingRecord bindingRecord1 = _codeBindingServices.FirstAsync(x => x.ProductCode == info11.ProductSNCode).Result;
if (bindingRecord1 == null)
{
log.Info(info11.ProductCode + "mes数据库未查询到条码绑定记录");
@ -359,11 +363,11 @@ namespace Aucma.Core.ProductOffLine.Business
}
else
{
// log.Info("条码绑定表查到记录:"+JsonHelper.ObjectToJson(bindingRecord1));
// log.Info("条码绑定表查到记录:"+JsonHelper.ObjectToJson(bindingRecord1));
info11.BoxCode = bindingRecord1.BoxCode;
}
// 产线
info11.ProductLineCode = "CX_02";
info11.SaveRetuenInfo = TempOffLineInfo.MsgInfo;
@ -371,13 +375,13 @@ namespace Aucma.Core.ProductOffLine.Business
info11.PlcResult = 1;
// 查询本地数据库是否有数据
OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == TempOffLineInfo.ProductSNCode).Result;
if(offLineInfo == null)
if (offLineInfo == null)
{
info11.ProductOrderNo = "0000" + info11.ProductOrderNo;
int flag = _offLineInfoServices.AddAsync(info11).Result;
int flag = _offLineInfoServices.AddAsync(info11).Result;
if (flag < 0)
{
log.Info(TempOffLineInfo.ProductSNCode+"插入下线记录失败");
log.Info(TempOffLineInfo.ProductSNCode + "插入下线记录失败");
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "插入下线记录失败";
TempOffLineInfo.MsgAlarmFlag = true;
//界面刷新
@ -393,7 +397,7 @@ namespace Aucma.Core.ProductOffLine.Business
BaseOrderInfo order = _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo).Result;
if (order == null)
{
log.Info("条码:"+TempOffLineInfo.ProductBarNo+" 订单号:"+TempOffLineInfo.ProductOrderNo+" 查询mes订单失败");
log.Info("条码:" + TempOffLineInfo.ProductBarNo + " 订单号:" + TempOffLineInfo.ProductOrderNo + " 查询mes订单失败");
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "查询mes订单失败";
TempOffLineInfo.MsgAlarmFlag = true;
//界面刷新
@ -408,7 +412,7 @@ namespace Aucma.Core.ProductOffLine.Business
}
order.UpdatedTime = DateTime.Now;
bool uploadOrder = _baseOrderInfoServices.UpdateAsync(order).Result;
if(!uploadOrder)
if (!uploadOrder)
{
log.Info("条码:" + TempOffLineInfo.ProductBarNo + " 订单号:" + TempOffLineInfo.ProductOrderNo + " 更新mes订单完成数失败");
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "更新mes订单完成数失败";
@ -438,7 +442,7 @@ namespace Aucma.Core.ProductOffLine.Business
#endregion
}
return true;
}
@ -450,151 +454,151 @@ namespace Aucma.Core.ProductOffLine.Business
}
/// <summary>
/// 去条码系统查询校验并保存
/// </summary>
/// <param name="BarCode"></param>
/// <returns></returns>
public bool HandleMaterialBarCode(string BarCode,TempInfo TempOffLineInfo)
{
try
{
// 1.质检
// List<ReportQualityInsPection> qualityList = _reportQualityInspectionServices.JudgeIsQualified(BarCode);
// if (qualityList != null)
//{
// TempOffLineInfo.QualityResult = "失败";
// TempOffLineInfo.ProductSNCode = BarCode.Trim(); //产品SN条码*1
// TempOffLineInfo.ProductScanTime = System.DateTime.Now; // 扫码时间*2
// TempOffLineInfo.MsgInfo = "条码质检失败:";
// foreach(ReportQualityInsPection item in qualityList)
// {
// TempOffLineInfo.MsgInfo += item.QualityDefectName;
// }
// TempOffLineInfo.MsgAlarmFlag = true;
// //界面刷新
// // TempOffLineInfo.ProductRefreshFlag = true;
// RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
// return false;
//}
TempOffLineInfo.QualityResult = "成功";
TempOffLineInfo.ProductSNCode = BarCode.Trim(); //产品SN条码*1
TempOffLineInfo.ProductScanTime = System.DateTime.Now; // 扫码时间*2
log.Info("条码验证开始:" + BarCode);
//1.查询条码系统
string result = _productOffLineServices.QueryChecked(BarCode);
/// <summary>
/// 去条码系统查询校验并保存
/// </summary>
/// <param name="BarCode"></param>
/// <returns></returns>
public bool HandleMaterialBarCode(string BarCode, TempInfo TempOffLineInfo)
{
try
{
// 1.质检
// List<ReportQualityInsPection> qualityList = _reportQualityInspectionServices.JudgeIsQualified(BarCode);
// if (qualityList != null)
//{
// TempOffLineInfo.QualityResult = "失败";
// TempOffLineInfo.ProductSNCode = BarCode.Trim(); //产品SN条码*1
// TempOffLineInfo.ProductScanTime = System.DateTime.Now; // 扫码时间*2
// TempOffLineInfo.MsgInfo = "条码质检失败:";
// foreach(ReportQualityInsPection item in qualityList)
// {
// TempOffLineInfo.MsgInfo += item.QualityDefectName;
// }
// TempOffLineInfo.MsgAlarmFlag = true;
// //界面刷新
// // TempOffLineInfo.ProductRefreshFlag = true;
// RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
// return false;
//}
TempOffLineInfo.QualityResult = "成功";
TempOffLineInfo.ProductSNCode = BarCode.Trim(); //产品SN条码*1
TempOffLineInfo.ProductScanTime = System.DateTime.Now; // 扫码时间*2
log.Info("条码验证开始:" + 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";
string[] FArrayList = new string[20];
if (result != null)
{
//用"@"号分隔
FArrayList = result.Split('@');
}
else
{
FArrayList[0] = "N";
FArrayList[1] = "条码系统查询接口调用失败,请检查网络重新扫描";
}
if (FArrayList[0].ToUpper() == "Y") //查询数据成功
{
log.Info(BarCode + "成功返回验证信息:" + result);
#region 实体赋值
TempOffLineInfo.MsgInfo = "获取信息成功" + BarCode + " 返回值:" + FArrayList[0].ToUpper(); // 提示信息*7
TempOffLineInfo.ProductFactoryCode = FArrayList[1];
TempOffLineInfo.ProductSNCode = FArrayList[2];
TempOffLineInfo.ProductOrderNo = DBToString(FArrayList[3]).Replace("0000", ""); // 订单编号*4
TempOffLineInfo.ProductSaleNo = DBToString(FArrayList[4]);
TempOffLineInfo.ProductSaleLineNo = DBToString(FArrayList[5]);
TempOffLineInfo.ProductCheckInfo = DBToString(FArrayList[6]); //验证组合
TempOffLineInfo.ProductCode = DBToString(FArrayList[7]).Replace("00000000", "");
TempOffLineInfo.ProductName = DBToString(FArrayList[8]); //产品描述
TempOffLineInfo.ProductType = FArrayList[9];
TempOffLineInfo.ProductModel = FArrayList[10]; //产品型号*3
TempOffLineInfo.ProductRemark = DBToString(FArrayList[11]);
TempOffLineInfo.ProductBarNo = FArrayList[12];
TempOffLineInfo.ProductMasterModel = FArrayList[13]; //产品主型号
TempOffLineInfo.ProductVersion = FArrayList[14];
TempOffLineInfo.ProductUseInfo = FArrayList[15];//产品用途
TempOffLineInfo.ProductCirculate = FArrayList[16];//流通特性
TempOffLineInfo.ProductCreateDate = FArrayList[17];
string[] FArrayList = new string[20];
if (result != null)
{
//用"@"号分隔
FArrayList = result.Split('@');
}
else
{
FArrayList[0] = "N";
FArrayList[1] = "条码系统查询接口调用失败,请检查网络重新扫描";
}
if (FArrayList[0].ToUpper() == "Y") //查询数据成功
{
log.Info(BarCode + "成功返回验证信息:" + result);
#region 实体赋值
TempOffLineInfo.MsgInfo = "获取信息成功" + BarCode + " 返回值:" + FArrayList[0].ToUpper(); // 提示信息*7
TempOffLineInfo.ProductFactoryCode = FArrayList[1];
TempOffLineInfo.ProductSNCode = FArrayList[2];
TempOffLineInfo.ProductOrderNo = DBToString(FArrayList[3]).Replace("0000", ""); // 订单编号*4
TempOffLineInfo.ProductSaleNo = DBToString(FArrayList[4]);
TempOffLineInfo.ProductSaleLineNo = DBToString(FArrayList[5]);
TempOffLineInfo.ProductCheckInfo = DBToString(FArrayList[6]); //验证组合
TempOffLineInfo.ProductCode = DBToString(FArrayList[7]).Replace("00000000", "");
TempOffLineInfo.ProductName = DBToString(FArrayList[8]); //产品描述
TempOffLineInfo.ProductType = FArrayList[9];
TempOffLineInfo.ProductModel = FArrayList[10]; //产品型号*3
TempOffLineInfo.ProductRemark = DBToString(FArrayList[11]);
TempOffLineInfo.ProductBarNo = FArrayList[12];
TempOffLineInfo.ProductMasterModel = FArrayList[13]; //产品主型号
TempOffLineInfo.ProductVersion = FArrayList[14];
TempOffLineInfo.ProductUseInfo = FArrayList[15];//产品用途
TempOffLineInfo.ProductCirculate = FArrayList[16];//流通特性
TempOffLineInfo.ProductCreateDate = FArrayList[17];
#endregion
//界面刷新
// TempOffLineInfo.ProductRefreshFlag = true;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
// 多码系统校验,暂不启用
// bool flag = TestBarCode(TempOffLineInfo);
// if (!flag)
// {
// return false;
// }
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证通过!");
//2.上传条码系统
bool resultUp = uploadSnSysytem(TempOffLineInfo);
return resultUp;
}
else
{
log.Info(BarCode + "失败返回验证信息:" + FArrayList[1]);
#region 实体赋值
TempOffLineInfo.MsgAlarmFlag = true;
TempOffLineInfo.MsgInfo = "条码系统获取信息失败. " + BarCode + " 返回值:" + FArrayList[0].ToString();
TempOffLineInfo.ProductOrderNo = "";
TempOffLineInfo.ProductSaleNo = "";
TempOffLineInfo.ProductSaleLineNo = "";
TempOffLineInfo.ProductCheckInfo = ""; //验证组合
TempOffLineInfo.ProductCode = "";
TempOffLineInfo.ProductName = ""; //产品描述
TempOffLineInfo.ProductType = "";
TempOffLineInfo.ProductModel = ""; //产品型号
TempOffLineInfo.ProductRemark = "";
TempOffLineInfo.ProductBarNo = ""; ;
TempOffLineInfo.ProductMasterModel = ""; //产品主型号
TempOffLineInfo.ProductVersion = "";
TempOffLineInfo.ProductUseInfo = "";//产品用途
TempOffLineInfo.ProductCirculate = "";//流通特性
TempOffLineInfo.ProductCreateDate = "";
TempOffLineInfo.oneCode = "";
TempOffLineInfo.serialNumber = "";
TempOffLineInfo.rfid = "";
TempOffLineInfo.sim = "";
TempOffLineInfo.number1 = "";
//界面刷新
// TempOffLineInfo.ProductRefreshFlag = true;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
// 多码系统校验,暂不启用
// bool flag = TestBarCode(TempOffLineInfo);
// if (!flag)
// {
// return false;
// }
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证通过!");
//2.上传条码系统
bool resultUp = uploadSnSysytem(TempOffLineInfo);
return resultUp;
}
else
{
log.Info(BarCode + "失败返回验证信息:" + FArrayList[1]);
#region 实体赋值
TempOffLineInfo.MsgAlarmFlag = true;
TempOffLineInfo.MsgInfo = "条码系统获取信息失败. " + BarCode + " 返回值:" + FArrayList[0].ToString();
TempOffLineInfo.ProductOrderNo = "";
TempOffLineInfo.ProductSaleNo = "";
TempOffLineInfo.ProductSaleLineNo = "";
TempOffLineInfo.ProductCheckInfo = ""; //验证组合
TempOffLineInfo.ProductCode = "";
TempOffLineInfo.ProductName = ""; //产品描述
TempOffLineInfo.ProductType = "";
TempOffLineInfo.ProductModel = ""; //产品型号
TempOffLineInfo.ProductRemark = "";
TempOffLineInfo.ProductBarNo = ""; ;
TempOffLineInfo.ProductMasterModel = ""; //产品主型号
TempOffLineInfo.ProductVersion = "";
TempOffLineInfo.ProductUseInfo = "";//产品用途
TempOffLineInfo.ProductCirculate = "";//流通特性
TempOffLineInfo.ProductCreateDate = "";
TempOffLineInfo.oneCode = "";
TempOffLineInfo.serialNumber = "";
TempOffLineInfo.rfid = "";
TempOffLineInfo.sim = "";
TempOffLineInfo.number1 = "";
#endregion
//界面刷新
// TempOffLineInfo.ProductRefreshFlag = true;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
return false;
}
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
return false;
}
}
catch (Exception ex)
{
TempOffLineInfo.MsgInfo = "获取产品条码异常:" + ex.Message;
TempOffLineInfo.MsgAlarmFlag = true;
catch (Exception ex)
{
TempOffLineInfo.MsgInfo = "获取产品条码异常:" + ex.Message;
TempOffLineInfo.MsgAlarmFlag = true;
//界面刷新
// TempOffLineInfo.ProductRefreshFlag = true;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
log.Info(BarCode + "条码验证异常:" + ex.Message.ToString());
return false;
return false;
}
}
}
/// <summary>
/// 条码系统保存接口
/// </summary>
/// <param name="TempOffLineInfo"></param>
/// <returns></returns>
public bool uploadSnSysytem(TempInfo TempOffLineInfo)
/// <summary>
/// 条码系统保存接口
/// </summary>
/// <param name="TempOffLineInfo"></param>
/// <returns></returns>
public bool uploadSnSysytem(TempInfo TempOffLineInfo)
{
try
{
@ -628,12 +632,12 @@ namespace Aucma.Core.ProductOffLine.Business
// string strSave = "Y";
if (!string.IsNullOrEmpty(strSave))
{
if (strSave == "Y" || strSave=="S")
if (strSave == "Y" || strSave == "S")
{
log.Info(TempOffLineInfo.ProductSNCode + "上传条码成功:" + strSave);
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",上传条码成功";
//界面刷新
// TempOffLineInfo.ProductRefreshFlag = true;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
@ -700,15 +704,15 @@ namespace Aucma.Core.ProductOffLine.Business
// 查询本地数据库是否有数据
OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == TempOffLineInfo.ProductSNCode).Result;
if (offLineInfo != null && offLineInfo.PlcResult==1)
if (offLineInfo != null && offLineInfo.PlcResult == 1)
{
log.Info(TempOffLineInfo.ProductSNCode + "条码重复上传plc应答字为1未响应为2可以再次放行");
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "条码重复plc应答字为1可以放行";
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
return true;
log.Info(TempOffLineInfo.ProductSNCode + "条码重复上传plc应答字为1未响应为2可以再次放行");
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "条码重复plc应答字为1可以放行";
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
return true;
}
else
{
@ -716,18 +720,18 @@ namespace Aucma.Core.ProductOffLine.Business
TempOffLineInfo.MsgAlarmFlag = true;
TempOffLineInfo.MsgInfo = "条码重复,plc应答字2,禁止重复放行,上传时间:" + offLineInfo.ProductScanTime;
RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
return false;
}
}
catch (Exception ex)
{
log.Error("CodeRepeatProcess()异常" + ex.Message.ToString());
return false;
}
}
#region 条码重复历史处理方法
@ -792,21 +796,21 @@ namespace Aucma.Core.ProductOffLine.Business
/// strDirection "A" ? 1 : 2;入库方向A,B
/// </summary>
/// <param name="materialType"></param>
private bool DownLoadPassFlag(int scannerNo,string strDirection)
{
// 入库方向A,B
int direction = strDirection == "A" ? 1 : 2;
bool result = false;
try
private bool DownLoadPassFlag(int scannerNo, string strDirection)
{
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
if (obj != null)
// 入库方向A,B
int direction = strDirection == "A" ? 1 : 2;
bool result = false;
try
{
if(scannerNo == 1) // 扫码器1对应的货道地址内侧
{
log.Info(TempOffLineInfo1.ProductSNCode + ":内侧下发plc放行信号,入库方向ZR1001,放行信号ZR1003分别写:"+ direction.ToString()+"/1" + ",等待反馈");
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
if (obj != null)
{
if (scannerNo == 1) // 扫码器1对应的货道地址内侧
{
log.Info(TempOffLineInfo1.ProductSNCode + ":内侧下发plc放行信号,入库方向ZR1001,放行信号ZR1003分别写:" + direction.ToString() + "/1" + ",等待反馈");
TempOffLineInfo1.MsgInfo = TempOffLineInfo1.MsgInfo + "下发放行,";
RefreshScanMateriaCodeEvent(TempOffLineInfo1);
//TempOffLineInfo1.ProductRefreshFlag = true;
@ -814,9 +818,9 @@ namespace Aucma.Core.ProductOffLine.Business
obj.plc.WriteInt16("ZR1001", direction.ToString());
// 往plc写入放行信号
obj.plc.WriteInt16("ZR1003", "1");
}
else // 外侧
{
}
else // 外侧
{
log.Info(TempOffLineInfo2.ProductSNCode + ":外侧下发plc放行信号,入库方向ZR1000,放行信号ZR1002分别写:" + direction.ToString() + "/1" + ",等待反馈");
TempOffLineInfo2.MsgInfo = TempOffLineInfo2.MsgInfo + "下发放行,";
RefreshScanMateriaCodeEvent(TempOffLineInfo2);
@ -826,21 +830,21 @@ namespace Aucma.Core.ProductOffLine.Business
// 往plc写入放行信号
obj.plc.WriteInt16("ZR1002", "1");
}
DateTime targetTime = DateTime.Now.AddSeconds(18000); // 5h
// 等待plc反馈信号
while (true)
}
DateTime targetTime = DateTime.Now.AddSeconds(18000); // 5h
// 等待plc反馈信号
while (true)
{
if (DateTime.Now > targetTime) // plc超最大时限无反馈
{
if(DateTime.Now > targetTime) // plc超最大时限无反馈
{
log.Info("等待plc放行反馈信号超时");
result = false;
break;
}
log.Info("等待plc放行反馈信号超时");
result = false;
break;
}
if (scannerNo == 1)
{
// 读取plc反馈信号
if (obj.plc.ReadInt32("ZR1003") == 2)
{
@ -859,7 +863,7 @@ namespace Aucma.Core.ProductOffLine.Business
else
{
// 读取plc反馈信号
if (obj.plc.ReadInt16("ZR1002") == 2)
{
@ -875,182 +879,182 @@ namespace Aucma.Core.ProductOffLine.Business
break;
}
}
Thread.Sleep(500);
}
Thread.Sleep(500);
}
}
else
{
log.Info("获取plc连接对象信息为空");
}
}
else
catch (Exception ex)
{
log.Info("获取plc连接对象信息为空");
log.Error("下发plc放行信号方法SendPlcPass()出现异常,ex:" + ex);
}
return result;
}
catch (Exception ex)
{
log.Error("下发plc放行信号方法SendPlcPass()出现异常,ex:" + ex);
}
return result;
}
/// <summary>
/// 下发plc报警信号
/// </summary>
private void sendPlcError()
{
try
/// <summary>
/// 下发plc报警信号
/// </summary>
private void sendPlcError()
{
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
if (obj != null)
try
{
if (obj.plc.IsConnected)
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
if (obj != null)
{
// 下发报警信号
obj.plc.WriteInt32("D104", 1);
if (obj.plc.IsConnected)
{
// 下发报警信号
obj.plc.WriteInt32("D104", 1);
}
else
{
log.Info("成品下线plc连接失败请检查plc连接");
}
}
else
{
log.Info("成品下线plc连接失败请检查plc连接");
log.Info("获取plc连接对象信息为空");
}
}
else
catch (Exception ex)
{
log.Info("获取plc连接对象信息为空");
log.Error("下发plc放报警信号方法sendPlcError()出现异常,ex:" + ex);
}
}
catch (Exception ex)
{
log.Error("下发plc放报警信号方法sendPlcError()出现异常,ex:" + ex);
}
}
#endregion
#endregion
#region 工具方法
/// <summary>
/// 转换成字符串
/// </summary>
/// <param name="refData"></param>
/// <returns></returns>
public static string DBToString(object refData)
{
if (refData == null)
return "";
else
return refData == DBNull.Value ? "" : refData.ToString();
}
/// <summary>
/// 多码系统校验,暂未确定使用
/// </summary>
/// <param name="TempOffLineInfo"></param>
/// <returns></returns>
public bool TestBarCode(TempInfo TempOffLineInfo)
{
if (TempOffLineInfo.ProductCode.Replace("00000000", "") == "9002005518" || TempOffLineInfo.ProductCode.Replace("00000000", "") == "9002005517")
#region 工具方法
/// <summary>
/// 转换成字符串
/// </summary>
/// <param name="refData"></param>
/// <returns></returns>
public static string DBToString(object refData)
{
TempOffLineInfo.ProductRemark = "";
if (refData == null)
return "";
else
return refData == DBNull.Value ? "" : refData.ToString();
}
if (TempOffLineInfo.ProductRemark != "")
/// <summary>
/// 多码系统校验,暂未确定使用
/// </summary>
/// <param name="TempOffLineInfo"></param>
/// <returns></returns>
public bool TestBarCode(TempInfo TempOffLineInfo)
{
log.Info(TempOffLineInfo.ProductSNCode + ", 验证组合:" + TempOffLineInfo.ProductRemark);
if (TempOffLineInfo.ProductCode.Replace("00000000", "") == "9002005518" || TempOffLineInfo.ProductCode.Replace("00000000", "") == "9002005517")
{
TempOffLineInfo.ProductRemark = "";
}
string strCheck = TempOffLineInfo.ProductRemark.Replace("wb", "");
if (TempOffLineInfo.ProductRemark != "")
{
log.Info(TempOffLineInfo.ProductSNCode + ", 验证组合:" + TempOffLineInfo.ProductRemark);
Boolean blnY = strCheck.Contains("Y");
Boolean blnZ = strCheck.Contains("Z");
Boolean blnX = strCheck.Contains("X");
Boolean blnG = strCheck.Contains("G");
//Boolean blnC = strCheck.Contains("C");
string strCheck = TempOffLineInfo.ProductRemark.Replace("wb", "");
int iCheck = 0;
Boolean blnY = strCheck.Contains("Y");
Boolean blnZ = strCheck.Contains("Z");
Boolean blnX = strCheck.Contains("X");
Boolean blnG = strCheck.Contains("G");
//Boolean blnC = strCheck.Contains("C");
if (blnY == true)
iCheck = iCheck + 1;
int iCheck = 0;
if (blnZ == true)
iCheck = iCheck + 1;
if (blnY == true)
iCheck = iCheck + 1;
if (blnX == true)
iCheck = iCheck + 1;
if (blnZ == true)
iCheck = iCheck + 1;
if (blnG == true)
iCheck = iCheck + 1;
if (blnX == true)
iCheck = iCheck + 1;
//if (blnC == true)
// iCheck = iCheck + 1;
if (blnG == true)
iCheck = iCheck + 1;
//y一维码公司条码 oneCode
//z资产号 serialNumber
//x芯片 rfid
//g模块信息 sim
//wb不需要验证
//c是摄像头码 number1
if (blnY == true && iCheck > 1)
{
if (blnY || blnZ || blnX || blnG) //|| blnC
//if (blnC == true)
// iCheck = iCheck + 1;
//y一维码公司条码 oneCode
//z资产号 serialNumber
//x芯片 rfid
//g模块信息 sim
//wb不需要验证
//c是摄像头码 number1
if (blnY == true && iCheck > 1)
{
var client = new RestClient("http://10.100.83.113/syong/test.php");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AlwaysMultipartFormData = true;
request.AddParameter("oneCode", TempOffLineInfo.ProductSNCode);
request.AddParameter("Werks", "2701");
request.AddParameter("mark", "YZX");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
var chkInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<AucmaBarCodeModel>(response.Content);
TempOffLineInfo.oneCode = DBToString(chkInfo.oneCode);
TempOffLineInfo.serialNumber = DBToString(chkInfo.serialNumber);
TempOffLineInfo.rfid = DBToString(chkInfo.rfid);
TempOffLineInfo.sim = DBToString(chkInfo.sim);
TempOffLineInfo.number1 = DBToString(chkInfo.number1);
if (blnY == true && DBToString(chkInfo.oneCode) == "")
if (blnY || blnZ || blnX || blnG) //|| blnC
{
TempOffLineInfo.MsgInfo = "多码验证,公司条码验证失败";
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证,公司条码验证失败");
return false;
}
var client = new RestClient("http://10.100.83.113/syong/test.php");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AlwaysMultipartFormData = true;
request.AddParameter("oneCode", TempOffLineInfo.ProductSNCode);
request.AddParameter("Werks", "2701");
request.AddParameter("mark", "YZX");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
var chkInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<AucmaBarCodeModel>(response.Content);
TempOffLineInfo.oneCode = DBToString(chkInfo.oneCode);
TempOffLineInfo.serialNumber = DBToString(chkInfo.serialNumber);
TempOffLineInfo.rfid = DBToString(chkInfo.rfid);
TempOffLineInfo.sim = DBToString(chkInfo.sim);
TempOffLineInfo.number1 = DBToString(chkInfo.number1);
if (blnY == true && DBToString(chkInfo.oneCode) == "")
{
TempOffLineInfo.MsgInfo = "多码验证,公司条码验证失败";
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证,公司条码验证失败");
return false;
}
if (blnZ == true && DBToString(chkInfo.serialNumber) == "")
{
TempOffLineInfo.MsgInfo = "多码验证,资产号验证失败";
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证,资产号验证失败");
return false;
}
if (blnZ == true && DBToString(chkInfo.serialNumber) == "")
{
TempOffLineInfo.MsgInfo = "多码验证,资产号验证失败";
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证,资产号验证失败");
return false;
}
if (blnX == true && DBToString(chkInfo.rfid) == "")
{
TempOffLineInfo.MsgInfo = "多码验证,芯片验证失败";
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证,芯片验证失败");
return false;
}
if (blnX == true && DBToString(chkInfo.rfid) == "")
{
TempOffLineInfo.MsgInfo = "多码验证,芯片验证失败";
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证,芯片验证失败");
return false;
}
if (blnG == true && DBToString(chkInfo.sim) == "")
{
TempOffLineInfo.MsgInfo = "多码验证,模块信息验证失败";
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证,模块信息验证失败");
return false;
}
if (blnG == true && DBToString(chkInfo.sim) == "")
{
TempOffLineInfo.MsgInfo = "多码验证,模块信息验证失败";
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证,模块信息验证失败");
return false;
}
return true;
return true;
}
}
}
return true;
}
return true;
}
/// <summary>
/// <summary>
/// 将 TempInfo转换为OffLineInfo对象
/// </summary>
/// <typeparam name="A">类型A</typeparam>
/// <typeparam name="B">类型B</typeparam>
/// <param name="b">类型为B的参数b</param>
/// <returns>拷贝b中相同属性的值的a</returns>
public OffLineInfo MapperTwo(TempInfo b)
public OffLineInfo MapperTwo(TempInfo b)
{
OffLineInfo a = new OffLineInfo();
try
@ -1080,9 +1084,17 @@ namespace Aucma.Core.ProductOffLine.Business
}
return a;
}
#endregion
/// <summary>
/// 验证条码是否是包含特征
/// </summary>
/// <param name="packagBarCode">成品码</param>
/// <param name="SNCode">包装码</param>
public void check(string packagBarCode, string SNCode)
{
}
}
}

@ -61,7 +61,7 @@ namespace Aucma.Core.TemperatureTask
try
{
flag = false;
var historyList = _codeMESServices.QueryAsync(d=>d.IsSync==0).Result;
var historyList = _codeMESServices.QueryAsync(d => d.IsSync == 0).Result;
Console.WriteLine(historyList.ToJson());
var query = (from a in historyList
select new TemperatureHistory
@ -77,7 +77,7 @@ namespace Aucma.Core.TemperatureTask
TestTime = a.TestTime,
TestedTime = a.TestedTime,
Etemp = a.Etemp,
BeginDateTime =Convert.ToDateTime(a.BeginDateTime),
BeginDateTime = Convert.ToDateTime(a.BeginDateTime),
CpResult = a.CpResult,
EndDateTime = Convert.ToDateTime(a.EndDateTime),
UserName = a.UserName,
@ -91,27 +91,27 @@ namespace Aucma.Core.TemperatureTask
LowV_PowerMax = a.LowV_PowerMax,
LowV_PowerFact = a.LowV_PowerFact,
LowVoltage = a.LowVoltage,
SyncDate =DateTime.Now
SyncDate = DateTime.Now
}).ToList();
if (query == null || query.Count == 0) return;
logHelper.Error($"读取数据个数:{historyList.Count()}");
Console.WriteLine($"【{DateTime.Now}】读取数据个数:{historyList.Count()}");
var result = _temperatureHistoryServices.AddAsync(query).Result;
if (result >0)
var result = _temperatureHistoryServices.AddAsync(query).Result;
if (result > 0)
{
historyList.ForEach(d => d.IsSync = 1);
int r = _codeMESServices.UpateTemperatureHistoryFlag(historyList);
if (r> 0)
int r = _codeMESServices.UpateTemperatureHistoryFlag(historyList);
if (r > 0)
{
InsertToCompleteAndCheck(query);//保存过点数据
//发送post 请求
PostToMes(query);
Console.WriteLine($"【{DateTime.Now}】保存测温数据成功!保存数量:{query.Count}");
} }
}
}
Console.WriteLine($"【{DateTime.Now}】测温数据同步成功!数量:{query.Count}");
}
catch (Exception ex)
{

Loading…
Cancel
Save