钣金添加多任务计划

dev
liulb@mesnac.com 1 year ago
parent 512d32c576
commit 66ba2ce2a8

@ -2346,6 +2346,11 @@
计划任务执行编号——钣金任务
</summary>
</member>
<member name="P:Admin.Core.Model.ExecutePlanInfo.MaterialSpecificatons">
<summary>
产品简码
</summary>
</member>
<member name="T:Admin.Core.Model.OffLineInfo">
<summary>
条码下线信息记录
@ -5126,6 +5131,136 @@
后板数量
</summary>
</member>
<member name="T:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView">
<summary>
钣金计划
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.ObjID">
<summary>
下发计划的ID
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.PlanCode">
<summary>
计划编码
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.OrderCode">
<summary>
订单编码
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.MaterialCode">
<summary>
物料编码
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.MaterialName">
<summary>
物料名称
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.ProductLineCode">
<summary>
产线工位
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.PlanAmount">
<summary>
计划数量
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.CompleteAmount">
<summary>
完成数量
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.BeginTime">
<summary>
开始时间
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.EndTime">
<summary>
结束时间
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaPlanInfoView.MaterialSpecificatons">
<summary>
产品型号
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.ObjId">
<summary>
主键
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.ExecutePlanCode">
<summary>
计划Code
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.OrderCode">
<summary>
订单Code
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.MaterialCode">
<summary>
物料编码
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.MaterialName">
<summary>
物料名称
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.MaterialSpecificatons">
<summary>
物料名称
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.ExecuteStatus">
<summary>
执行状态
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.PlanType">
<summary>
执行类型
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.PlanAmount">
<summary>
计划数量
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.CompleteAmount">
<summary>
计划数量
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.TaskCode">
<summary>
任务编码
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.SidePanelAmount">
<summary>
前板数量
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.BackPanelAmount">
<summary>
后板数量
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.SheetMetaSendPlanInfoView.ExecuteOrder">
<summary>
执行顺序
</summary>
</member>
<member name="P:Admin.Core.Model.ViewModels.StationHourAmountView.RowNum">
<summary>
产线编码

@ -19,5 +19,9 @@ namespace Admin.Core.IRepository
List<dynamic> GetStationSheetMetalStats(string stationCode);
List<SheetMetalDataView> QuerySheetMetalData(string stationCode);
List<SheetMetaPlanInfoView> QuerySheetMetalPlanData(string stationCode);
List<SheetMetaSendPlanInfoView> QuerySheetMetalSendPlanData(string stationCode);
}
}

@ -118,6 +118,25 @@ namespace Admin.Core.IService
/// <param name="stationCode"></param>
/// <returns></returns>
List<SheetMetalDataView> QuerySheetMetalData(string stationCode);
/// <summary>
/// 获取钣金当前工位计划
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
List<SheetMetaPlanInfoView> QuerySheetMetalPlanData(string stationCode);
/// <summary>
/// 查询钣金计划执行任务
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
List<SheetMetaSendPlanInfoView> QuerySheetMetalSendPlanData(string stationCode);
/// <summary>
/// 修改钣金执行计划
/// </summary>
/// <param name="executePlanInfo"></param>
/// <returns></returns>
Task<bool> UpdateSheetMetalExecutePlanInfo(int execPanId,int status);
#endregion
}
}

@ -118,5 +118,12 @@ namespace Admin.Core.Model
/// </summary>
[SugarColumn(ColumnName = "TASK_CODE")]
public string TaskCode { get; set; }
/// <summary>
/// 产品简码
/// </summary>
[SugarColumn(ColumnName = "MATERIAL_SPECIFICATIONS")]
public string MaterialSpecificatons { get; set; }
}
}

@ -0,0 +1,71 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Model.ViewModels
{
/// <summary>
/// 钣金计划
/// </summary>
public class SheetMetaPlanInfoView
{
/// <summary>
/// 下发计划的ID
/// </summary>
[SugarColumn(ColumnName = "OBJ_ID")]
public int ObjID { get; set; }
/// <summary>
/// 计划编码
/// </summary>
[SugarColumn(ColumnName = "PLAN_CODE")]
public string PlanCode { get; set; }
/// <summary>
/// 订单编码
/// </summary>
[SugarColumn(ColumnName = "ORDER_CODE")]
public string OrderCode { get; set; }
/// <summary>
/// 物料编码
/// </summary>
[SugarColumn(ColumnName = "MATERIAL_CODE")]
public string MaterialCode { get; set; }
/// <summary>
/// 物料名称
/// </summary>
[SugarColumn(ColumnName = "MATERIAL_NAME")]
public string MaterialName { get; set; }
/// <summary>
/// 产线工位
/// </summary>
[SugarColumn(ColumnName = "PRODUCTLINE_CODE")]
public string ProductLineCode { get; set; }
/// <summary>
/// 计划数量
/// </summary>
[SugarColumn(ColumnName = "PLAN_AMOUNT")]
public int PlanAmount { get; set; }
/// <summary>
/// 完成数量
/// </summary>
[SugarColumn(ColumnName = "COMPLETE_AMOUNT")]
public int CompleteAmount { get; set; }
/// <summary>
/// 开始时间
/// </summary>
[SugarColumn(ColumnName = "BEGIN_TIME")]
public DateTime BeginTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
[SugarColumn(ColumnName = "END_TIME")]
public DateTime EndTime { get; set; }
/// <summary>
/// 产品型号
/// </summary>
[SugarColumn(ColumnName = "MATERIAL_SPECIFICATIONS")]
public string MaterialSpecificatons { get; set; }
}
}

@ -0,0 +1,85 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Model.ViewModels
{
public class SheetMetaSendPlanInfoView
{
/// <summary>
/// 主键
/// </summary>
[SugarColumn(ColumnName = "OBJ_ID")]
public int ObjId { get; set; }
/// <summary>
/// 计划Code
/// </summary>
[SugarColumn(ColumnName = "EXECUTE_PLANCODE")]
public string ExecutePlanCode { get; set; }
/// <summary>
/// 订单Code
/// </summary>
[SugarColumn(ColumnName = "ORDER_CODE")]
public string OrderCode { get; set; }
/// <summary>
/// 物料编码
/// </summary>
[SugarColumn(ColumnName = "MATERIAL_CODE")]
public string MaterialCode { get; set; }
/// <summary>
/// 物料名称
/// </summary>
[SugarColumn(ColumnName = "MATERIAL_NAME")]
public string MaterialName { get; set; }
/// <summary>
/// 物料名称
/// </summary>
[SugarColumn(ColumnName = "MATERIAL_SPECIFICATIONS")]
public string MaterialSpecificatons { get; set; }
/// <summary>
/// 执行状态
/// </summary>
[SugarColumn(ColumnName = "EXECUTE_STATUS")]
public int ExecuteStatus { get; set; }
/// <summary>
/// 执行类型
/// </summary>
[SugarColumn(ColumnName = "PLAN_TYPE")]
public int PlanType { get; set; }
/// <summary>
/// 计划数量
/// </summary>
[SugarColumn(ColumnName = "PLAN_AMOUNT")]
public int PlanAmount { get; set; }
/// <summary>
/// 计划数量
/// </summary>
[SugarColumn(ColumnName = "COMPLETE_AMOUNT")]
public int CompleteAmount { get; set; }
/// <summary>
/// 任务编码
/// </summary>
[SugarColumn(ColumnName = "TASK_CODE")]
public string TaskCode { get; set; }
/// <summary>
/// 前板数量
/// </summary>
[SugarColumn(ColumnName = "SIDEPANELAMOUNT")]
public int SidePanelAmount { get; set; }
/// <summary>
/// 后板数量
/// </summary>
[SugarColumn(ColumnName = "BACKPANELAMOUNT")]
public int BackPanelAmount { get; set; }
/// <summary>
/// 执行顺序
/// </summary>
[SugarColumn(ColumnName = "EXECUTE_ORDER")]
public int ExecuteOrder { get; set; }
}
}

@ -82,5 +82,41 @@ namespace Admin.Core.Repository
return Db.CopyNew().SqlQueryable<SheetMetalDataView>(sql).Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToList();
}
/// <summary>
/// 下发计划
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
public List<SheetMetaPlanInfoView> QuerySheetMetalPlanData(string stationCode)
{
string sql = $@"select P.OBJ_ID,P.PLAN_CODE,P.ORDER_CODE,P.MATERIAL_CODE,P.MATERIAL_NAME,P.PRODUCTLINE_CODE,
P.PLAN_AMOUNT,P.COMPLETE_AMOUNT,P.BEGIN_TIME,P.END_TIME,SPC.MATERIAL_SPECIFICATIONS from C##AUCMA_MES.PRODUCT_PLANINFO P
inner join (select SPC.*,ML.MATERIAL_SPECIFICATIONS FROM C##AUCMA_MES.PRODUCT_PLANINFO SPC
inner JOIN C##AUCMA_MES.BASE_MATERIALINFO ML ON ML.MATERIAL_CODE = SPC.MATERIAL_CODE where SPC.PRODUCTLINE_CODE ='{stationCode}'
) SPC on p.ORDER_CODE=SPC.ORDER_CODE
where p.PRODUCTLINE_CODE ='{stationCode}' ";
return Db.CopyNew().SqlQueryable<SheetMetaPlanInfoView>(sql).Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToList();
}
/// <summary>
/// 获取钣金下发的计划
/// </summary>
/// <param name="stationCode"></param>
/// <returns></returns>
public List<SheetMetaSendPlanInfoView> QuerySheetMetalSendPlanData(string stationCode)
{
string sql = $@"select *from (select e.OBJ_ID,e.EXECUTE_PLANCODE, e.ORDER_CODE, e.MATERIAL_CODE,e.MATERIAL_NAME, e.MATERIAL_SPECIFICATIONS,
e.EXECUTE_STATUS,e.PLAN_TYPE,e.PLAN_AMOUNT,e.COMPLETE_AMOUNT,e.TASK_CODE,COUNT(c.PLAN_CODE) BACKPANELAMOUNT,COUNT(s.PLAN_CODE) SIDEPANELAMOUNT,e.EXECUTE_ORDER
from EXECUTE_PLANINFO e left join RECORD_BACKPANEL_COMPLATE c on e.TASK_CODE=c.PLAN_CODE
left join RECORD_SIDEPANEL_COMPLATE s on e.TASK_CODE=s.PLAN_CODE
where e.PRODUCTLINE_CODE='{stationCode}' and EXECUTE_STATUS in (1,2)
GROUP BY e.OBJ_ID,e.EXECUTE_PLANCODE,e.ORDER_CODE, e.MATERIAL_CODE,e.MATERIAL_NAME,e.MATERIAL_SPECIFICATIONS, e.PLAN_TYPE,e.PLAN_AMOUNT,e.EXECUTE_STATUS,e.COMPLETE_AMOUNT, e.TASK_CODE,e.EXECUTE_ORDER ) t
order by t.EXECUTE_ORDER ";
return Db.CopyNew().SqlQueryable<SheetMetaSendPlanInfoView>(sql).ToList();
}
}
}

@ -41,6 +41,8 @@ namespace Admin.Core.Service
/// <returns></returns>
public async Task<bool> ExecPlanDelete(string id)
{
if (string.IsNullOrWhiteSpace(id)) { return false; }
return await _dal.DeleteByIdAsync(id);
}
#endregion
@ -405,5 +407,38 @@ namespace Admin.Core.Service
{
return _executePlanInfoRepository.QuerySheetMetalData(stationCode);
}
public List<SheetMetaPlanInfoView> QuerySheetMetalPlanData(string stationCode)
{
return _executePlanInfoRepository.QuerySheetMetalPlanData(stationCode);
}
public List<SheetMetaSendPlanInfoView> QuerySheetMetalSendPlanData(string stationCode)
{
return _executePlanInfoRepository.QuerySheetMetalSendPlanData(stationCode);
}
/// <summary>
/// 修改执行计划
/// </summary>
/// <param name="executePlanInfo"></param>
/// <returns></returns>
public async Task<bool> UpdateSheetMetalExecutePlanInfo(int execPanId, int status)
{
bool result = false;
try
{
var executePlanInfo =await _dal.FirstAsync(d=>d.ObjId== execPanId);
executePlanInfo.ExecuteStatus = status;
result = await _dal.UpdateAsync(executePlanInfo);
}
catch (Exception ex)
{
logHelper.Error("修改执行计划异常", ex);
}
return result;
}
}
}

@ -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)
@ -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);
@ -421,7 +822,7 @@ public class SheetMetalPlanTaskHandle
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,
@ -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);
@ -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,
@ -722,4 +1123,5 @@ public class SheetMetalPlanTaskHandle
}
return returnStr;
}
#endregion
}

@ -83,5 +83,9 @@ namespace Aucma.Core.SheetMetal.Models
/// 钣金类型
/// </summary>
public int PlanType { get; set; }
/// <summary>
/// 产品型号
/// </summary>
public string MaterialSpecificatons { get; set; }
}
}

@ -21,6 +21,7 @@ using Aucma.Core.SheetMetal.Business;
using Admin.Core.Model.ViewModels;
using NPOI.SS.Formula.Functions;
using log4net;
using Aucma.Core.HwPLc;
/*
*
*/
@ -209,7 +210,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
string stationCode = Appsettings.app("StationInfo", "StationCode");
CurrentTeamTimeView view = GetTeamHour();
var list = _taskExecutionPlanInfoServices.QueryAsync(x => x.ProductLineCode == stationCode && x.BeginTime > view.StartTime || x.ExecuteStatus == 2).Result;
var list = _taskExecutionPlanInfoServices.QueryAsync(x => x.IsFlag == 0 && x.ProductLineCode == stationCode && x.BeginTime > view.StartTime || x.ExecuteStatus == 2).Result;
if (list == null) return Task.CompletedTask;
var execList = list.OrderByDescending(d => d.ExecuteOrder);
@ -251,31 +252,31 @@ namespace Aucma.Core.SheetMetal.ViewModels
}
//更新首页显示信息
ExecutePlanInfo execPlan = execList.SingleOrDefault(d => d.ExecuteStatus == 2);
if (execPlan != null)
{
OrderCode = execPlan.OrderCode;
MesMOrderCode = execPlan.ProductPlanCode;
ProductModel = execPlan.MaterialName;
BeginTime = execPlan.BeginTime.ToString();
PlanMaxNum = PlanNum = execPlan.PlanAmount;
RealQuantity = execPlan.CompleteAmount;
double diff = _planMaxNum - _realQuantity;
DiffQuantity =int.Parse(diff.ToString());
//CompletionRate = (_realQuantity/_planMaxNum).ToString("0%");
CompletionRate = (_realQuantity / _planMaxNum);
}
else
{
OrderCode =string.Empty;
MesMOrderCode = string.Empty;
ProductModel = string.Empty;
BeginTime = string.Empty;
PlanMaxNum = 0;
RealQuantity =0.0;
DiffQuantity = 0;
CompletionRate =0;
}
//ExecutePlanInfo execPlan = execList.SingleOrDefault(d => d.ExecuteStatus == 2);
//if (execPlan != null)
//{
// OrderCode = execPlan.OrderCode;
// MesMOrderCode = execPlan.ProductPlanCode;
// ProductModel = execPlan.MaterialName;
// BeginTime = execPlan.BeginTime.ToString();
// PlanMaxNum = PlanNum = execPlan.PlanAmount;
// RealQuantity = execPlan.CompleteAmount;
// double diff = _planMaxNum - _realQuantity;
// DiffQuantity =int.Parse(diff.ToString());
// //CompletionRate = (_realQuantity/_planMaxNum).ToString("0%");
// CompletionRate = (_realQuantity / _planMaxNum);
//}
//else
//{
// OrderCode =string.Empty;
// MesMOrderCode = string.Empty;
// ProductModel = string.Empty;
// BeginTime = string.Empty;
// PlanMaxNum = 0;
// RealQuantity =0.0;
// DiffQuantity = 0;
// CompletionRate =0;
//}
}));
}
catch (Exception ex)
@ -330,11 +331,25 @@ namespace Aucma.Core.SheetMetal.ViewModels
MessageBoxResult msg = MessageBox.Show("确定要删除吗?", "系统提醒", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
if (MessageBoxResult.Yes == msg)
{
bool result = await _taskExecutionPlanInfoServices.ExecPlanDelete(Id);
int id = Convert.ToInt32(Id);
ExecutePlanInfo executionPlanInfo= _taskExecutionPlanInfoServices.FirstAsync(s => s.ObjId == id).Result;
if (executionPlanInfo.PlanAmount== executionPlanInfo.CompleteAmount)
{
MessageBox.Show("执行计划已经完成,不可以删除!", "系统信息");
return;
}
executionPlanInfo.IsFlag = 1;
bool result = await _taskExecutionPlanInfoServices.UpdateAsync(executionPlanInfo);
if (result)
{
//下发该计划取消PLC任务
//var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
//var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
//obj_backPanel.plc.WriteInt16("D4021","5");//下传5为计划结束
PlanInfoDataGrid.Clear();
LoadData();
await LoadData();
MessageBox.Show("执行计划删除成功", "系统信息");
}

@ -32,9 +32,13 @@ namespace Aucma.Core.SheetMetal.ViewModels
init();
Task.Run(() =>
{
//_taskHandle.InitSendPlanData();
_taskHandle.InitSendPlan();
//_taskHandle.InitSendPlan();
_taskHandle.InitSendBackPanelPlan();
});
Task.Run(() =>
{
//_taskHandle.InitSendPlan();
_taskHandle.InitSendSidePanelPlan();
});
}
public void init()

@ -109,6 +109,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
task.BeginTime = DateTime.Now;
task.ExecuteStatus = 1;
task.PlanType = productPlanInfo.PlanType;
task.MaterialSpecificatons = productPlanInfo.MaterialSpecificatons;
var result = await _executePlanInfoServices.AddAsync(task);
if (result > 0)

@ -31,7 +31,6 @@ namespace Aucma.Core.SheetMetal.ViewModels
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(SplitPlanViewModel));
protected readonly IProductPlanInfoServices? _productPlanInfoServices;
//protected readonly ISmTaskExecutionServices? _smTaskExecutionServices;
protected readonly IExecutePlanInfoServices? _executePlanInfoServices;
private AppConfigHelper appConfig = new AppConfigHelper();
@ -52,11 +51,13 @@ namespace Aucma.Core.SheetMetal.ViewModels
MaterialDataGrid.Clear();
int i = 1;
string station = Appsettings.app("StationInfo", "StationCode");
var planlist = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)).Result;
if (planlist == null) return ;
var execList = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station));
//var planlist = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)).Result;
//if (planlist == null) return ;
//var execList = await _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station));
//if (execList == null) return;
var execList = _executePlanInfoServices.QuerySheetMetalPlanData(station);
if (execList == null) return;
foreach (var item in planlist)
foreach (var item in execList)
{
int residue = 0;
if (execList == null) residue = 0;
@ -71,6 +72,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
PlanAmount = item.PlanAmount,
ResidueAmount = item.PlanAmount - item.CompleteAmount,
SpliteResidueAmount = item.PlanAmount - residue,
MaterialSpecificatons = item.MaterialSpecificatons,
StartDate = item.BeginTime
});
i++;

@ -60,7 +60,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
}
}
private async Task LoadDateData(string result)
private Task LoadDateData(string result)
{
string station = Appsettings.app("StationInfo", "StationCode");
var list = _productPlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(station)).Result;
@ -86,6 +86,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
});
i++;
}
return Task.CompletedTask;
}
#endregion
@ -109,13 +110,9 @@ namespace Aucma.Core.SheetMetal.ViewModels
[RelayCommand]
private async Task ExecQuery(string result)
{
//System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
//{
if (!string.IsNullOrEmpty(result))
{
MaterialDataGrid.Clear();
await LoadDateData(result);
}
else
@ -126,48 +123,5 @@ namespace Aucma.Core.SheetMetal.ViewModels
}
#endregion
/// <summary>
/// 围板完成数量
/// </summary>
/// <param name="sidePanelComplate"></param>
/// <param name="orderCode">订单</param>
/// <param name="productLineCode">工位</param>
/// <returns></returns>
public int GetSidePanelCompleteData(List<RecordSidePanelComplate> sidePanelComplate, string orderCode, string productLineCode)
{
try
{
var execList = _executePlanInfoServices.QueryAsync(d => d.OrderCode == orderCode && d.ProductPlanCode == productLineCode).Result;
List<string> taskCodeList = execList.Select(x => x.TaskCode).ToList();
var list = _sidePanelComplateServices.QueryAsync(d => taskCodeList.Contains(d.PlanCode)).Result;
return list.Count;
}
catch (Exception)
{
return 0;
}
}
/// <summary>
/// 背板完成数量
/// </summary>
/// <param name="sidePanelComplate"></param>
/// <param name="orderCode"></param>
/// <param name="productLineCode"></param>
/// <returns></returns>
public int GetBackPanelCompleteData(List<RecordSidePanelComplate> sidePanelComplate, string orderCode, string productLineCode)
{
try
{
var execList = _executePlanInfoServices.QueryAsync(d => d.OrderCode == orderCode && d.ProductPlanCode == productLineCode).Result;
List<string> taskCodeList = execList.Select(x => x.TaskCode).ToList();
var list = _backPanelComplateServices.QueryAsync(d => taskCodeList.Contains(d.PlanCode)).Result;
return list.Count;
}
catch (Exception)
{
return 0;
}
}
}
}

@ -31,6 +31,7 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
@ -46,11 +47,15 @@
<TextBox x:Name="materialCode" FontSize="18" Text="{Binding PlanInfo.MaterialName}" Foreground="#FFFFFF" BorderBrush="White" Width="150" IsReadOnly="True" Margin="5,0,10,0"/>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="产品简码" FontSize="18" Foreground="#FFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox x:Name="materialSpecificatons" FontSize="18" Text="{Binding PlanInfo.MaterialSpecificatons}" Foreground="#FFFFFF" BorderBrush="White" Width="150" IsReadOnly="True" Margin="5,0,10,0"/>
</StackPanel>
<StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="计划数量" FontSize="18" Foreground="#FFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox FontSize="18" Text="{Binding PlanInfo.PlanAmount}" Foreground="#FFFFFF" BorderBrush="White" Width="150" IsReadOnly="True" Margin="5,0,10,0"/>
</StackPanel>
<StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="完成数量" FontSize="18" Foreground="#FFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox FontSize="18" Text="{Binding PlanInfo.CompleteAmount}" Foreground="#FFFFFF" BorderBrush="White" Width="150" IsReadOnly="True" Margin="5,0,10,0"/>
</StackPanel>

@ -236,6 +236,7 @@
<DataGridTextColumn Binding="{Binding PlanCode}" Header="计划编号" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding OrderCode}" Header="工单编号" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialName}" Header="产品型号" Width="3*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialSpecificatons}" Header="产品型号" Width="*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding PlanAmount}" Header="计划数量" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding CompleteAmount}" Header="完成数量" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding BeginTime,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="开始时间" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>

@ -136,7 +136,7 @@
"PlcType": "Melsec",
"Enabled": true,
"IP": "10.10.91.6",
"Port": 5552
"Port": 5553
}
]
}

@ -2,6 +2,7 @@
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using Admin.Core.Model.ViewModels;
using Aucma.Core.HwPLc;
using Aucma.Core.Tasks.Business;
using log4net;
@ -16,55 +17,57 @@ namespace Aucma.Core.Tasks
{
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(AucamTaskService));
IPerfusionRecordServices _perfusionRecordServices;
IExecutePlanInfoServices _executePlanInfoServices;
System.Timers.Timer timer1 = new System.Timers.Timer(5000);
public AucamTaskService(IPerfusionRecordServices perfusionRecordServices, IPerfusionAlarmServices perfusionAlarmServices, IPerfusionDeviceStatusServices perfusionDeviceStatusServices)
public AucamTaskService(IPerfusionRecordServices perfusionRecordServices,
IPerfusionAlarmServices perfusionAlarmServices, IExecutePlanInfoServices executePlanInfoServices,
IPerfusionDeviceStatusServices perfusionDeviceStatusServices)
{
PerfusionCollection coll = new PerfusionCollection(perfusionRecordServices, perfusionAlarmServices, perfusionDeviceStatusServices);
}
System.Timers.Timer timer1 = new System.Timers.Timer(5000);
#region 更新钣金工位计划数
bool qFlay = true;//完成
public void AucamTaskAsync()
public void AucamUpdatePlanNumTask()
{
timer1.Elapsed += new System.Timers.ElapsedEventHandler(Run1); //到达时间的时候执行事件;
timer1.AutoReset = true;//设置是执行一次false还是一直执行(true)
timer1.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
timer1.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
//timer1.Elapsed += new System.Timers.ElapsedEventHandler(Run1); //到达时间的时候执行事件;
//timer1.AutoReset = true;//设置是执行一次false还是一直执行(true)
//timer1.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
//timer1.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
}
#region 老发泡
/// <summary>
/// 老发泡
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Run1(object? sender, ElapsedEventArgs e)
{
if (qFlay)
{
qFlay = false;
try
List<SheetMetalDataView> viewList=new List<SheetMetalDataView>();
List<SheetMetalDataView> list= _executePlanInfoServices.QuerySheetMetalData("1001");
foreach (SheetMetalDataView item in list)
{
if (item.SidPanelAmount==item.BackPanelAmount)
{
Collection.startCollect();
SheetMetalDataView view = new SheetMetalDataView();
view.CompleteAmount= item.PlanAmount;
viewList.Add(view);
}
catch (Exception)
if (item.SidPanelAmount > item.BackPanelAmount)
{
throw;
SheetMetalDataView view = new SheetMetalDataView();
view.CompleteAmount = item.BackPanelAmount;
viewList.Add(view);
}
finally
if (item.SidPanelAmount < item.BackPanelAmount)
{
qFlay = true;
SheetMetalDataView view = new SheetMetalDataView();
view.CompleteAmount = item.SidPanelAmount;
viewList.Add(view);
}
}
}
}
#endregion
}
}

@ -3,6 +3,9 @@ namespace Aucma.Core.Tasks
{
public interface IAucamTaskService
{
void AucamTaskAsync();
/// <summary>
/// 实时更新工位计划表中的数据
/// </summary>
public void AucamUpdatePlanNumTask();
}
}

Loading…
Cancel
Save