|
|
@ -13,7 +13,6 @@ using Admin.Core.Model;
|
|
|
|
using Aucma.Core.HwPLc;
|
|
|
|
using Aucma.Core.HwPLc;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using NetTaste;
|
|
|
|
using NetTaste;
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.SheetMetal.Business;
|
|
|
|
namespace Aucma.Core.SheetMetal.Business;
|
|
|
|
|
|
|
|
|
|
|
@ -22,15 +21,16 @@ namespace Aucma.Core.SheetMetal.Business;
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class SheetMetalPlanTaskHandle
|
|
|
|
public class SheetMetalPlanTaskHandle
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#region 刷新创建计划
|
|
|
|
#region 刷新创建计划
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 刷新创建计划
|
|
|
|
/// 刷新创建计划
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public delegate Task RefreshCretaePlanInfo();
|
|
|
|
public delegate Task RefreshCretaePlanInfo();
|
|
|
|
public static event RefreshCretaePlanInfo RefreshCretaePlanInfoEvent;
|
|
|
|
public static event RefreshCretaePlanInfo RefreshCreatePlanInfoEvent;
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 刷新图标
|
|
|
|
#region 刷新图表
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 刷新创建计划
|
|
|
|
/// 刷新创建计划
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -42,7 +42,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 刷新当前正在执行的计划
|
|
|
|
/// 刷新当前正在执行的计划
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public delegate void RefreshCurrentPlanInfo(ExecutePlanInfo planInfo);
|
|
|
|
public delegate void RefreshCurrentPlanInfo();
|
|
|
|
public static event RefreshCurrentPlanInfo RefreshCurrentPlanInfoEvent;
|
|
|
|
public static event RefreshCurrentPlanInfo RefreshCurrentPlanInfoEvent;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -56,7 +56,6 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected readonly IExecutePlanInfoServices? _executePlanInfoServices;
|
|
|
|
protected readonly IExecutePlanInfoServices? _executePlanInfoServices;
|
|
|
|
protected readonly IRecordSidePanelComplateServices _sidePanelComplateServices;
|
|
|
|
protected readonly IRecordSidePanelComplateServices _sidePanelComplateServices;
|
|
|
|
protected readonly IRecordBackPanelComplateServices _backPanelComplateServices;
|
|
|
|
protected readonly IRecordBackPanelComplateServices _backPanelComplateServices;
|
|
|
@ -81,14 +80,13 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var planInfos = _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals("1001") && d.ExecuteStatus == 1||d.ExecuteStatus==2).Result;
|
|
|
|
var planInfos = _executePlanInfoServices.Query(d => d.ProductLineCode.Equals("1001") && d.ExecuteStatus == 1 || d.ExecuteStatus == 2);
|
|
|
|
|
|
|
|
|
|
|
|
if (planInfos != null)
|
|
|
|
if (planInfos != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (planInfos.Count > 0)
|
|
|
|
if (planInfos.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ExecutePlanInfo planInfo = planInfos.First();
|
|
|
|
ExecutePlanInfo planInfo = planInfos.First();
|
|
|
|
//planInfo.PlanAmount = planInfo.PlanAmount - planInfo.CompleteAmount;
|
|
|
|
|
|
|
|
if (planInfo.PlanType == 1) //联合下发
|
|
|
|
if (planInfo.PlanType == 1) //联合下发
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SendPlanTask(planInfo, obj_sidePanel, obj_backPanel);
|
|
|
|
SendPlanTask(planInfo, obj_sidePanel, obj_backPanel);
|
|
|
@ -113,7 +111,6 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.WriteLine("未获取到需要下发的任务");
|
|
|
|
Console.WriteLine("未获取到需要下发的任务");
|
|
|
|
RefreshExecInfoEvent?.Invoke("未获取到需要下发的任务");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -136,10 +133,10 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
do
|
|
|
|
do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//等待计划执行完成
|
|
|
|
//等待计划执行完成
|
|
|
|
List<RecordSidePanelComplate> sidePanelComplates = _sidePanelComplateServices.QueryAsync(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode).Result;
|
|
|
|
List<RecordSidePanelComplate> sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
|
|
|
|
int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
|
|
|
|
|
|
|
|
List<RecordBackPanelComplate> backPanelComplates = _backPanelComplateServices.QueryAsync(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode).Result;
|
|
|
|
List<RecordBackPanelComplate> backPanelComplates = _backPanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
|
|
|
|
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};围板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};围板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
@ -174,8 +171,13 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
|
|
planInfo.CompleteAmount = sumAmount;
|
|
|
|
planInfo.CompleteAmount = sumAmount;
|
|
|
|
|
|
|
|
|
|
|
|
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
|
|
|
|
bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
|
|
|
|
|
|
|
} while (isComplate);
|
|
|
|
} while (isComplate);
|
|
|
@ -203,14 +205,12 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
if (obj_sidePanel != null)
|
|
|
|
if (obj_sidePanel != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
|
|
|
|
//计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
|
|
|
|
obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode);
|
|
|
|
obj_sidePanel.plc.WriteString("D6030", planInfo.TaskCode);
|
|
|
|
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
|
|
|
|
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
|
|
|
|
obj_sidePanel.plc.WriteString("D6010", "BCD/310NF");
|
|
|
|
obj_sidePanel.plc.WriteString("D6010", "BCD/310NF");
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount);
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount);
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 1);
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待围板设备应答。。。。。。");
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待围板设备应答。。。。。。");
|
|
|
|
RefreshExecInfoEvent?.Invoke("等待围板设备应答");
|
|
|
|
RefreshExecInfoEvent?.Invoke("等待围板设备应答");
|
|
|
|
//下发完成后读取PLC应答,应答后复位应答信号
|
|
|
|
//下发完成后读取PLC应答,应答后复位应答信号
|
|
|
@ -232,8 +232,13 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
|
|
|
|
bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
RefreshCurrentPlanInfoEvent?.Invoke(planInfo);
|
|
|
|
if (result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
ReadDeviceComplate_SidePanel(obj_sidePanel);
|
|
|
|
ReadDeviceComplate_SidePanel(obj_sidePanel);
|
|
|
@ -246,24 +251,22 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
if (obj_backPanel != null)
|
|
|
|
if (obj_backPanel != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
|
|
|
|
//计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
|
|
|
|
obj_backPanel.plc.WriteString("D4000", planInfo.TaskCode);
|
|
|
|
obj_backPanel.plc.WriteString("D6030", planInfo.TaskCode);
|
|
|
|
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
|
|
|
|
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
|
|
|
|
obj_backPanel.plc.WriteString("D4010", "BCD/310NF");
|
|
|
|
obj_backPanel.plc.WriteString("D6010", "BCD/310NF");
|
|
|
|
obj_backPanel.plc.WriteInt32("D4020", planInfo.PlanAmount);
|
|
|
|
obj_backPanel.plc.WriteInt32("D6020", planInfo.PlanAmount);
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 1);
|
|
|
|
obj_backPanel.plc.WriteInt32("D6021", 1);
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
|
|
|
|
RefreshExecInfoEvent?.Invoke("等待背板设备应答......");
|
|
|
|
RefreshExecInfoEvent?.Invoke("等待背板设备应答......");
|
|
|
|
|
|
|
|
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
//循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
|
|
|
|
//循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
|
|
|
|
bool isFlag = true;
|
|
|
|
bool isFlag = true;
|
|
|
|
do
|
|
|
|
do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (obj_backPanel.plc.ReadInt32("D6021") == 2)
|
|
|
|
if (obj_backPanel.plc.ReadInt32("D4021") == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 0);
|
|
|
|
obj_backPanel.plc.WriteInt32("D6021", 0);
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
|
|
|
|
RefreshExecInfoEvent?.Invoke("收到背板板设备应答信号,复位应答地址");
|
|
|
|
RefreshExecInfoEvent?.Invoke("收到背板板设备应答信号,复位应答地址");
|
|
|
|
isFlag = false;
|
|
|
|
isFlag = false;
|
|
|
@ -273,8 +276,13 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
|
|
|
|
bool result= _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
RefreshCurrentPlanInfoEvent?.Invoke(planInfo);
|
|
|
|
if (result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
@ -324,24 +332,29 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到围板设备应答信号,复位应答地址");
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到围板设备应答信号,复位应答地址");
|
|
|
|
RefreshExecInfoEvent?.Invoke("收到围板设备应答信号......");
|
|
|
|
RefreshExecInfoEvent?.Invoke("收到围板设备应答信号......");
|
|
|
|
isFlag = false;
|
|
|
|
isFlag = false;
|
|
|
|
|
|
|
|
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
|
|
|
|
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCurrentPlanInfoEvent?.Invoke(planInfo);
|
|
|
|
|
|
|
|
RefreshCretaePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
} while (isFlag);
|
|
|
|
} while (isFlag);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
|
|
|
|
bool result=_executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RefreshCurrentPlanInfoEvent?.Invoke();
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
ReadDeviceComplate_SidePanel(obj_sidePanel);
|
|
|
|
ReadDeviceComplate_SidePanel(obj_sidePanel);
|
|
|
|
|
|
|
|
if (!isFlag)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -349,7 +362,6 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MessageBox.Show($"围板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
|
|
|
|
MessageBox.Show($"围板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
|
|
|
|
MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
RefreshExecInfoEvent?.Invoke("围板⽣产计划下发异常:{ex.Message}");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -389,14 +401,13 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
int productionBeat = short.Parse(bytesToHexStr(info.Skip(51).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
int productionBeat = short.Parse(bytesToHexStr(info.Skip(51).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
|
|
|
|
Console.WriteLine($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
|
|
|
|
Console.WriteLine($"===>收到围板设备应答信号,复位应答地址");
|
|
|
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
|
|
|
|
RefreshExecInfoEvent?.Invoke($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
|
|
|
|
RefreshExecInfoEvent?.Invoke($"收到围板设备应答信号,复位应答地址");
|
|
|
|
|
|
|
|
//添加完工记录
|
|
|
|
//添加完工记录
|
|
|
|
RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate()
|
|
|
|
RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ProductlineCode = "1001",
|
|
|
|
ProductlineCode = "1001",
|
|
|
|
PlanCode = planCode.Substring(0, 16).Replace("\n","").Trim(),//.Substring(0, 16),
|
|
|
|
PlanCode = planCode.Substring(0, 16),
|
|
|
|
//MaterialCode = string.IsNullOrEmpty(materialCode) ? "" : materialCode,
|
|
|
|
//MaterialCode = string.IsNullOrEmpty(materialCode) ? "" : materialCode,
|
|
|
|
MaterialCode = "BCD/310NF",
|
|
|
|
MaterialCode = "BCD/310NF",
|
|
|
|
CompleteAmount = complateAmount,
|
|
|
|
CompleteAmount = complateAmount,
|
|
|
@ -414,7 +425,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//先查询该计划编号下的前一条完工记录,如果不存在本条记录产量为0
|
|
|
|
//先查询该计划编号下的前一条完工记录,如果不存在本条记录产量为0
|
|
|
|
List<RecordSidePanelComplate> sidePanelComplates = _sidePanelComplateServices.QueryAsync(x => x.ProductlineCode == "1001" && x.PlanCode == planCode.Substring(0, 16)).Result;
|
|
|
|
List<RecordSidePanelComplate> sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planCode.Substring(0, 16));
|
|
|
|
int lastComplateAmount = 0; //前一条完成记录的计划完成数量
|
|
|
|
int lastComplateAmount = 0; //前一条完成记录的计划完成数量
|
|
|
|
int sumComplateAmount = 0; //当前计划总产量
|
|
|
|
int sumComplateAmount = 0; //当前计划总产量
|
|
|
|
if (sidePanelComplates != null)
|
|
|
|
if (sidePanelComplates != null)
|
|
|
@ -434,7 +445,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<ExecutePlanInfo> planInfos = _executePlanInfoServices.QueryAsync(x => x.TaskCode.Equals(planCode.Substring(0, 16)) && x.ExecuteStatus == 2).Result;
|
|
|
|
List<ExecutePlanInfo> planInfos = _executePlanInfoServices.Query(x => x.TaskCode.Equals(planCode.Substring(0, 16)) && x.ExecuteStatus == 2);
|
|
|
|
if (planInfos != null)
|
|
|
|
if (planInfos != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (planInfos.Count > 0)
|
|
|
|
if (planInfos.Count > 0)
|
|
|
@ -447,8 +458,6 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
isFlag = false;
|
|
|
|
isFlag = false;
|
|
|
|
Console.WriteLine($"围板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
Console.WriteLine($"围板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
RefreshExecInfoEvent?.Invoke($"围板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
RefreshExecInfoEvent?.Invoke($"围板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
RefreshCretaePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -460,8 +469,22 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
|
|
_sidePanelComplateServices.InsertSidePanelCimplate(sidePanelComplate);
|
|
|
|
_sidePanelComplateServices.InsertSidePanelCimplate(sidePanelComplate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (complateAmount!=lastComplateAmount)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();
|
|
|
|
|
|
|
|
}
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
} while (isFlag);
|
|
|
|
} while (isFlag);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isFlag)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -493,7 +516,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 1);
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 1);
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
|
|
|
|
RefreshExecInfoEvent?.Invoke($"等待背板设备应答.....");
|
|
|
|
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。");
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
//循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
|
|
|
|
//循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
|
|
|
|
bool isFlag = true;
|
|
|
|
bool isFlag = true;
|
|
|
@ -512,12 +535,25 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
|
|
|
|
bool result= _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
RefreshCurrentPlanInfoEvent?.Invoke(planInfo);
|
|
|
|
if (result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
ReadDeviceComplate_BackPanel(obj_backPanel);
|
|
|
|
ReadDeviceComplate_BackPanel(obj_backPanel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isFlag)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -525,7 +561,6 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MessageBox.Show($"背板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
|
|
|
|
MessageBox.Show($"背板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
|
|
|
|
MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{ex.Message}");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -606,7 +641,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<ExecutePlanInfo> planInfos = _executePlanInfoServices.QueryAsync(x => x.TaskCode == planCode.Substring(0, 16) && x.ExecuteStatus == 2).Result;
|
|
|
|
List<ExecutePlanInfo> planInfos = _executePlanInfoServices.Query(x => x.TaskCode == planCode.Substring(0, 16) && x.ExecuteStatus == 2);
|
|
|
|
if (planInfos != null)
|
|
|
|
if (planInfos != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (planInfos.Count > 0)
|
|
|
|
if (planInfos.Count > 0)
|
|
|
@ -619,9 +654,6 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
isFlag = false;
|
|
|
|
isFlag = false;
|
|
|
|
Console.WriteLine($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
Console.WriteLine($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
RefreshExecInfoEvent?.Invoke($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
RefreshExecInfoEvent?.Invoke($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
RefreshCretaePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -631,17 +663,31 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_backPanelComplateServices.InsertBackPanelCimplate(backPanelComplate);
|
|
|
|
_backPanelComplateServices.InsertBackPanelCimplate(backPanelComplate);
|
|
|
|
|
|
|
|
if (complateAmount != lastComplateAmount)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
} while (isFlag);
|
|
|
|
} while (isFlag);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isFlag)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.WriteLine($"读取背板设备完成数据异常:{e.Message}");
|
|
|
|
Console.WriteLine($"读取背板设备完成数据异常:{e.Message}");
|
|
|
|
RefreshExecInfoEvent?.Invoke($"读取背板设备完成数据异常:{e.Message}");
|
|
|
|
RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{e.Message}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 通过物料编号获取工艺编号
|
|
|
|
/// 通过物料编号获取工艺编号
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|