|
|
|
@ -10,10 +10,13 @@ using System.Windows.Documents;
|
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Admin.Core.Model;
|
|
|
|
|
using Admin.Core.Model.Model_New;
|
|
|
|
|
using Admin.Core.Model.ViewModels;
|
|
|
|
|
using Admin.Core.Service;
|
|
|
|
|
using Aucma.Core.HwPLc;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using NetTaste;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.SheetMetal.Business;
|
|
|
|
@ -61,7 +64,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新当前正在执行的计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
public delegate void RefreshExecInfo(string message);
|
|
|
|
|
public delegate void RefreshExecInfo(string message,string color);
|
|
|
|
|
public static event RefreshExecInfo RefreshExecInfoEvent;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
@ -70,15 +73,19 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
protected readonly IRecordSidePanelComplateServices _sidePanelComplateServices;
|
|
|
|
|
protected readonly IRecordBackPanelComplateServices _backPanelComplateServices;
|
|
|
|
|
protected readonly IProductPlanInfoServices? _productPlanInfoServices;
|
|
|
|
|
protected readonly ISysUserInfoServices? _sysUserInfoServices;
|
|
|
|
|
protected readonly IMaterialCompletionServices? _materialCompletionServices;
|
|
|
|
|
public HwPLc.PlcModel plc1 = null;
|
|
|
|
|
|
|
|
|
|
public SheetMetalPlanTaskHandle()
|
|
|
|
|
{
|
|
|
|
|
_executePlanInfoServices =
|
|
|
|
|
App.ServiceProvider.GetService<IExecutePlanInfoServices>();
|
|
|
|
|
_executePlanInfoServices =App.ServiceProvider.GetService<IExecutePlanInfoServices>();
|
|
|
|
|
_sidePanelComplateServices = App.ServiceProvider.GetService<IRecordSidePanelComplateServices>();
|
|
|
|
|
_backPanelComplateServices = App.ServiceProvider.GetService<IRecordBackPanelComplateServices>();
|
|
|
|
|
_productPlanInfoServices = App.ServiceProvider.GetService<IProductPlanInfoServices>();
|
|
|
|
|
_backPanelComplateServices = App.ServiceProvider.GetService<IRecordBackPanelComplateServices>();
|
|
|
|
|
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
|
|
|
|
|
_materialCompletionServices = App.ServiceProvider.GetService<IMaterialCompletionServices>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -109,6 +116,8 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
if (planInfo == null) continue;
|
|
|
|
|
if (planInfo.PlanType == 3 || planInfo.PlanType == 1)//如果为3或者为1 后板计划单独下发 以前板完成为主
|
|
|
|
|
{
|
|
|
|
|
//获取设置的型号查询对应的型号,下发计划
|
|
|
|
|
|
|
|
|
|
SendPlanTaskToBackPanel(planInfo, obj_backPanel);
|
|
|
|
|
|
|
|
|
|
UpdateBackPanelPlanTaskByComplate(planInfo);
|
|
|
|
@ -183,7 +192,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 1);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>计划【{planInfo.TaskCode}】已下发,等待前板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】已下发,等待前板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】已下发,等待前板设备应答。。。。。。","White");
|
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
|
//循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
|
|
|
|
|
bool isFlag = true;
|
|
|
|
@ -195,7 +204,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
{
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 0);
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>计划【{planInfo.TaskCode}】,收到前板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】,收到前板板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】,收到前板板设备应答信号,复位应答地址", "White");
|
|
|
|
|
startTime=DateTime.Now;
|
|
|
|
|
isFlag = false;
|
|
|
|
|
}
|
|
|
|
@ -255,7 +264,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 1);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>计划【{planInfo.TaskCode}】已下发,等待背板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】以下发,等待背板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】已下发,等待背板设备应答。。。。。。", "White");
|
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
|
//循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
|
|
|
|
|
bool isFlag = true;
|
|
|
|
@ -267,7 +276,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
{
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 0);
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址", "White");
|
|
|
|
|
startTime = DateTime.Now;
|
|
|
|
|
isFlag = false;
|
|
|
|
|
}
|
|
|
|
@ -328,7 +337,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}", "White");
|
|
|
|
|
int sumAmount = 0;
|
|
|
|
|
|
|
|
|
|
if (planInfo.PlanType == 1)
|
|
|
|
@ -339,7 +348,6 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
{
|
|
|
|
|
sumAmount = sumSidePanelAmount;
|
|
|
|
|
planInfo.ExecuteStatus = 3;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (sumSidePanelAmount < sumBackPanelAmount && sumBackPanelAmount == planInfo.PlanAmount)
|
|
|
|
|
{
|
|
|
|
@ -420,7 +428,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}", "Red");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
@ -446,7 +454,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}", "White");
|
|
|
|
|
int sumAmount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -516,7 +524,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}", "Red");
|
|
|
|
|
}
|
|
|
|
|
} while (isComplate);
|
|
|
|
|
|
|
|
|
@ -534,74 +542,6 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 更新计划列表数量
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新计划列表数量
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void UpdateComplatePlan()
|
|
|
|
|
{
|
|
|
|
|
string stationCode = Appsettings.app("StationInfo", "StationCode");
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var planInfoList = _executePlanInfoServices.QueryAsync(d=>d.ProductLineCode.Contains(stationCode)).Result;
|
|
|
|
|
if (planInfoList == null || planInfoList.Count == 0) continue;
|
|
|
|
|
|
|
|
|
|
var list = from d in planInfoList
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
d.OrderCode,
|
|
|
|
|
d.CompleteAmount
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var grouplist =( from d in list
|
|
|
|
|
group d by d.OrderCode into g
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
OrderCode = g.Key,
|
|
|
|
|
CompleteAmount = g.Sum(d=>d.CompleteAmount)
|
|
|
|
|
}).OrderBy(t => t.OrderCode).ToList();
|
|
|
|
|
|
|
|
|
|
var productPlanInfoList= _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains(stationCode)&& d.CompleteAmount!=d.PlanAmount).Result;
|
|
|
|
|
productPlanInfoList.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
var obj= grouplist.SingleOrDefault(d=>d.OrderCode.Equals(t.OrderCode));
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
if (t.PlanAmount == obj.CompleteAmount)
|
|
|
|
|
{
|
|
|
|
|
t.CompleteAmount = obj.CompleteAmount;
|
|
|
|
|
t.EndTime = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
if (t.PlanAmount > obj.CompleteAmount)
|
|
|
|
|
{
|
|
|
|
|
t.CompleteAmount = obj.CompleteAmount;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
t.CompleteAmount = t.PlanAmount;
|
|
|
|
|
}
|
|
|
|
|
if (obj.CompleteAmount!=0)
|
|
|
|
|
{
|
|
|
|
|
_productPlanInfoServices.UpdateAsync(t);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 下发单个计划逻辑
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -678,7 +618,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};前板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}", "White");
|
|
|
|
|
int sumAmount = 0;
|
|
|
|
|
|
|
|
|
|
if (planInfo.PlanType == 1)
|
|
|
|
@ -724,7 +664,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"计划任务信息更新异常:{ex.Message}", "Red");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -751,7 +691,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 1);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待前板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke("等待前板设备应答......");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke("等待前板设备应答......","Red");
|
|
|
|
|
//下发完成后读取PLC应答,应答后复位应答信号
|
|
|
|
|
|
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
@ -764,7 +704,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
{
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 0);
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到前板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke("收到前板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke("收到前板设备应答信号,复位应答地址","White");
|
|
|
|
|
isFlag = false;
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
@ -803,7 +743,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 1);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。", "White");
|
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
|
//循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
|
|
|
|
|
bool isFlag = true;
|
|
|
|
@ -813,7 +753,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
{
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 0);
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke("收到背板板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke("收到背板板设备应答信号,复位应答地址", "White");
|
|
|
|
|
isFlag = false;
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
@ -870,7 +810,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 1);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待前板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke("等待前板设备应答......");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke("等待前板设备应答......", "White");
|
|
|
|
|
//下发完成后读取PLC应答,应答后复位应答信号
|
|
|
|
|
|
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
@ -882,7 +822,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
{
|
|
|
|
|
obj_sidePanel.plc.WriteInt32("D6021", 0);
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到前板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke("收到前板设备应答信号......");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke("收到前板设备应答信号......", "White");
|
|
|
|
|
isFlag = false;
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
@ -955,7 +895,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
int productionBeat = short.Parse(bytesToHexStr(info.Skip(51).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"前板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"前板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"前板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}", "White");
|
|
|
|
|
|
|
|
|
|
//添加完工记录
|
|
|
|
|
RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate()
|
|
|
|
@ -1011,7 +951,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
{
|
|
|
|
|
isFlag = false;
|
|
|
|
|
Console.WriteLine($"前板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"前板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"前板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}", "White");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1041,7 +981,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"读取前板设备完成数据异常:{e.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"读取前板设备完成数据异常:{e.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"读取前板设备完成数据异常:{e.Message}", "Red");
|
|
|
|
|
}
|
|
|
|
|
} while (isFlag);
|
|
|
|
|
|
|
|
|
@ -1078,7 +1018,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 1);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"等待背板设备应答。。。。。。", "White");
|
|
|
|
|
#region PLC反馈信号逻辑处理
|
|
|
|
|
//循环读取PLC应答信号,PLC应答后复位应答信号、更新计划状态为执行中
|
|
|
|
|
bool isFlag = true;
|
|
|
|
@ -1089,7 +1029,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
{
|
|
|
|
|
obj_backPanel.plc.WriteInt32("D4021", 0);
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"收到背板板设备应答信号,复位应答地址", "White");
|
|
|
|
|
isFlag = false;
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
@ -1161,7 +1101,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
int productionBeat = short.Parse(bytesToHexStr(info.Skip(51).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"背板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}", "White");
|
|
|
|
|
//添加完工记录
|
|
|
|
|
RecordBackPanelComplate backPanelComplate = new RecordBackPanelComplate()
|
|
|
|
|
{
|
|
|
|
@ -1215,7 +1155,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
{
|
|
|
|
|
isFlag = false;
|
|
|
|
|
Console.WriteLine($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"背板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}", "White");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1244,7 +1184,7 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"读取背板设备完成数据异常:{e.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{e.Message}");
|
|
|
|
|
RefreshExecInfoEvent?.Invoke($"背板⽣产计划下发异常:{e.Message}", "Red");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1271,9 +1211,92 @@ public class SheetMetalPlanTaskHandle
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return returnStr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 更新计划列表数量
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新计划列表数量
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void UpdateComplatePlan()
|
|
|
|
|
{
|
|
|
|
|
string stationCode = Appsettings.app("StationInfo", "StationCode");
|
|
|
|
|
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
|
|
|
|
|
List<ProductPlanInfo> pPlanInfoList = new List<ProductPlanInfo>();
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var planInfoList = _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains(stationCode)).Result;
|
|
|
|
|
if (planInfoList == null || planInfoList.Count == 0) continue;
|
|
|
|
|
|
|
|
|
|
var list = from d in planInfoList
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
d.OrderCode,
|
|
|
|
|
d.CompleteAmount
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var grouplist = (from d in list
|
|
|
|
|
group d by d.OrderCode into g
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
OrderCode = g.Key,
|
|
|
|
|
CompleteAmount = g.Sum(d => d.CompleteAmount)
|
|
|
|
|
}).OrderBy(t => t.OrderCode).ToList();
|
|
|
|
|
|
|
|
|
|
var productPlanInfoList = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains(stationCode) && d.CompleteAmount != d.PlanAmount).Result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
productPlanInfoList.ForEach(async t =>
|
|
|
|
|
{
|
|
|
|
|
var materialCompletionList = _materialCompletionServices.QueryAsync(d => d.ProductLineCode.Contains(productLineCode) && d.StationName.Equals(stationCode)).Result;
|
|
|
|
|
var obj = grouplist.FirstOrDefault(d => d.OrderCode.Equals(t.OrderCode));
|
|
|
|
|
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
ProductPlanInfo productPlanInfo = new ProductPlanInfo();
|
|
|
|
|
|
|
|
|
|
if (obj.CompleteAmount == 1 && t.CompleteAmount == 0)
|
|
|
|
|
{
|
|
|
|
|
productPlanInfo.EndTime = DateTime.Now;
|
|
|
|
|
_sysUserInfoServices.UpdateSapPlan(obj.OrderCode);//第一次执行更新日历表
|
|
|
|
|
}
|
|
|
|
|
if (t.PlanAmount == obj.CompleteAmount)
|
|
|
|
|
{
|
|
|
|
|
productPlanInfo.CompleteAmount = obj.CompleteAmount;
|
|
|
|
|
productPlanInfo.EndTime = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
if (t.PlanAmount > obj.CompleteAmount)
|
|
|
|
|
{
|
|
|
|
|
productPlanInfo.CompleteAmount = obj.CompleteAmount;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
productPlanInfo.CompleteAmount = t.PlanAmount;
|
|
|
|
|
}
|
|
|
|
|
int completeNum = materialCompletionList.Count();//过点完成数量
|
|
|
|
|
if ((obj.CompleteAmount - completeNum) > 0)
|
|
|
|
|
{
|
|
|
|
|
MaterialCompletion materialCompletion = new MaterialCompletion();
|
|
|
|
|
materialCompletion.OrderCode = t.OrderCode;
|
|
|
|
|
materialCompletion.ProductLineCode = productLineCode;
|
|
|
|
|
materialCompletion.MaterialCode = t.MaterialCode;
|
|
|
|
|
materialCompletion.MaterialName = t.MaterialName;
|
|
|
|
|
materialCompletion.StationName = stationCode;
|
|
|
|
|
materialCompletion.CompleteDate = DateTime.Now;
|
|
|
|
|
materialCompletion.planCode = t.PlanCode;
|
|
|
|
|
await _materialCompletionServices.AddAsync(materialCompletion);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (pPlanInfoList.Count != 0 && pPlanInfoList != null)
|
|
|
|
|
{
|
|
|
|
|
_productPlanInfoServices.UpdateAsync(pPlanInfoList);
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|