|
|
|
@ -18,6 +18,10 @@ using Aucma.Core.PLc;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Consul;
|
|
|
|
|
using NetTaste;
|
|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Admin.Core.Model.Model_New;
|
|
|
|
|
using Admin.Core.Model;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 成品分舵入库首页信息
|
|
|
|
@ -28,12 +32,16 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
public partial class IndexPageViewModel : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly IBaseOrderInfoServices? _baseOrderInfoServices;
|
|
|
|
|
private readonly IProductPlanInfoServices? _productPlanInfoServices;
|
|
|
|
|
|
|
|
|
|
public IndexPageViewModel()
|
|
|
|
|
{
|
|
|
|
|
_baseOrderInfoServices = App.ServiceProvider.GetService<IBaseOrderInfoServices>();
|
|
|
|
|
_productPlanInfoServices = App.ServiceProvider.GetService<IProductPlanInfoServices>();
|
|
|
|
|
MvCodeHelper.ReceiveCodeEvent += ReceiveCode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// test();
|
|
|
|
|
//List<MutiDBOperate> listdatabase = Appsettings.app<MutiDBOperate>("DBS")
|
|
|
|
|
// .Where(i => i.Enabled).ToList();
|
|
|
|
@ -210,7 +218,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="code"></param>
|
|
|
|
|
/// <param name="direction">扫码器方向,1左边分A库,2右边分B库</param>
|
|
|
|
|
private void ReceiveCode(string code, int scannerNo)
|
|
|
|
|
private async void ReceiveCode(string code, int scannerNo)
|
|
|
|
|
{
|
|
|
|
|
//1.扫描的SN条码去条码系统查询GET_BARCODE_DATA
|
|
|
|
|
|
|
|
|
@ -233,14 +241,44 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
|
|
|
|
|
//3.调条码系统保存接口入库SaveBarcodeInfo
|
|
|
|
|
|
|
|
|
|
//4.更新mes数据库完成数量和时间(BASE_ORDERINFO,PRODUCT_PLANINFO)
|
|
|
|
|
|
|
|
|
|
//4.更新mes数据库完成数量和时间(BASE_ORDERINFO,PRODUCT_PLANINFO) 注意:查询的字段可能需要修改,确保数据一致
|
|
|
|
|
|
|
|
|
|
//4.1截取订单号去查询更新BASE_ORDERINFO
|
|
|
|
|
string orderCode = "11215484";
|
|
|
|
|
BaseOrderInfo order = _baseOrderInfoServices.Query(x => x.OrderCode == orderCode).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);
|
|
|
|
|
//4.2根据订单号去更新PRODUCT_PLANINFO
|
|
|
|
|
ProductPlanInfo productIndo =_productPlanInfoServices.Query(x => x.OrderCode == orderCode).FirstOrDefault();
|
|
|
|
|
if (productIndo.CompleteAmount == 0)
|
|
|
|
|
{
|
|
|
|
|
productIndo.CompleteAmount++;
|
|
|
|
|
productIndo.BeginTime = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
if(productIndo.CompleteAmount==productIndo.PlanAmount)
|
|
|
|
|
{
|
|
|
|
|
productIndo.EndTime = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
productIndo.UpdatedTime = DateTime.Now;
|
|
|
|
|
_productPlanInfoServices.UpdateAsync(productIndo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//5.分垛A,B库逻辑(先左边读到的条码分A库,右边读到的B库==>预留分库逻辑)
|
|
|
|
|
|
|
|
|
|
//6.下发plc信号
|
|
|
|
|
SendPlcPass(scannerNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region plc交互
|
|
|
|
@ -260,12 +298,23 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
{
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
// 写入入库方向,两条道plc地址不同
|
|
|
|
|
obj.plc.WriteInt32("D100", scannerNo);
|
|
|
|
|
// 往plc写入放行信号
|
|
|
|
|
obj.plc.WriteInt32("D102", 1);
|
|
|
|
|
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();
|
|
|
|
|
waitPlcSignal(scannerNo);
|
|
|
|
|
// semaphore.Wait();
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
@ -289,7 +338,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
/// 读取plc放行反馈
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
private void waitPlcSignal()
|
|
|
|
|
private void waitPlcSignal(int scannerNo)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -299,34 +348,43 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
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连接失败,请检查plc连接");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
log.Info("获取plc连接对象信息为空");
|
|
|
|
|
log.Info("成品下线plc连接失败");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -375,7 +433,8 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
/// </summary>
|
|
|
|
|
void test()
|
|
|
|
|
{
|
|
|
|
|
string connectionString = "Data Source=(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.50)(PORT = 1521)))(CONNECT_DATA=(SERVICE_NAME=tmdata)));User ID=ILS_SORT;Password=Aucma_2019;";
|
|
|
|
|
// string aa = BaseDBConfig.MutiInitConn().Item1[2].Connection;
|
|
|
|
|
string connectionString = "Data Source=(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.50)(PORT = 1521)))(CONNECT_DATA=(SERVICE_NAME=tmdata)));User ID=ILS_SORT;Password=Aucma_2019;";
|
|
|
|
|
// string connectionString = "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;";
|
|
|
|
|
// string functionQuery = "SELECT COUNT(*) from CODE_BINDING";
|
|
|
|
|
string sql = "SELECT ILS_TMPRD.ILS_SORT_BARCODE_PKG.GET_BARCODE_DATA('16160030000000910779') FROM DUAL";
|
|
|
|
|