change-成品下线业务处理异步改同步

dev
liuwf 1 year ago
parent ef7dada70e
commit 66857d3f24

@ -104,10 +104,9 @@ namespace Aucma.Core.ProductOffLine.Business
public async void test() public async void test()
{ {
string result = await _productOffLineServices.QueryChecked("1531000AP0098DCU0481"); string result = await _productOffLineServices.QueryChecked("1531000AP0098DCU0481");
Console.WriteLine(result); Console.WriteLine(result);
// string tt = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000004899@BCD-160C,家电下乡@@BCD-160C@皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01"; // string tt = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000004899@BCD-160C,家电下乡@@BCD-160C@皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01";
//Task.Run(() => //Task.Run(() =>
//{ //{
@ -122,9 +121,7 @@ namespace Aucma.Core.ProductOffLine.Business
/// </summary> /// </summary>
/// <param name="code"></param> /// <param name="code"></param>
/// <param name="direction">扫码器方向</param> /// <param name="direction">扫码器方向</param>
public async void MaterialBarScanEvent(string code,string scannerIp)//接收条码数据 public void MaterialBarScanEvent(string code,string scannerIp)//接收条码数据
{
await Task.Run(async () =>
{ {
Console.WriteLine(scannerIp); Console.WriteLine(scannerIp);
int ScannerNo = scannerIp == Appsettings.app("Middleware", "Scanner1", "Ip") ? 1 : 2; // 确定是哪个扫码器 int ScannerNo = scannerIp == Appsettings.app("Middleware", "Scanner1", "Ip") ? 1 : 2; // 确定是哪个扫码器
@ -133,26 +130,26 @@ namespace Aucma.Core.ProductOffLine.Business
if (ScannerNo == 1) if (ScannerNo == 1)
{ {
//1.扫描的SN条码去条码系统校验 //1.扫描的SN条码去条码系统校验
BackResult = await HandleMaterialBarCode(code.Trim(), TempOffLineInfo1); //扫码器1 BackResult = HandleMaterialBarCode(code.Trim(), TempOffLineInfo1); //扫码器1
materialType = TempOffLineInfo1.ProductCode; materialType = TempOffLineInfo1.ProductCode;
if (!BackResult) if (!BackResult)
{ {
return; return;
} }
// 2.更新mes数据库 // 2.更新mes数据库
BackResult = await updateMesData(TempOffLineInfo1); BackResult = updateMesData(TempOffLineInfo1);
log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo1.ProductOrderNo, TempOffLineInfo1.OrderQty)); log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo1.ProductOrderNo, TempOffLineInfo1.OrderQty));
} }
else else
{ {
BackResult = await HandleMaterialBarCode(code.Trim(), TempOffLineInfo2); //扫码器2 BackResult = HandleMaterialBarCode(code.Trim(), TempOffLineInfo2); //扫码器2
materialType = TempOffLineInfo2.ProductCode; materialType = TempOffLineInfo2.ProductCode;
if (!BackResult) if (!BackResult)
{ {
return; return;
} }
// 2.更新mes数据库 // 2.更新mes数据库
BackResult = await updateMesData(TempOffLineInfo2); BackResult = updateMesData(TempOffLineInfo2);
log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo2.ProductOrderNo, TempOffLineInfo2.OrderQty)); log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo2.ProductOrderNo, TempOffLineInfo2.OrderQty));
} }
if (BackResult == true) if (BackResult == true)
@ -170,7 +167,6 @@ namespace Aucma.Core.ProductOffLine.Business
} }
log.Info("plc放行反馈成功"); log.Info("plc放行反馈成功");
} }
});
} }
@ -179,23 +175,23 @@ namespace Aucma.Core.ProductOffLine.Business
/// </summary> /// </summary>
/// <param name="BarCode"></param> /// <param name="BarCode"></param>
/// <returns></returns> /// <returns></returns>
public async Task<bool> updateMesData(TempInfo TempOffLineInfo) public bool updateMesData(TempInfo TempOffLineInfo)
{ {
try try
{ {
OffLineInfo info11 = MapperTwo(TempOffLineInfo); OffLineInfo info11 = MapperTwo(TempOffLineInfo);
// 添加成品下线表 // 添加成品下线表
CodeBindingRecord bindingRecord1 = await _codeBindingServices.FirstAsync(x=>x.ProductCode == info11.ProductCode); CodeBindingRecord bindingRecord1 = _codeBindingServices.FirstAsync(x=>x.ProductCode == info11.ProductCode).Result;
if (bindingRecord1 == null) return false; if (bindingRecord1 == null) return false;
info11.BoxCode = bindingRecord1.BoxCode; info11.BoxCode = bindingRecord1.BoxCode;
// 产线 // 产线
info11.ProductLineCode = "CX_01"; info11.ProductLineCode = "CX_01";
await _offLineInfoServices.AddAsync(info11); _offLineInfoServices.AddAsync(info11);
// 修改订单表 // 修改订单表
////6.更新mes 数据库完成数量和时间(BASE_ORDERINFO) 注意:查询的字段可能需要修改,确保数据一致 ////6.更新mes 数据库完成数量和时间(BASE_ORDERINFO) 注意:查询的字段可能需要修改,确保数据一致
////6.1截取订单号去查询更新BASE_ORDERINFO,全放到service处理 ////6.1截取订单号去查询更新BASE_ORDERINFO,全放到service处理
BaseOrderInfo order = await _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo); BaseOrderInfo order = _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo).Result;
// order.CompleteAmount++; // order.CompleteAmount++;
//if (order.CompleteAmount == order.OrderAmount) //if (order.CompleteAmount == order.OrderAmount)
@ -205,17 +201,19 @@ namespace Aucma.Core.ProductOffLine.Business
//order.UpdatedTime = DateTime.Now; //order.UpdatedTime = DateTime.Now;
//await _baseOrderInfoServices.UpdateAsync(order); //await _baseOrderInfoServices.UpdateAsync(order);
#region 更新过点数据 #region 暂时不启用,因为还没打箱体码,查不到数据,更新过点数据
PrintBarCode print = await _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == bindingRecord1.BoxCode); //PrintBarCode print = await _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == bindingRecord1.BoxCode);
MaterialCompletion completion = new MaterialCompletion(); //MaterialCompletion completion = new MaterialCompletion();
completion.OrderCode = print.OrderCode; //completion.OrderCode = print.OrderCode;
completion.MaterialBarcode = bindingRecord1.BoxCode; //completion.MaterialBarcode = bindingRecord1.BoxCode;
completion.MaterialCode = print.MaterialCode; //completion.MaterialCode = print.MaterialCode;
completion.MaterialName = print.MaterialName; //completion.MaterialName = print.MaterialName;
completion.StationName = "1008" ; //completion.StationName = "1008" ;
completion.CompleteDate = DateTime.Now; //completion.CompleteDate = DateTime.Now;
await _iMaterialCompletionServices.AddAsync(completion); //await _iMaterialCompletionServices.AddAsync(completion);
#endregion #endregion
return true; return true;
} }
catch (Exception) catch (Exception)
@ -231,7 +229,7 @@ namespace Aucma.Core.ProductOffLine.Business
/// </summary> /// </summary>
/// <param name="BarCode"></param> /// <param name="BarCode"></param>
/// <returns></returns> /// <returns></returns>
public async Task<bool> HandleMaterialBarCode(string BarCode,TempInfo TempOffLineInfo) public bool HandleMaterialBarCode(string BarCode,TempInfo TempOffLineInfo)
{ {
try try
{ {
@ -316,7 +314,7 @@ namespace Aucma.Core.ProductOffLine.Business
return false; return false;
} }
// mes查询订单数据, 异常处理后期可能根据SN码查箱体码查订单号并检查更新订单数据 // mes查询订单数据, 异常处理后期可能根据SN码查箱体码查订单号并检查更新订单数据
BaseOrderInfo order = await _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo.Replace("0000", "")); BaseOrderInfo order = _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo.Replace("0000", "")).Result;
//2.上传条码系统 //2.上传条码系统
if (!string.IsNullOrEmpty(TempOffLineInfo.ProductOrderNo)) if (!string.IsNullOrEmpty(TempOffLineInfo.ProductOrderNo))
{ {
@ -347,7 +345,7 @@ namespace Aucma.Core.ProductOffLine.Business
if (strSave.Contains("条码重复")) if (strSave.Contains("条码重复"))
{ {
// 查询本地数据库是否有数据 // 查询本地数据库是否有数据
OffLineInfo offLineInfo = await _offLineInfoServices.FirstAsync(x => x.ProductSNCode == BarCode); OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == BarCode).Result;
if (offLineInfo != null) if (offLineInfo != null)
{ {
log.Info(BarCode + "条码重复,本地已存在,放行"); log.Info(BarCode + "条码重复,本地已存在,放行");
@ -365,7 +363,7 @@ namespace Aucma.Core.ProductOffLine.Business
{ {
log.Info(BarCode + "条码重复,本地不存在,已插入,放行"); log.Info(BarCode + "条码重复,本地不存在,已插入,放行");
OffLineInfo info11 = MapperTwo(TempOffLineInfo); OffLineInfo info11 = MapperTwo(TempOffLineInfo);
await _offLineInfoServices.AddAsync(info11); _offLineInfoServices.AddAsync(info11);
return true; return true;
} }
} }

Loading…
Cancel
Save