|
|
|
@ -14,6 +14,7 @@ using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
@ -39,14 +40,13 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
// public OffLineBusiness(){}
|
|
|
|
|
|
|
|
|
|
#region 变量定义
|
|
|
|
|
public static OffLineInfo TempOffLineInfo = new OffLineInfo();
|
|
|
|
|
public static OffLineInfo FDOffLineInfo = new OffLineInfo();
|
|
|
|
|
public static TempInfo TempOffLineInfo = new TempInfo();
|
|
|
|
|
public static TempInfo FDOffLineInfo = new TempInfo();
|
|
|
|
|
// 河南工厂编码
|
|
|
|
|
private static string Werks = "1301";
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 接口引用
|
|
|
|
|
|
|
|
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OffLineBusiness));
|
|
|
|
@ -91,110 +91,137 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
|
|
|
|
|
public async void test()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
BaseOrderInfo order = await _baseOrderInfoServices.FirstAsync();
|
|
|
|
|
Console.WriteLine(order);
|
|
|
|
|
//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);
|
|
|
|
|
// int a = await _offLineInfoServices.AddAsync(info11);
|
|
|
|
|
// Console.WriteLine(a);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 处理条码
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="code"></param>
|
|
|
|
|
/// <param name="direction">扫码器方向</param>
|
|
|
|
|
private async void MaterialBarScanEvent(string code)//接收条码数据
|
|
|
|
|
{
|
|
|
|
|
//1.扫描的SN条码去条码系统校验
|
|
|
|
|
bool BackResult = await HandleMaterialBarCode(code.Trim()); //处理条码信息
|
|
|
|
|
TempOffLineInfo.ReadFlag = 0;
|
|
|
|
|
if (BackResult == true)
|
|
|
|
|
public async void MaterialBarScanEvent(string code)//接收条码数据
|
|
|
|
|
{
|
|
|
|
|
TempOffLineInfo.ProductRefreshFlag = true;
|
|
|
|
|
// 更新mes数据库
|
|
|
|
|
int a = await _offLineInfoServices.AddAsync(TempOffLineInfo);
|
|
|
|
|
log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo.ProductOrderNo.Replace("0000", ""), TempOffLineInfo.OrderQty));
|
|
|
|
|
if (a > 0)
|
|
|
|
|
//1.扫描的SN条码去条码系统校验
|
|
|
|
|
bool BackResult = await HandleMaterialBarCode(code.Trim()); //处理条码信息
|
|
|
|
|
TempOffLineInfo.ReadFlag = 0;
|
|
|
|
|
if (BackResult == true)
|
|
|
|
|
{
|
|
|
|
|
// 先查询分垛方向A或者B eg:000000009001000718
|
|
|
|
|
string direction = getDirectioneEvent?.Invoke(TempOffLineInfo.ProductCode.Replace("00000000", ""));
|
|
|
|
|
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; //放行成功
|
|
|
|
|
// DownLoadPassFlag(BackResult); //下发plc放行信号,分垛AB库
|
|
|
|
|
TempOffLineInfo.ReadFlag = 1; //放行成功
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TempOffLineInfo.ReadFlag = 2; //保存条码失败
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TempOffLineInfo.ReadFlag = 2; //保存条码失败
|
|
|
|
|
log.Info("条码验证失败");
|
|
|
|
|
TempOffLineInfo.ReadFlag = 3; // 条码验证失败
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
log.Info("条码验证失败");
|
|
|
|
|
TempOffLineInfo.ReadFlag = 3; // 条码验证失败
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// // 如果校验失败,下发报警
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
// // 如果校验失败,下发报警
|
|
|
|
|
// 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>
|
|
|
|
|
/// 去条码系统查询校验并保存
|
|
|
|
@ -206,9 +233,9 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TempOffLineInfo.ProductSNCode = BarCode.Trim(); //SN码
|
|
|
|
|
TempOffLineInfo.ProductScanTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
TempOffLineInfo.ProductScanTime = System.DateTime.Now;
|
|
|
|
|
|
|
|
|
|
TempOffLineInfo.ProductOrderNo = "";
|
|
|
|
|
TempOffLineInfo.ProductOrderNo = "";
|
|
|
|
|
log.Info("条码验证开始:" + BarCode);
|
|
|
|
|
|
|
|
|
|
//1.查询条码系统
|
|
|
|
@ -321,7 +348,9 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
log.Info(BarCode + "条码重复,本地不存在,已上传中");
|
|
|
|
|
await _offLineInfoServices.AddAsync(TempOffLineInfo);
|
|
|
|
|
|
|
|
|
|
OffLineInfo info11 = MapperTwo(TempOffLineInfo);
|
|
|
|
|
await _offLineInfoServices.AddAsync(info11);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
@ -519,7 +548,7 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="TempOffLineInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool TestBarCode(OffLineInfo TempOffLineInfo)
|
|
|
|
|
public bool TestBarCode(TempInfo TempOffLineInfo)
|
|
|
|
|
{
|
|
|
|
|
if (TempOffLineInfo.ProductCode.Replace("00000000", "") == "9002005518" || TempOffLineInfo.ProductCode.Replace("00000000", "") == "9002005517")
|
|
|
|
|
{
|
|
|
|
@ -617,6 +646,44 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 传入类型B的对象b,将b与a相同名称的值进行赋值给创建的a中
|
|
|
|
|
/// </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)
|
|
|
|
|
{
|
|
|
|
|
OffLineInfo a = new OffLineInfo();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
a.ProductFactoryCode = b.ProductFactoryCode;
|
|
|
|
|
a.ProductSNCode = b.ProductSNCode;
|
|
|
|
|
a.ProductOrderNo = b.ProductOrderNo;
|
|
|
|
|
a.ProductSaleNo = b.ProductSaleNo;
|
|
|
|
|
a.ProductSaleLineNo = b.ProductSaleLineNo;
|
|
|
|
|
a.ProductCode = b.ProductCode;
|
|
|
|
|
a.ProductModel = b.ProductModel;
|
|
|
|
|
a.ProductName = b.ProductName;
|
|
|
|
|
a.ProductType = b.ProductType;
|
|
|
|
|
a.ProductCheckInfo = b.ProductCheckInfo;
|
|
|
|
|
a.ProductRemark = b.ProductRemark;
|
|
|
|
|
a.ProductBarNo = b.ProductBarNo;
|
|
|
|
|
a.ProductMasterModel = b.ProductMasterModel;
|
|
|
|
|
a.ProductVersion = b.ProductVersion;
|
|
|
|
|
a.ProductUseInfo = b.ProductUseInfo;
|
|
|
|
|
a.ProductCirculate = b.ProductCirculate;
|
|
|
|
|
a.ProductCreateDate = b.ProductCreateDate;
|
|
|
|
|
a.ProductScanTime = b.ProductScanTime;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|