liulb@mesnac.com 1 year ago
commit 544b4af331

@ -10,7 +10,7 @@ namespace Admin.Core.Model.Model_New
/// <summary> /// <summary>
/// 物料完成记录 /// 物料完成记录
/// </summary> /// </summary>
[SugarTable("PRINT_ORDERINFO", "AUCMA_SCADA")] [SugarTable("MATERIAL_COMPLETION", "AUCMA_SCADA")]
public class MaterialCompletion public class MaterialCompletion
{ {
/// <summary> /// <summary>
@ -20,7 +20,7 @@ namespace Admin.Core.Model.Model_New
public int ObjId { get; set; } public int ObjId { get; set; }
/// <summary> /// <summary>
/// 单编号 /// 单编号
/// </summary> /// </summary>
[SugarColumn(ColumnName = "ORDER_CODE")] [SugarColumn(ColumnName = "ORDER_CODE")]
public string OrderCode { get; set; } public string OrderCode { get; set; }
@ -54,5 +54,10 @@ namespace Admin.Core.Model.Model_New
/// </summary> /// </summary>
[SugarColumn(ColumnName = "COMPLETE_DATE")] [SugarColumn(ColumnName = "COMPLETE_DATE")]
public DateTime CompleteDate { get; set; } public DateTime CompleteDate { get; set; }
/// <summary>
/// 工单编号
/// </summary>
[SugarColumn(ColumnName = "PLAN_CODE")]
public string planCode { get; set; }
} }
} }

@ -55,6 +55,8 @@ namespace Admin.Core.Model
public string ProductCreateDate { get; set; }//生成日期 public string ProductCreateDate { get; set; }//生成日期
[SugarColumn(ColumnName = "PRODUCT_SCANTIME")] [SugarColumn(ColumnName = "PRODUCT_SCANTIME")]
public DateTime ProductScanTime { get; set; } //扫描时间 public DateTime ProductScanTime { get; set; } //扫描时间
[SugarColumn(ColumnName = "BOX_CODE")]
public string boxCode { get; set; } //扫描时间
} }
} }

@ -31,6 +31,7 @@ using Admin.Core.Model.ViewModels;
using System.Windows.Media; using System.Windows.Media;
using System.Drawing; using System.Drawing;
using Brushes = System.Windows.Media.Brushes; using Brushes = System.Windows.Media.Brushes;
using Admin.Core.Model.Model_New;
/* /*
* *
*/ */
@ -42,6 +43,10 @@ namespace Aucma.Core.CodeBinding.ViewModels
private readonly ICodeBindingRecordServices? _codeBindingRecordServices; private readonly ICodeBindingRecordServices? _codeBindingRecordServices;
private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices; private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices;
private readonly IBaseBomInfoServices? _baseBomInfoServices; private readonly IBaseBomInfoServices? _baseBomInfoServices;
private readonly IPrintBarCodeServices? _printBarCodeServices;
// 过点数据表物料完成记录MaterialCompletion
private readonly IMaterialCompletionServices? _iMaterialCompletionServices;
// 静态变量存code1 // 静态变量存code1
private static string code1Str = string.Empty; private static string code1Str = string.Empty;
// 定时检测数据库有没有pad绑定未放行的数据 // 定时检测数据库有没有pad绑定未放行的数据
@ -53,7 +58,10 @@ namespace Aucma.Core.CodeBinding.ViewModels
_codeBindingRecordServices = App.ServiceProvider.GetService<ICodeBindingRecordServices>(); _codeBindingRecordServices = App.ServiceProvider.GetService<ICodeBindingRecordServices>();
_baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>(); _baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
_baseMaterialInfoServices = App.ServiceProvider.GetService<IBaseMaterialInfoServices>(); _baseMaterialInfoServices = App.ServiceProvider.GetService<IBaseMaterialInfoServices>();
MvCodeHelper.ReceiveCode1Event += receiveCode1;
_printBarCodeServices = App.ServiceProvider.GetService<IPrintBarCodeServices>();
_iMaterialCompletionServices = App.ServiceProvider.GetService<IMaterialCompletionServices>();
MvCodeHelper.ReceiveCode1Event += receiveCode1;
MvCodeHelper.ReceiveCode2Event += receiveCode2; MvCodeHelper.ReceiveCode2Event += receiveCode2;
// pda手持检测plc放行定时器 // pda手持检测plc放行定时器
// StartPlcTimer(); // StartPlcTimer();
@ -346,39 +354,61 @@ namespace Aucma.Core.CodeBinding.ViewModels
/// <param name="materialType"></param> /// <param name="materialType"></param>
private async void receiveCode2(string code2) private async void receiveCode2(string code2)
{ {
log.Info("进入条码2处理函数receiveCode1,code2:" + code2); try
// 取之前读出来的code1
string code1 = code1Str;
if (string.IsNullOrEmpty(code1))
{ {
// 刷新页面提示信息 log.Info("进入条码2处理函数receiveCode1,code2:" + code2);
BindingInfo = "箱体码还未扫码"; // 取之前读出来的code1
return; string code1 = code1Str;
}
if (string.IsNullOrEmpty(code1))
{
// 刷新页面提示信息
BindingInfo = "箱体码还未扫码";
return;
}
// 1.数据库查询各个工序质检结果,不合格报警 // 1.数据库查询各个工序质检结果,不合格报警
// 2.查询条码绑定记录表(内胆箱壳绑定处就应该插入记录)绑定SN码 // 2.查询条码绑定记录表(内胆箱壳绑定处就应该插入记录)绑定SN码
List<CodeBindingRecord> list = await _codeBindingRecordServices.QueryAsync(x=> x.BoxCode==code1); List<CodeBindingRecord> list = await _codeBindingRecordServices.QueryAsync(x => x.BoxCode == code1);
CodeBindingRecord record = list.FirstOrDefault(); CodeBindingRecord record = list.FirstOrDefault();
List<BaseMaterialInfo> materialInfoList = await _baseMaterialInfoServices.QueryAsync(x => x.MaterialCode == code2.Substring(2, 10)); List<BaseMaterialInfo> materialInfoList = await _baseMaterialInfoServices.QueryAsync(x => x.MaterialCode == code2.Substring(2, 10));
record.BoxName = materialInfoList.FirstOrDefault().MaterialName; record.BoxName = materialInfoList.FirstOrDefault().MaterialName;
record.ProductCode = code2; record.ProductCode = code2;
record.RecordTime1 = System.DateTime.Now; record.RecordTime1 = System.DateTime.Now;
record.RecordTime2 = System.DateTime.Now; record.RecordTime2 = System.DateTime.Now;
record.BindingResult = "成功"; record.BindingResult = "成功";
// 3.下发plc放行信号
if (SendPlcPass()) // 3.下发plc放行信号
{ if (SendPlcPass())
record.isPlcPass = 2; {
record.isPlcPass = 2;
}
await _codeBindingRecordServices.UpdateAsync(record);
#region 更新过点数据,插入记录到MATERIAL_COMPLETION表
PrintBarCode print = await _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == code1);
if (print != null) return;
MaterialCompletion completion = new MaterialCompletion();
completion.OrderCode = print.OrderCode;
completion.MaterialBarcode = code1;
completion.MaterialCode = print.MaterialCode;
completion.MaterialName = print.MaterialName;
completion.StationName = "1007";
completion.CompleteDate = DateTime.Now;
await _iMaterialCompletionServices.AddAsync(completion);
#endregion
// 2.刷新界面信息
code1Str = string.Empty;
RefreshCode2(record);
} }
await _codeBindingRecordServices.UpdateAsync(record); catch (Exception)
// 2.刷新界面信息 {
RefreshCode2(record);
code1Str = string.Empty; code1Str = string.Empty;
}
} }

@ -81,7 +81,7 @@
"Enabled": true, "Enabled": true,
"HitRate": 50, "HitRate": 50,
//"Connection": "Data Source=localhost;Initial Catalog=Hsdb;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", //"Connection": "Data Source=localhost;Initial Catalog=Hsdb;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
"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_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.72.20)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User ID=C##aucma_scada;Password=aucma;",
"ProviderName": "System.Data.SqlClient" "ProviderName": "System.Data.SqlClient"
}, },
{ {
@ -89,7 +89,7 @@
"DBType": 3, "DBType": 3,
"Enabled": true, "Enabled": true,
"HitRate": 40, "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_mes;Password=aucma;", "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" "ProviderName": "System.Data.SqlClient"
} }

@ -11,6 +11,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Logging; using Microsoft.IdentityModel.Logging;
using NetTaste; using NetTaste;
using RestSharp; using RestSharp;
using StackExchange.Redis;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -57,11 +58,16 @@ namespace Aucma.Core.ProductOffLine.Business
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OffLineBusiness)); private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OffLineBusiness));
private readonly IBaseOrderInfoServices _baseOrderInfoServices = App.ServiceProvider.GetService<IBaseOrderInfoServices>(); private readonly IBaseOrderInfoServices _baseOrderInfoServices = App.ServiceProvider.GetService<IBaseOrderInfoServices>();
private readonly IProductPlanInfoServices? _productPlanInfoServices = App.ServiceProvider.GetService<IProductPlanInfoServices>(); private readonly IPrintBarCodeServices? _printBarCodeServices = App.ServiceProvider.GetService<IPrintBarCodeServices>();
// 成品下线操作条码系统接口 // 成品下线操作条码系统接口
private readonly IProductOffLineServices? _productOffLineServices = App.ServiceProvider.GetService<IProductOffLineServices>(); private readonly IProductOffLineServices? _productOffLineServices = App.ServiceProvider.GetService<IProductOffLineServices>();
// 成品下线操作mes数据 // 成品下线操作mes数据
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>(); 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>();
#endregion #endregion
#region 委托事件 #region 委托事件
@ -94,12 +100,13 @@ namespace Aucma.Core.ProductOffLine.Business
public async void test() public async void test()
{ {
// 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(() =>
{ //{
Thread.Sleep(5000); // Thread.Sleep(5000);
MaterialBarScanEvent("32160030000000910780", "192.168.1.19"); // MaterialBarScanEvent("32160030000000910780", "192.168.1.19");
// MaterialBarScanEvent("33160030000000910780", "192.168.1.20"); // Thread.Sleep(1000);
}); // MaterialBarScanEvent("33160030000000910780", "192.168.1.20");
//});
} }
/// <summary> /// <summary>
/// 处理条码 /// 处理条码
@ -108,8 +115,9 @@ namespace Aucma.Core.ProductOffLine.Business
/// <param name="direction">扫码器方向</param> /// <param name="direction">扫码器方向</param>
public async void MaterialBarScanEvent(string code,string scannerIp)//接收条码数据 public async void MaterialBarScanEvent(string code,string scannerIp)//接收条码数据
{ {
Task.Run(async () => await Task.Run(async () =>
{ {
Console.WriteLine(scannerIp);
int ScannerNo = scannerIp == Appsettings.app("Middleware", "Scanner1", "Ip") ? 1 : 2; // 确定是哪个扫码器 int ScannerNo = scannerIp == Appsettings.app("Middleware", "Scanner1", "Ip") ? 1 : 2; // 确定是哪个扫码器
string materialType = ""; string materialType = "";
bool BackResult = false; bool BackResult = false;
@ -166,43 +174,40 @@ namespace Aucma.Core.ProductOffLine.Business
{ {
try try
{ {
OffLineInfo info11 = MapperTwo(TempOffLineInfo); OffLineInfo info11 = MapperTwo(TempOffLineInfo);
// 添加成品下线表 // 添加成品下线表
CodeBindingRecord bindingRecord1 = await _codeBindingServices.FirstAsync(x=>x.ProductCode == info11.ProductCode);
if (bindingRecord1 == null) return false;
info11.boxCode = bindingRecord1.BoxCode;
await _offLineInfoServices.AddAsync(info11); await _offLineInfoServices.AddAsync(info11);
// 添加订单表 // 修改订单表
////6.更新mes 数据库完成数量和时间(BASE_ORDERINFO,PRODUCT_PLANINFO) 注意:查询的字段可能需要修改,确保数据一致 ////6.更新mes 数据库完成数量和时间(BASE_ORDERINFO) 注意:查询的字段可能需要修改,确保数据一致
////6.1截取订单号去查询更新BASE_ORDERINFO,全放到service处理 ////6.1截取订单号去查询更新BASE_ORDERINFO,全放到service处理
BaseOrderInfo order = await _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo);
List<BaseOrderInfo> orders = await _baseOrderInfoServices.QueryAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo);
//BaseOrderInfo order = orders.FirstOrDefault();
//if (order.CompleteAmount == 0) //if (order.CompleteAmount == 0)
//{ //{
// order.CompleteAmount++;
// order.BeginDate = DateTime.Now; // order.BeginDate = DateTime.Now;
//} //}
// order.CompleteAmount++;
//if (order.CompleteAmount == order.OrderAmount) //if (order.CompleteAmount == order.OrderAmount)
//{ //{
// order.EndDate = DateTime.Now; // order.EndDate = DateTime.Now;
//} //}
//order.UpdatedTime = DateTime.Now; //order.UpdatedTime = DateTime.Now;
//_baseOrderInfoServices.UpdateAsync(order); //await _baseOrderInfoServices.UpdateAsync(order);
////6.2根据订单号去更新PRODUCT_PLANINFO
//List<ProductPlanInfo> productInfos = await _productPlanInfoServices.QueryAsync(x => x.OrderCode == orderCode); #region 更新过点数据
//ProductPlanInfo productInfo = productInfos.FirstOrDefault(); PrintBarCode print = await _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == bindingRecord1.BoxCode);
//if (productInfo.CompleteAmount == 0) MaterialCompletion completion = new MaterialCompletion();
//{ completion.OrderCode = print.OrderCode;
// productInfo.CompleteAmount++; completion.MaterialBarcode = bindingRecord1.BoxCode;
// productInfo.BeginTime = DateTime.Now; completion.MaterialCode = print.MaterialCode;
//} completion.MaterialName = print.MaterialName;
//if (productInfo.CompleteAmount == productInfo.PlanAmount) completion.StationName = "1008" ;
//{ completion.CompleteDate = DateTime.Now;
// productInfo.EndTime = DateTime.Now; await _iMaterialCompletionServices.AddAsync(completion);
//} #endregion
//productInfo.UpdatedTime = DateTime.Now;
//await _productPlanInfoServices.UpdateAsync(productInfo);
return true; return true;
} }
catch (Exception) catch (Exception)

@ -89,8 +89,8 @@ namespace Aucma.Core.ProductOffLine.Models
/// <summary> /// <summary>
/// //扫描时间 /// //扫描时间
/// </summary> /// </summary>
public DateTime ProductScanTime { get; set; } public DateTime ProductScanTime { get; set; }
/// <summary> /// <summary>
/// 刷新标志定时器检测true刷新 /// 刷新标志定时器检测true刷新
/// </summary> /// </summary>
@ -134,5 +134,6 @@ namespace Aucma.Core.ProductOffLine.Models
/// </summary> /// </summary>
/// ///
public string QualityResult { get; set; } public string QualityResult { get; set; }
} }
} }

Loading…
Cancel
Save