|
|
|
@ -10,9 +10,12 @@ using System.Windows.Documents;
|
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Admin.Core.Model;
|
|
|
|
|
using Admin.Core.Model.ViewModels;
|
|
|
|
|
using Admin.Core.Service;
|
|
|
|
|
using Aucma.Core.HwPLc;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using NetTaste;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.SheetMetal.Business;
|
|
|
|
|
|
|
|
|
@ -69,6 +72,401 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
_backPanelComplateServices = App.ServiceProvider.GetService<IRecordBackPanelComplateServices>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 下发多个计划同步执行
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化下发生产计划,获取已拆分的计划进行下发——后板任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void InitSendBackPanelPlan()
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
var planInfoList = _executePlanInfoServices.QuerySheetMetalSendPlanData("1001").Where(d => d.PlanAmount > d.BackPanelAmount).ToList();
|
|
|
|
|
planInfoList = planInfoList.Where(d => d.ExecuteStatus == 1 || d.ExecuteStatus == 2).ToList();
|
|
|
|
|
if (planInfoList == null|| planInfoList.Count==0) continue;
|
|
|
|
|
var planInfos = planInfoList.Where(d => d.PlanType == 3 || d.PlanType == 1).ToList();
|
|
|
|
|
if (planInfos!=null)
|
|
|
|
|
{
|
|
|
|
|
if (planInfos.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
SheetMetaSendPlanInfoView planInfo = planInfos.FirstOrDefault(d => d.BackPanelAmount != d.PlanAmount);
|
|
|
|
|
if (planInfo == null) continue;
|
|
|
|
|
if (planInfo.PlanType == 3||planInfo.PlanType == 1)//如果为3或者为1 后板计划单独下发 以前板完成为主
|
|
|
|
|
{
|
|
|
|
|
SendPlanTaskToBackPanel(planInfo, obj_backPanel);
|
|
|
|
|
|
|
|
|
|
UpdateBackPanelPlanTaskByComplate(planInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("未获取到需要下发的任务");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化下发生产计划,获取已拆分的计划进行下发——前板任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void InitSendSidePanelPlan()
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
var planInfoList = _executePlanInfoServices.QuerySheetMetalSendPlanData("1001").Where(d=>d.PlanAmount > d.SidePanelAmount).ToList();
|
|
|
|
|
planInfoList = planInfoList.Where(d => d.ExecuteStatus == 1 || d.ExecuteStatus == 2).ToList();
|
|
|
|
|
if (planInfoList == null || planInfoList.Count == 0) continue;
|
|
|
|
|
var planInfos = planInfoList.Where(d => d.PlanType == 2 || d.PlanType == 1).ToList();
|
|
|
|
|
if (planInfos != null)
|
|
|
|
|
{
|
|
|
|
|
if (planInfos.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
SheetMetaSendPlanInfoView planInfo = planInfos.FirstOrDefault(d => d.SidePanelAmount != d.PlanAmount);
|
|
|
|
|
if (planInfo == null) continue;
|
|
|
|
|
if (planInfo.PlanType == 2 || planInfo.PlanType == 1)//如果为2或者为1 前板板计划单独下发 以前板完成为主
|
|
|
|
|
{
|
|
|
|
|
SendPlanTaskToSidPanel(planInfo, obj_sidePanel);
|
|
|
|
|
|
|
|
|
|
UpdateSidPanelPlanTaskByComplate(planInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("未获取到需要下发的任务");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下发前板生产计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="planInfo"></param>
|
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
|
public void SendPlanTaskToSidPanel(SheetMetaSendPlanInfoView planInfo, PlcModel obj_sidePanel)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
if (obj_sidePanel != null)
|
|
|
|
|
{
|
|
|
|
|
//计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
|
|
|
|
|
obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode);
|
|
|
|
|
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
|
|
|
|
|
obj_sidePanel.plc.WriteString("D6010", planInfo.MaterialSpecificatons);
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount);
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 1);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。");
|
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
|
//循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
|
|
|
|
|
bool isFlag = true;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (obj_sidePanel.plc.ReadInt32("D6021") == 2)
|
|
|
|
|
{
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 0);
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址");
|
|
|
|
|
isFlag = false;
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
|
} while (isFlag);
|
|
|
|
|
|
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
|
bool result = _executePlanInfoServices.UpdateSheetMetalExecutePlanInfo(planInfo.ObjId, planInfo.ExecuteStatus).Result;
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
|
ReadDeviceComplate_SidePanel(obj_sidePanel);
|
|
|
|
|
|
|
|
|
|
if (!isFlag)
|
|
|
|
|
{
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"背板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
|
|
|
|
|
MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下发背板生产计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="planInfo"></param>
|
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
|
public void SendPlanTaskToBackPanel(SheetMetaSendPlanInfoView planInfo, PlcModel obj_backPanel)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
if (obj_backPanel != null)
|
|
|
|
|
{
|
|
|
|
|
//计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
|
|
|
|
|
obj_backPanel.plc.WriteString("D4000", planInfo.TaskCode);
|
|
|
|
|
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
|
|
|
|
|
obj_backPanel.plc.WriteString("D4010", planInfo.MaterialSpecificatons);
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4020", planInfo.PlanAmount);
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 1);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。");
|
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
|
//循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
|
|
|
|
|
bool isFlag = true;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (obj_backPanel.plc.ReadInt32("D4021") == 2)
|
|
|
|
|
{
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 0);
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址");
|
|
|
|
|
isFlag = false;
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
|
} while (isFlag);
|
|
|
|
|
|
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
|
bool result = _executePlanInfoServices.UpdateSheetMetalExecutePlanInfo(planInfo.ObjId, planInfo.ExecuteStatus).Result;
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
|
ReadDeviceComplate_BackPanel(obj_backPanel);
|
|
|
|
|
|
|
|
|
|
if (!isFlag)
|
|
|
|
|
{
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"背板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
|
|
|
|
|
MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据后板完成记录更新生产计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="planInfo"></param>
|
|
|
|
|
private void UpdateBackPanelPlanTaskByComplate(SheetMetaSendPlanInfoView planInfo)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lock (string.Empty)
|
|
|
|
|
{
|
|
|
|
|
bool isComplate = true;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
//等待计划执行完成
|
|
|
|
|
List<RecordSidePanelComplate> sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
|
|
|
|
|
int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
|
|
|
|
|
|
List<RecordBackPanelComplate> backPanelComplates = _backPanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
|
|
|
|
|
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
|
int sumAmount = 0;
|
|
|
|
|
|
|
|
|
|
if (planInfo.PlanType == 1)
|
|
|
|
|
{
|
|
|
|
|
if(planInfo.PlanAmount == sumBackPanelAmount)
|
|
|
|
|
{
|
|
|
|
|
if (sumSidePanelAmount<= sumBackPanelAmount)
|
|
|
|
|
{
|
|
|
|
|
sumAmount = sumSidePanelAmount;
|
|
|
|
|
isComplate = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sumAmount = planInfo.PlanAmount;
|
|
|
|
|
isComplate = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sumAmount = sumSidePanelAmount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (planInfo.PlanType == 3)
|
|
|
|
|
{
|
|
|
|
|
sumAmount = sumBackPanelAmount;
|
|
|
|
|
if (planInfo.PlanAmount - sumAmount == 0)
|
|
|
|
|
{
|
|
|
|
|
planInfo.ExecuteStatus = 3;
|
|
|
|
|
isComplate = false;
|
|
|
|
|
}
|
|
|
|
|
planInfo.CompleteAmount = sumAmount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var obj = _executePlanInfoServices.FirstAsync(d => d.ObjId == planInfo.ObjId).Result;
|
|
|
|
|
obj.ExecuteStatus = planInfo.ExecuteStatus;
|
|
|
|
|
if (obj.PlanType==1)
|
|
|
|
|
{
|
|
|
|
|
obj.CompleteAmount = sumAmount;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
obj.CompleteAmount = sumAmount;
|
|
|
|
|
}
|
|
|
|
|
bool result = _executePlanInfoServices.UpdateExecutePlanInfo(obj).Result;
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
// RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
|
|
|
|
|
} while (isComplate);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据前板完成记录更新生产计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="planInfo"></param>
|
|
|
|
|
private void UpdateSidPanelPlanTaskByComplate(SheetMetaSendPlanInfoView planInfo)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
lock (string.Empty)
|
|
|
|
|
{
|
|
|
|
|
bool isComplate = true;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
//等待计划执行完成
|
|
|
|
|
List<RecordSidePanelComplate> sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
|
|
|
|
|
int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
|
|
|
|
|
|
List<RecordBackPanelComplate> backPanelComplates = _backPanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
|
|
|
|
|
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};围板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};围板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
|
int sumAmount = 0;
|
|
|
|
|
|
|
|
|
|
if (planInfo.PlanType == 1)
|
|
|
|
|
{
|
|
|
|
|
if (sumSidePanelAmount >= sumBackPanelAmount)
|
|
|
|
|
{
|
|
|
|
|
sumAmount = sumBackPanelAmount;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sumAmount = sumSidePanelAmount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (planInfo.PlanType == 2)
|
|
|
|
|
{
|
|
|
|
|
sumAmount = sumSidePanelAmount;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sumAmount = sumBackPanelAmount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (planInfo.PlanAmount - sumAmount == 0)
|
|
|
|
|
{
|
|
|
|
|
planInfo.ExecuteStatus = 3;
|
|
|
|
|
isComplate = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
planInfo.CompleteAmount = sumAmount;
|
|
|
|
|
|
|
|
|
|
var obj = _executePlanInfoServices.FirstAsync(d => d.ObjId == planInfo.ObjId).Result;
|
|
|
|
|
obj.CompleteAmount = planInfo.CompleteAmount;
|
|
|
|
|
obj.ExecuteStatus = planInfo.ExecuteStatus;
|
|
|
|
|
bool result = _executePlanInfoServices.UpdateExecutePlanInfo(obj).Result;
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
|
|
|
|
|
} while (isComplate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 下发单个计划逻辑
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化下发生产计划,获取已拆分的计划进行下发
|
|
|
|
|
/// </summary>
|
|
|
|
@ -200,6 +598,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//前板
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
if (obj_sidePanel != null)
|
|
|
|
@ -207,7 +606,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
//计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
|
|
|
|
|
obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode);
|
|
|
|
|
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
|
|
|
|
|
obj_sidePanel.plc.WriteString("D6010", "BCD/310NF");
|
|
|
|
|
obj_sidePanel.plc.WriteString("D6010", planInfo.MaterialSpecificatons);
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount);
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 1);
|
|
|
|
|
|
|
|
|
@ -220,6 +619,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
bool isFlag = true;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
//开始做计划的时候给我
|
|
|
|
|
if (obj_sidePanel.plc.ReadInt32("D6021") == 2)
|
|
|
|
|
{
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 0);
|
|
|
|
@ -250,7 +650,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//背板
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
if (obj_backPanel != null)
|
|
|
|
@ -281,7 +681,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
|
bool result= _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
|
bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//更新前端展示图表
|
|
|
|
@ -308,6 +708,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下发围板生产计划
|
|
|
|
|
/// </summary>
|
|
|
|
@ -324,7 +725,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
//计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
|
|
|
|
|
obj_sidePanel.plc.WriteString("D6000", planInfo.TaskCode);
|
|
|
|
|
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
|
|
|
|
|
obj_sidePanel.plc.WriteString("D6010", "BCD/310NF");
|
|
|
|
|
obj_sidePanel.plc.WriteString("D6010", planInfo.MaterialSpecificatons);
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount);
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 1);
|
|
|
|
|
|
|
|
|
@ -349,7 +750,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
|
bool result=_executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
|
bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//更新前端展示图表
|
|
|
|
@ -357,7 +758,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
RefreshCurrentPlanInfoEvent?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
|
ReadDeviceComplate_SidePanel(obj_sidePanel);
|
|
|
|
@ -414,14 +815,14 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//添加完工记录
|
|
|
|
|
RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate()
|
|
|
|
|
{
|
|
|
|
|
ProductlineCode = "1001",
|
|
|
|
|
PlanCode = planCode.Substring(0, 16),
|
|
|
|
|
//MaterialCode = string.IsNullOrEmpty(materialCode) ? "" : materialCode,
|
|
|
|
|
MaterialCode = "BCD/310NF",
|
|
|
|
|
MaterialCode = materialCode.Replace("\0", "").Trim(),//"BCD/310NF",
|
|
|
|
|
CompleteAmount = complateAmount,
|
|
|
|
|
OffLineAmount = offLineAmount,
|
|
|
|
|
DeviceStatus = deviceStatus,
|
|
|
|
@ -481,7 +882,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
_sidePanelComplateServices.InsertSidePanelCimplate(sidePanelComplate);
|
|
|
|
|
|
|
|
|
|
if (complateAmount!=lastComplateAmount)
|
|
|
|
|
if (complateAmount != lastComplateAmount)
|
|
|
|
|
{
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
@ -523,7 +924,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
//计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
|
|
|
|
|
obj_backPanel.plc.WriteString("D4000", planInfo.TaskCode);
|
|
|
|
|
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
|
|
|
|
|
obj_backPanel.plc.WriteString("D4010", "BCD/310NF");
|
|
|
|
|
obj_backPanel.plc.WriteString("D4010", planInfo.MaterialSpecificatons);
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4020", planInfo.PlanAmount);
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 1);
|
|
|
|
|
|
|
|
|
@ -547,14 +948,14 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
//更新计划状态为2执行中
|
|
|
|
|
planInfo.ExecuteStatus = 2;
|
|
|
|
|
bool result= _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
|
bool result = _executePlanInfoServices.UpdateExecutePlanInfo(planInfo).Result;
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//更新前端展示图表
|
|
|
|
|
RefreshCreatePlanInfoEvent?.Invoke();//更新界面
|
|
|
|
|
RefreshChatEvent?.Invoke();//刷新图表
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//读取设备进度,完成后再次下发新任务
|
|
|
|
@ -598,9 +999,9 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//计划编号
|
|
|
|
|
string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray());
|
|
|
|
|
string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\0", "").Trim();
|
|
|
|
|
//物料编号
|
|
|
|
|
string materialCode = Encoding.ASCII.GetString(info.Skip(20).Take(20).ToArray());
|
|
|
|
|
string materialCode = Encoding.ASCII.GetString(info.Skip(20).Take(20).ToArray()).Replace("\0", "").Trim();
|
|
|
|
|
//完成数量
|
|
|
|
|
int complateAmount = short.Parse(bytesToHexStr(info.Skip(40).Take(1).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
//下线数量
|
|
|
|
@ -616,9 +1017,9 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
RecordBackPanelComplate backPanelComplate = new RecordBackPanelComplate()
|
|
|
|
|
{
|
|
|
|
|
ProductlineCode = "1001",
|
|
|
|
|
PlanCode = planCode.Substring(0, 16),
|
|
|
|
|
PlanCode = planCode.Substring(0, 16).Replace("\0", "").Trim(),
|
|
|
|
|
//MaterialCode = string.IsNullOrEmpty(materialCode) ? "" : materialCode,
|
|
|
|
|
MaterialCode = "BCD/310NF",
|
|
|
|
|
MaterialCode = materialCode.Replace("\0", "").Trim(),//"BCD/310NF",
|
|
|
|
|
CompleteAmount = complateAmount,
|
|
|
|
|
OffLineAmount = offLineAmount,
|
|
|
|
|
DeviceStatus = deviceStatus,
|
|
|
|
@ -721,5 +1122,6 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return returnStr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|