|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Admin.Core.Model;
|
|
|
|
|
using Admin.Core.Model.Model_New;
|
|
|
|
|
using Admin.Core.Service;
|
|
|
|
@ -8,6 +9,7 @@ using Aucma.Core.ProductOffLine.Models;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.IdentityModel.Logging;
|
|
|
|
|
using NetTaste;
|
|
|
|
|
using RestSharp;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
@ -38,15 +40,19 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
// public OffLineBusiness(){}
|
|
|
|
|
|
|
|
|
|
#region 变量定义
|
|
|
|
|
public static TempInfo TempOffLineInfo = new TempInfo();
|
|
|
|
|
public static TempInfo FDOffLineInfo = new TempInfo();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扫码器1扫到条码的临时数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static TempInfo TempOffLineInfo1 = new TempInfo();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扫码器2扫到条码的临时数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static TempInfo TempOffLineInfo2 = new TempInfo();
|
|
|
|
|
// 河南工厂编码
|
|
|
|
|
private static string Werks = "1301";
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 接口引用
|
|
|
|
|
|
|
|
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OffLineBusiness));
|
|
|
|
@ -58,8 +64,6 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 委托事件
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -87,148 +91,132 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async void test()
|
|
|
|
|
{
|
|
|
|
|
//TempInfo info = new TempInfo();
|
|
|
|
|
//string tt = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000000807@BCD-160C,家电下乡@@BCD-160C@皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01";
|
|
|
|
|
//string[] FArrayList = tt.Split('@');
|
|
|
|
|
//if (FArrayList[0].ToUpper() == "Y") //查询数据成功
|
|
|
|
|
//{
|
|
|
|
|
// #region 实体赋值
|
|
|
|
|
// info.ProductFactoryCode = FArrayList[1];
|
|
|
|
|
// info.ProductSNCode = FArrayList[2];
|
|
|
|
|
// info.ProductOrderNo = DBToString(FArrayList[3]);
|
|
|
|
|
// info.ProductSaleNo = DBToString(FArrayList[4]);
|
|
|
|
|
// info.ProductSaleLineNo = DBToString(FArrayList[5]);
|
|
|
|
|
// info.ProductCheckInfo = DBToString(FArrayList[6]); //验证组合
|
|
|
|
|
// info.ProductCode = DBToString(FArrayList[7]);
|
|
|
|
|
// info.ProductName = DBToString(FArrayList[8]); //产品描述
|
|
|
|
|
// info.ProductType = FArrayList[9];
|
|
|
|
|
// info.ProductModel = FArrayList[10]; //产品型号
|
|
|
|
|
// info.ProductRemark = DBToString(FArrayList[11]);
|
|
|
|
|
// info.ProductBarNo = FArrayList[12];
|
|
|
|
|
// info.ProductMasterModel = FArrayList[13]; //产品主型号
|
|
|
|
|
// info.ProductVersion = FArrayList[14];
|
|
|
|
|
// info.ProductUseInfo = FArrayList[15];//产品用途
|
|
|
|
|
// info.ProductCirculate = FArrayList[16];//流通特性
|
|
|
|
|
// info.ProductCreateDate = FArrayList[17];
|
|
|
|
|
// #endregion
|
|
|
|
|
// info.ProductScanTime = System.DateTime.Now;
|
|
|
|
|
// info.number1 = "111";
|
|
|
|
|
// OffLineInfo info11 = MapperTwo(info);
|
|
|
|
|
string tt = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000000807@BCD-160C,家电下乡@@BCD-160C@皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01";
|
|
|
|
|
string[] FArrayList = tt.Split('@');
|
|
|
|
|
if (FArrayList[0].ToUpper() == "Y") //查询数据成功
|
|
|
|
|
{
|
|
|
|
|
#region 实体赋值
|
|
|
|
|
TempOffLineInfo1.ProductFactoryCode = FArrayList[1];
|
|
|
|
|
TempOffLineInfo1.ProductSNCode = FArrayList[2];
|
|
|
|
|
TempOffLineInfo1.ProductOrderNo = DBToString(FArrayList[3]);
|
|
|
|
|
TempOffLineInfo1.ProductSaleNo = DBToString(FArrayList[4]);
|
|
|
|
|
TempOffLineInfo1.ProductSaleLineNo = DBToString(FArrayList[5]);
|
|
|
|
|
TempOffLineInfo1.ProductCheckInfo = DBToString(FArrayList[6]); //验证组合
|
|
|
|
|
TempOffLineInfo1.ProductCode = DBToString(FArrayList[7]);
|
|
|
|
|
TempOffLineInfo1.ProductName = DBToString(FArrayList[8]); //产品描述
|
|
|
|
|
TempOffLineInfo1.ProductType = FArrayList[9];
|
|
|
|
|
TempOffLineInfo1.ProductModel = FArrayList[10]; //产品型号
|
|
|
|
|
TempOffLineInfo1.ProductRemark = DBToString(FArrayList[11]);
|
|
|
|
|
TempOffLineInfo1.ProductBarNo = FArrayList[12];
|
|
|
|
|
TempOffLineInfo1.ProductMasterModel = FArrayList[13]; //产品主型号
|
|
|
|
|
TempOffLineInfo1.ProductVersion = FArrayList[14];
|
|
|
|
|
TempOffLineInfo1.ProductUseInfo = FArrayList[15];//产品用途
|
|
|
|
|
TempOffLineInfo1.ProductCirculate = FArrayList[16];//流通特性
|
|
|
|
|
TempOffLineInfo1.ProductCreateDate = FArrayList[17];
|
|
|
|
|
#endregion
|
|
|
|
|
TempOffLineInfo1.ProductScanTime = System.DateTime.Now;
|
|
|
|
|
TempOffLineInfo1.number1 = "111";
|
|
|
|
|
// OffLineInfo info11 = MapperTwo(TempOffLineInfo);
|
|
|
|
|
// int a = await _offLineInfoServices.AddAsync(info11);
|
|
|
|
|
// Console.WriteLine(a);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 处理条码
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="code"></param>
|
|
|
|
|
/// <param name="direction">扫码器方向</param>
|
|
|
|
|
public async void MaterialBarScanEvent(string code)//接收条码数据
|
|
|
|
|
public async void MaterialBarScanEvent(string code,string scannerIp)//接收条码数据
|
|
|
|
|
{
|
|
|
|
|
int ScannerNo = scannerIp== Appsettings.app("Middleware", "Scanner1", "Ip") ? 1:2 ; // 确定是哪个扫码器
|
|
|
|
|
|
|
|
|
|
bool BackResult = false;
|
|
|
|
|
if (ScannerNo==1)
|
|
|
|
|
{
|
|
|
|
|
//1.扫描的SN条码去条码系统校验
|
|
|
|
|
bool BackResult = await HandleMaterialBarCode(code.Trim()); //处理条码信息
|
|
|
|
|
TempOffLineInfo.ReadFlag = 0;
|
|
|
|
|
if (BackResult == true)
|
|
|
|
|
{
|
|
|
|
|
TempOffLineInfo.ProductRefreshFlag = true;
|
|
|
|
|
// 更新mes数据库
|
|
|
|
|
|
|
|
|
|
OffLineInfo info11 = MapperTwo(TempOffLineInfo);
|
|
|
|
|
int a = await _offLineInfoServices.AddAsync(info11);
|
|
|
|
|
log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo.ProductOrderNo.Replace("0000", ""), TempOffLineInfo.OrderQty));
|
|
|
|
|
if (a > 0)
|
|
|
|
|
{
|
|
|
|
|
// 先查询分垛方向A或者B eg:000000009001000718=>9001000718
|
|
|
|
|
string direction = getDirectioneEvent?.Invoke(TempOffLineInfo.ProductCode.Replace("00000000", ""));
|
|
|
|
|
|
|
|
|
|
// DownLoadPassFlag(BackResult); //下发plc放行信号,分垛AB库
|
|
|
|
|
TempOffLineInfo.ReadFlag = 1; //放行成功
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TempOffLineInfo.ReadFlag = 2; //保存条码失败
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
log.Info("条码验证失败");
|
|
|
|
|
TempOffLineInfo.ReadFlag = 3; // 条码验证失败
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BackResult = await HandleMaterialBarCode(code.Trim(), TempOffLineInfo1); //扫码器1
|
|
|
|
|
// 2.更新mes数据库
|
|
|
|
|
await updateMesData(TempOffLineInfo1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BackResult = await HandleMaterialBarCode(code.Trim(), TempOffLineInfo2); //扫码器2
|
|
|
|
|
// 2.更新mes数据库
|
|
|
|
|
await updateMesData(TempOffLineInfo1);
|
|
|
|
|
}
|
|
|
|
|
if (BackResult == true)
|
|
|
|
|
{
|
|
|
|
|
log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo1.ProductOrderNo, TempOffLineInfo1.OrderQty));
|
|
|
|
|
// 先查询分垛方向A或者B
|
|
|
|
|
string direction = getDirectioneEvent?.Invoke(TempOffLineInfo1.ProductCode);
|
|
|
|
|
DownLoadPassFlag(ScannerNo,direction); //下发plc放行信号,分垛AB库
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 条码验证成功后,更新mes数据库 成品下线表,订单表等等
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="BarCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> updateMesData(TempInfo TempOffLineInfo)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// TempOffLineInfo.ProductRefreshFlag = true;
|
|
|
|
|
OffLineInfo info11 = MapperTwo(TempOffLineInfo);
|
|
|
|
|
// 添加成品下线表
|
|
|
|
|
await _offLineInfoServices.AddAsync(info11);
|
|
|
|
|
// 添加订单表
|
|
|
|
|
////6.更新mes数据库完成数量和时间(BASE_ORDERINFO,PRODUCT_PLANINFO) 注意:查询的字段可能需要修改,确保数据一致
|
|
|
|
|
|
|
|
|
|
////6.1截取订单号去查询更新BASE_ORDERINFO,全放到service处理
|
|
|
|
|
//string orderCode = "11215484";
|
|
|
|
|
//List<BaseOrderInfo> orders = await _baseOrderInfoServices.QueryAsync(x => x.OrderCode == orderCode);
|
|
|
|
|
//BaseOrderInfo order = orders.FirstOrDefault();
|
|
|
|
|
//if (order.CompleteAmount == 0)
|
|
|
|
|
//{
|
|
|
|
|
// order.CompleteAmount++;
|
|
|
|
|
// order.BeginDate = DateTime.Now;
|
|
|
|
|
//}
|
|
|
|
|
//if (order.CompleteAmount == order.OrderAmount)
|
|
|
|
|
//{
|
|
|
|
|
// order.EndDate = DateTime.Now;
|
|
|
|
|
//}
|
|
|
|
|
//order.UpdatedTime = DateTime.Now;
|
|
|
|
|
//_baseOrderInfoServices.UpdateAsync(order);
|
|
|
|
|
////6.2根据订单号去更新PRODUCT_PLANINFO
|
|
|
|
|
//List<ProductPlanInfo> productInfos = await _productPlanInfoServices.QueryAsync(x => x.OrderCode == orderCode);
|
|
|
|
|
//ProductPlanInfo productInfo = productInfos.FirstOrDefault();
|
|
|
|
|
//if (productInfo.CompleteAmount == 0)
|
|
|
|
|
//{
|
|
|
|
|
// productInfo.CompleteAmount++;
|
|
|
|
|
// productInfo.BeginTime = DateTime.Now;
|
|
|
|
|
//}
|
|
|
|
|
//if (productInfo.CompleteAmount == productInfo.PlanAmount)
|
|
|
|
|
//{
|
|
|
|
|
// productInfo.EndTime = DateTime.Now;
|
|
|
|
|
//}
|
|
|
|
|
//productInfo.UpdatedTime = DateTime.Now;
|
|
|
|
|
//await _productPlanInfoServices.UpdateAsync(productInfo);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
log.Info("更新数据库记录失败");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // 如果校验失败,下发报警
|
|
|
|
|
// if ("N".Equals(result.Substring(0, 1)))
|
|
|
|
|
//{
|
|
|
|
|
// sendPlcError();
|
|
|
|
|
// // 刷新页面提示信息 result.Substring(2)
|
|
|
|
|
// return false;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//3.分垛A,B库逻辑(先左边读到的条码分A库,右边读到的B库==>预留分库逻辑)
|
|
|
|
|
|
|
|
|
|
////4.下发plc信号
|
|
|
|
|
//bool flag = SendPlcPass();
|
|
|
|
|
//if (!flag)
|
|
|
|
|
//{
|
|
|
|
|
// log.Error("获取plc反馈失败");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//Console.WriteLine(code);
|
|
|
|
|
//return;
|
|
|
|
|
//5.调条码系统保存入库接口SaveBarcodeInfo
|
|
|
|
|
//string saveResult = await _productOffLineServices.SaveBarcodeInfo("333", "ILS_SORT", "11111", 1);
|
|
|
|
|
//if (string.IsNullOrEmpty(saveResult) || "E".Equals(saveResult.Substring(0, 1)))
|
|
|
|
|
//{
|
|
|
|
|
// log.Error("条码系统保存接口出错");
|
|
|
|
|
// sendPlcError();
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
////6.更新mes数据库完成数量和时间(BASE_ORDERINFO,PRODUCT_PLANINFO) 注意:查询的字段可能需要修改,确保数据一致
|
|
|
|
|
|
|
|
|
|
////6.1截取订单号去查询更新BASE_ORDERINFO,全放到service处理
|
|
|
|
|
//string orderCode = "11215484";
|
|
|
|
|
//List<BaseOrderInfo> orders = await _baseOrderInfoServices.QueryAsync(x => x.OrderCode == orderCode);
|
|
|
|
|
//BaseOrderInfo order = orders.FirstOrDefault();
|
|
|
|
|
//if (order.CompleteAmount == 0)
|
|
|
|
|
//{
|
|
|
|
|
// order.CompleteAmount++;
|
|
|
|
|
// order.BeginDate = DateTime.Now;
|
|
|
|
|
//}
|
|
|
|
|
//if (order.CompleteAmount == order.OrderAmount)
|
|
|
|
|
//{
|
|
|
|
|
// order.EndDate = DateTime.Now;
|
|
|
|
|
//}
|
|
|
|
|
//order.UpdatedTime = DateTime.Now;
|
|
|
|
|
//_baseOrderInfoServices.UpdateAsync(order);
|
|
|
|
|
////6.2根据订单号去更新PRODUCT_PLANINFO
|
|
|
|
|
//List<ProductPlanInfo> productInfos = await _productPlanInfoServices.QueryAsync(x => x.OrderCode == orderCode);
|
|
|
|
|
//ProductPlanInfo productInfo = productInfos.FirstOrDefault();
|
|
|
|
|
//if (productInfo.CompleteAmount == 0)
|
|
|
|
|
//{
|
|
|
|
|
// productInfo.CompleteAmount++;
|
|
|
|
|
// productInfo.BeginTime = DateTime.Now;
|
|
|
|
|
//}
|
|
|
|
|
//if (productInfo.CompleteAmount == productInfo.PlanAmount)
|
|
|
|
|
//{
|
|
|
|
|
// productInfo.EndTime = DateTime.Now;
|
|
|
|
|
//}
|
|
|
|
|
//productInfo.UpdatedTime = DateTime.Now;
|
|
|
|
|
//await _productPlanInfoServices.UpdateAsync(productInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 去条码系统查询校验并保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="BarCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> HandleMaterialBarCode(string BarCode)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 去条码系统查询校验并保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="BarCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> HandleMaterialBarCode(string BarCode,TempInfo TempOffLineInfo)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -252,11 +240,11 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
TempOffLineInfo.MsgInfo = "获取信息成功" + BarCode + " 返回值:" + FArrayList[0].ToUpper();
|
|
|
|
|
TempOffLineInfo.ProductFactoryCode = FArrayList[1];
|
|
|
|
|
TempOffLineInfo.ProductSNCode = FArrayList[2];
|
|
|
|
|
TempOffLineInfo.ProductOrderNo = DBToString(FArrayList[3]);
|
|
|
|
|
TempOffLineInfo.ProductOrderNo = DBToString(FArrayList[3]).Replace("0000", "");
|
|
|
|
|
TempOffLineInfo.ProductSaleNo = DBToString(FArrayList[4]);
|
|
|
|
|
TempOffLineInfo.ProductSaleLineNo = DBToString(FArrayList[5]);
|
|
|
|
|
TempOffLineInfo.ProductCheckInfo = DBToString(FArrayList[6]); //验证组合
|
|
|
|
|
TempOffLineInfo.ProductCode = DBToString(FArrayList[7]);
|
|
|
|
|
TempOffLineInfo.ProductCode = DBToString(FArrayList[7]).Replace("00000000", "");
|
|
|
|
|
TempOffLineInfo.ProductName = DBToString(FArrayList[8]); //产品描述
|
|
|
|
|
TempOffLineInfo.ProductType = FArrayList[9];
|
|
|
|
|
TempOffLineInfo.ProductModel = FArrayList[10]; //产品型号
|
|
|
|
@ -270,18 +258,18 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// 多码系统校验,是否需要待定,现场看情况
|
|
|
|
|
bool flag = TestBarCode(TempOffLineInfo);
|
|
|
|
|
if (!flag)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// bool flag = TestBarCode(TempOffLineInfo);
|
|
|
|
|
// if (!flag)
|
|
|
|
|
// {
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证通过!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
log.Info(BarCode + "失败返回验证信息:" + FArrayList[1]);
|
|
|
|
|
#region 实体赋值
|
|
|
|
|
TempOffLineInfo.ProductDataFlag = true;
|
|
|
|
|
// TempOffLineInfo.ProductDataFlag = true;
|
|
|
|
|
TempOffLineInfo.MsgAlarmFlag = true;
|
|
|
|
|
TempOffLineInfo.MsgInfo = "获取信息失败. " + BarCode + " 返回值:" + FArrayList[0].ToString();
|
|
|
|
|
TempOffLineInfo.ProductOrderNo = "";
|
|
|
|
@ -339,7 +327,7 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
{
|
|
|
|
|
log.Info(BarCode + "条码重复,本地已存在");
|
|
|
|
|
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",上传条码失败" + strSave + "上传日期:" + DBToString(offLineInfo.ProductScanTime);
|
|
|
|
|
|
|
|
|
|
// chkout:条码重复是否允许放行
|
|
|
|
|
if (TempOffLineInfo.ChkOut == true)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
@ -380,21 +368,18 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
{
|
|
|
|
|
TempOffLineInfo.ProductRefreshFlag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region plc交互
|
|
|
|
|
private SemaphoreSlim semaphore = new SemaphoreSlim(0);
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下发plc放行信号,根据接收到的scannerNo不同,两条道的plc信号地址也不同
|
|
|
|
|
/// 下发plc放行信号,传进来扫码器编号,分垛方向A或者B,返回plc反馈结果
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
private bool SendPlcPass(int scannerNo)
|
|
|
|
|
private bool DownLoadPassFlag(int scannerNo,string strDirection)
|
|
|
|
|
{
|
|
|
|
|
// 入库方向A,B
|
|
|
|
|
int direction = strDirection == "A" ? 1 : 2;
|
|
|
|
|
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -402,26 +387,59 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
if (scannerNo == 1)
|
|
|
|
|
{
|
|
|
|
|
// 写入入库方向,两条道plc地址不同
|
|
|
|
|
obj.plc.WriteInt32("D100", scannerNo);
|
|
|
|
|
// 往plc写入放行信号
|
|
|
|
|
obj.plc.WriteInt32("D102", 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 写入入库方向,两条道plc地址不同
|
|
|
|
|
obj.plc.WriteInt32("D200", scannerNo);
|
|
|
|
|
// 往plc写入放行信号
|
|
|
|
|
obj.plc.WriteInt32("D202", 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 等待plc反馈信号
|
|
|
|
|
waitPlcSignal(scannerNo);
|
|
|
|
|
// semaphore.Wait();
|
|
|
|
|
result = true;
|
|
|
|
|
{
|
|
|
|
|
if(scannerNo == 1) // 扫码器1对应的货道地址
|
|
|
|
|
{
|
|
|
|
|
// 写入入库方向,两条道plc地址不同
|
|
|
|
|
obj.plc.WriteInt32("D100", direction);
|
|
|
|
|
// 往plc写入放行信号
|
|
|
|
|
obj.plc.WriteInt32("D102", 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 写入入库方向,两条道plc地址不同
|
|
|
|
|
obj.plc.WriteInt32("D200", direction);
|
|
|
|
|
// 往plc写入放行信号
|
|
|
|
|
obj.plc.WriteInt32("D202", 1);
|
|
|
|
|
}
|
|
|
|
|
DateTime targetTime = DateTime.Now.AddSeconds(8);
|
|
|
|
|
// 等待plc反馈信号
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
if(DateTime.Now > targetTime) // plc超最大时限无反馈
|
|
|
|
|
{
|
|
|
|
|
log.Info("等待plc放行反馈信号超时");
|
|
|
|
|
result = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (scannerNo == 1)
|
|
|
|
|
{
|
|
|
|
|
// 读取plc反馈信号
|
|
|
|
|
if (obj.plc.ReadInt32("D102") == 2)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("收到plc放行成功");
|
|
|
|
|
// 清空数据
|
|
|
|
|
obj.plc.WriteInt32("D100", 0);
|
|
|
|
|
obj.plc.WriteInt32("D102", 0);
|
|
|
|
|
result = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 读取plc反馈信号
|
|
|
|
|
if (obj.plc.ReadInt32("D202") == 2)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("收到plc放行成功");
|
|
|
|
|
// 清空数据
|
|
|
|
|
obj.plc.WriteInt32("D200", 0);
|
|
|
|
|
obj.plc.WriteInt32("D202", 0);
|
|
|
|
|
result = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -439,61 +457,6 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取plc放行反馈
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
private void waitPlcSignal(int scannerNo)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
bool isFlag = true;
|
|
|
|
|
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
|
|
|
|
|
|
|
|
|
|
if (obj != null && obj.plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
if (scannerNo == 1)
|
|
|
|
|
{
|
|
|
|
|
// 读取plc反馈信号
|
|
|
|
|
if (obj.plc.ReadInt32("D102") == 2)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("收到plc放行成功");
|
|
|
|
|
// 清空数据
|
|
|
|
|
obj.plc.WriteInt32("D100", 0);
|
|
|
|
|
obj.plc.WriteInt32("D102", 0);
|
|
|
|
|
isFlag = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 读取plc反馈信号
|
|
|
|
|
if (obj.plc.ReadInt32("D202") == 2)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("收到plc放行成功");
|
|
|
|
|
// 清空数据
|
|
|
|
|
obj.plc.WriteInt32("D200", 0);
|
|
|
|
|
obj.plc.WriteInt32("D202", 0);
|
|
|
|
|
isFlag = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
} while (isFlag);
|
|
|
|
|
// 释放信号量
|
|
|
|
|
//semaphore.Release();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
log.Info("成品下线plc连接失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Error("读取plc放行反馈方法waitPlcSignal()出现异常,ex:" + ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下发plc报警信号
|
|
|
|
@ -531,7 +494,7 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
|
|
|
|
|
#region 工具方法
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// 转换成字符串
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="refData"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
@ -544,7 +507,7 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 多码系统校验
|
|
|
|
|
/// 多码系统校验,暂未确定使用
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="TempOffLineInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
@ -646,15 +609,14 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 传入类型B的对象b,将b与a相同名称的值进行赋值给创建的a中
|
|
|
|
|
/// <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
|
|
|
|
@ -684,6 +646,9 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
}
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|