liulb@mesnac.com 1 year ago
parent af1a8e25fe
commit 57478af4d8

@ -2496,6 +2496,56 @@
是否标识 是否标识
</summary> </summary>
</member> </member>
<member name="T:Admin.Core.Model.RecordSidePanelComplate">
<summary>
完成记录
</summary>
</member>
<member name="P:Admin.Core.Model.RecordSidePanelComplate.ObjId">
<summary>
主键标识
</summary>
</member>
<member name="P:Admin.Core.Model.RecordSidePanelComplate.PlanCode">
<summary>
计划编号
</summary>
</member>
<member name="P:Admin.Core.Model.RecordSidePanelComplate.MaterialCode">
<summary>
物料编号
</summary>
</member>
<member name="P:Admin.Core.Model.RecordSidePanelComplate.ProductlineCode">
<summary>
计划工位
</summary>
</member>
<member name="P:Admin.Core.Model.RecordSidePanelComplate.CompleteAmount">
<summary>
完成数量
</summary>
</member>
<member name="P:Admin.Core.Model.RecordSidePanelComplate.OffLineAmount">
<summary>
下线数量
</summary>
</member>
<member name="P:Admin.Core.Model.RecordSidePanelComplate.OutPutAmount">
<summary>
实际产量
</summary>
</member>
<member name="P:Admin.Core.Model.RecordSidePanelComplate.RecordTime">
<summary>
记录时间
</summary>
</member>
<member name="P:Admin.Core.Model.RecordSidePanelComplate.IsFlag">
<summary>
是否标识
</summary>
</member>
<member name="T:Admin.Core.Model.SMProductionCompletionRecord"> <member name="T:Admin.Core.Model.SMProductionCompletionRecord">
<summary> <summary>
钣金每日生产记录表 钣金每日生产记录表

@ -0,0 +1,14 @@
using Admin.Core.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.IService
{
public interface IRecordSidePanelComplateServices : IBaseServices<RecordSidePanelComplate>
{
Task<bool> InsertSidePanelCimplate(RecordSidePanelComplate sidePanelComplate);
}
}

@ -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
{
/// <summary>
/// 完成记录
///</summary>
[SugarTable("RECORD_SIDEPANEL_COMPLAte", "AUCMA_SCADA")]
public class RecordSidePanelComplate
{
/// <summary>
/// 主键标识
///</summary>
[SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, OracleSequenceName = "SEQ_RECORD_SIDEPANEL_COMPLATE")]
public decimal ObjId { get; set; }
/// <summary>
/// 计划编号
///</summary>
[SugarColumn(ColumnName = "PLAN_CODE")]
public string PlanCode { get; set; }
/// <summary>
/// 物料编号
///</summary>
[SugarColumn(ColumnName = "MATERIAL_CODE")]
public string MaterialCode { get; set; }
/// <summary>
/// 计划工位
///</summary>
[SugarColumn(ColumnName = "PRODUCTLINE_CODE")]
public string ProductlineCode { get; set; }
/// <summary>
/// 完成数量
///</summary>
[SugarColumn(ColumnName = "COMPLETE_AMOUNT")]
public int CompleteAmount { get; set; }
/// <summary>
/// 下线数量
/// </summary>
[SugarColumn(ColumnName = "OFFLINE_AMOUNT")]
public int OffLineAmount { get; set; }
/// <summary>
/// 实际产量
/// </summary>
[SugarColumn(ColumnName = "OUTPUT_AMOUNT")]
public int OutPutAmount { get; set; }
[SugarColumn(ColumnName = "DEVICE_STATUS")]
public decimal? DeviceStatus { get; set; }
[SugarColumn(ColumnName = "PRODUCTION_BEAT")]
public decimal? ProductionBeat { get; set; }
/// <summary>
/// 记录时间
///</summary>
[SugarColumn(ColumnName = "RECORD_TIME")]
public DateTime? RecordTime { get; set; }
/// <summary>
/// 是否标识
///</summary>
[SugarColumn(ColumnName = "IS_FLAG")]
public decimal? IsFlag { get; set; }
}
}

@ -0,0 +1,41 @@
using Admin.Core.IRepository;
using Admin.Core.IService;
using Admin.Core.Model;
using log4net;
using System;
using System.Threading.Tasks;
namespace Admin.Core.Service
{
/// <summary>
/// RecordProductFinishServices
/// </summary>
public class RecordSidePanelComplateServices : BaseServices<RecordSidePanelComplate>, IRecordSidePanelComplateServices
{
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(RecordOutStoreServices));
private readonly IBaseRepository<RecordSidePanelComplate> _dal;
public RecordSidePanelComplateServices(IBaseRepository<RecordSidePanelComplate> dal)
{
this._dal = dal;
base.BaseDal = dal;
}
public async Task<bool> InsertSidePanelCimplate(RecordSidePanelComplate sidePanelComplate)
{
bool result = false;
try
{
int r =await _dal.AddAsync(sidePanelComplate);
if (r > 0) result=true;
}
catch (Exception ex)
{
logHelper.Error("完成记录添加异常", ex);
}
return result;
}
}
}

@ -21,12 +21,12 @@ namespace Aucma.Core.OldBoxFoam.Business
public List<FixtureStatus> listFixtureStatus = new List<FixtureStatus>(); public List<FixtureStatus> listFixtureStatus = new List<FixtureStatus>();
public List<SpaceDetailModel> spaceDetailModel = new List<SpaceDetailModel>(); public List<SpaceDetailModel> spaceDetailModel = new List<SpaceDetailModel>();
public List<int> BoxTypeList = new List<int>(); public static List<int> BoxTypeList = new List<int>();
public List<int> HolderStatusList = new List<int>(); public static List<int> HolderStatusList = new List<int>();
public List<int> HolderOutPutList = new List<int>(); public static List<int> HolderOutPutList = new List<int>();
public List<int> SolidifyTimeList = new List<int>(); public static List<int> SolidifyTimeList = new List<int>();
public List<string> StoreTypeList = new List<string>(); public static List<string> StoreTypeList = new List<string>();
public List<string> StoreAmountList = new List<string>(); public static List<string> StoreAmountList = new List<string>();
public Collection() { public Collection() {
@ -133,9 +133,18 @@ namespace Aucma.Core.OldBoxFoam.Business
/// <summary> /// <summary>
/// 读取夹具箱型 /// 读取夹具箱型
/// </summary> /// </summary>
static void ReadBoxType(HwPLc.PlcModel obj, List<int> BoxTypeList) static void ReadBoxType(HwPLc.PlcModel obj, List<int> HolderStatusList)
{ {
if (obj == null) return; if (obj == null)
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
return;
}
if (obj.plc.IsConnected) if (obj.plc.IsConnected)
{ {
@ -156,6 +165,15 @@ namespace Aucma.Core.OldBoxFoam.Business
BoxTypeList.Add(temp6); BoxTypeList.Add(temp6);
Console.WriteLine($"读取夹具箱型,1#:{temp1};2#{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}"); Console.WriteLine($"读取夹具箱型,1#:{temp1};2#{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}");
} }
else
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
}
} }
/// <summary> /// <summary>
@ -163,7 +181,16 @@ namespace Aucma.Core.OldBoxFoam.Business
/// </summary> /// </summary>
static void ReadHolderStatus(PlcModel obj1, List<int> HolderStatusList) static void ReadHolderStatus(PlcModel obj1, List<int> HolderStatusList)
{ {
if (obj1 == null) return; if (obj1 == null)
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
return;
}
byte[] result = obj1.plc.Read("YF0", 1); byte[] result = obj1.plc.Read("YF0", 1);
if (result == null) return; if (result == null) return;
//输出二进制字符串,1#-3#手动、自动数据 //输出二进制字符串,1#-3#手动、自动数据
@ -271,9 +298,27 @@ namespace Aucma.Core.OldBoxFoam.Business
/// </summary> /// </summary>
static void ReadHolderOutPut(PlcModel obj,List<int> HolderOutPutList) static void ReadHolderOutPut(PlcModel obj,List<int> HolderOutPutList)
{ {
if (obj == null) return; if (obj == null)
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
return;
}
byte[] result = obj.plc.Read("D182", 24); byte[] result = obj.plc.Read("D182", 24);
if (result == null) return; if (result == null)
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
return;
}
byte[] info = result; byte[] info = result;
int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(2).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(2).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
@ -296,9 +341,27 @@ namespace Aucma.Core.OldBoxFoam.Business
/// </summary> /// </summary>
static void ReadSolidifyTime(PlcModel obj,List<int> SolidifyTimeList) static void ReadSolidifyTime(PlcModel obj,List<int> SolidifyTimeList)
{ {
if (obj == null) return; if (obj == null)
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
return;
}
byte[] result = obj.plc.Read("D910", 24); byte[] result = obj.plc.Read("D910", 24);
if (result == null) return; if (result == null)
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
return;
}
byte[] info = result; byte[] info = result;
int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(2).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(2).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
@ -320,10 +383,28 @@ namespace Aucma.Core.OldBoxFoam.Business
/// </summary> /// </summary>
static void ReadStoreType(PlcModel obj, List<string> storeType) static void ReadStoreType(PlcModel obj, List<string> storeType)
{ {
if (obj == null) return; if (obj == null)
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
return;
}
//夹具箱型 //夹具箱型
byte[] result = obj.plc.Read("D2010", 40); byte[] result = obj.plc.Read("D2010", 40);
if (result == null) return; if (result == null)
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
return;
}
byte[] info = result; byte[] info = result;
int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(20).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(20).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
@ -341,9 +422,27 @@ namespace Aucma.Core.OldBoxFoam.Business
/// </summary> /// </summary>
static void ReadStoreAmount(PlcModel obj, List<string> storeAmount) static void ReadStoreAmount(PlcModel obj, List<string> storeAmount)
{ {
if (obj == null) return; if (obj == null)
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
return;
}
byte[] result = obj.plc.Read("L101", 1); byte[] result = obj.plc.Read("L101", 1);
if (result == null) return; if (result == null)
{
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
BoxTypeList.Add(0);
return;
}
string str1 = ByteArrayToBinary(array(result)).Substring(0, 3); string str1 = ByteArrayToBinary(array(result)).Substring(0, 3);
int item1 = Regex.Matches(str1, "1").Count; int item1 = Regex.Matches(str1, "1").Count;

@ -231,10 +231,25 @@
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding ObjId}" Header="货道号" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding ObjId}" Header="货道号" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding Local}" Header="位置" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding Local}" Header="位置" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding Boxtype}" Header="货道类型" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTemplateColumn Width="*" Header="状态">
<DataGridTextColumn Binding="{Binding Storeamount}" Header="库存数量" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTemplateColumn.CellStyle>
<DataGridTextColumn Binding="{Binding Status}" Header="库存状态" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <Style TargetType="{x:Type DataGridCell}">
<DataGridTextColumn Binding="{Binding MaterialCode}" Header="物料编号" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" /> <Style.Triggers>
<DataTrigger Binding="{Binding Status}" Value="1">
<Setter Property="Background" Value="Red"/>
</DataTrigger>
<DataTrigger Binding="{Binding Status}" Value="0">
<Setter Property="Background" Value="LawnGreen"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGridTemplateColumn.CellStyle>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding Boxtype}" Header="货道类型" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding Storeamount}" Header="库存数量" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<!--<DataGridTextColumn Binding="{Binding Status}" Header="库存状态" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<DataGridTextColumn Binding="{Binding MaterialCode}" Header="物料编号" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding MaterialName}" Header="物料名称" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" /> <DataGridTextColumn Binding="{Binding MaterialName}" Header="物料名称" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<!--<DataGridTextColumn Binding="{Binding QualityResult}" Header="模具数量" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>--> <!--<DataGridTextColumn Binding="{Binding QualityResult}" Header="模具数量" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
</DataGrid.Columns> </DataGrid.Columns>

@ -11,8 +11,8 @@ namespace Aucma.Core.RunPlc
/// </summary> /// </summary>
public class RunPlcService : IRunPlcService public class RunPlcService : IRunPlcService
{ {
System.Timers.Timer timer = new System.Timers.Timer(5000);//创建定时器设置间隔时间为1000毫秒 System.Timers.Timer timer = new System.Timers.Timer(3000);//创建定时器设置间隔时间为1000毫秒
System.Timers.Timer timer1 = new System.Timers.Timer(3000);
#region 构造函数 #region 构造函数
public RunPlcService() public RunPlcService()
{ {
@ -29,10 +29,10 @@ namespace Aucma.Core.RunPlc
timer.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它 timer.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
timer.Start();//timer.Start()的内部原理还是设置timer.Enabled = true; timer.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(ExecSiemensHeartTask); timer1.Elapsed += new System.Timers.ElapsedEventHandler(ExecSiemensHeartTask);
timer.AutoReset = true;//设置是执行一次false还是一直执行(true) timer1.AutoReset = true;//设置是执行一次false还是一直执行(true)
timer.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它 timer1.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
timer.Start();//timer.Start()的内部原理还是设置timer.Enabled = true; timer1.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -87,7 +87,7 @@ namespace Aucma.Core.RunPlc
{ {
var item = PlcHelper.melsecList.Where(c => c.Id == i).FirstOrDefault(); var item = PlcHelper.melsecList.Where(c => c.Id == i).FirstOrDefault();
if (item == null) continue; if (item == null) continue;
if (await item.plc.Read("M100")) if (item.plc.Read("M100").Result)
{ {
item.IsConnect = true; item.IsConnect = true;
item.plc.IsConnected = true; item.plc.IsConnected = true;

@ -1,9 +1,11 @@
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Documents;
using Admin.Core.Common; using Admin.Core.Common;
using Admin.Core.IService; using Admin.Core.IService;
using Admin.Core.Model; using Admin.Core.Model;
@ -25,127 +27,262 @@ public class SheetMetalPlanTaskHandle
public event RefreshCurrentPlanInfo RefreshCurrentPlanInfoEvent; public event RefreshCurrentPlanInfo RefreshCurrentPlanInfoEvent;
protected readonly IExecutePlanInfoServices? _executePlanInfoServices; protected readonly IExecutePlanInfoServices? _executePlanInfoServices;
protected readonly IRecordSidePanelComplateServices _sidePanelComplateServices;
public HwPLc.PlcModel plc1 = null;
public SheetMetalPlanTaskHandle() public SheetMetalPlanTaskHandle()
{ {
_executePlanInfoServices = _executePlanInfoServices =
App.ServiceProvider.GetService<IExecutePlanInfoServices>(); App.ServiceProvider.GetService<IExecutePlanInfoServices>();
_sidePanelComplateServices = App.ServiceProvider.GetService<IRecordSidePanelComplateServices>();
} }
/// <summary> /// <summary>
/// 箱壳计划任务下发⾄设备PLC /// 下发围板生产计划
/// </summary> /// </summary>
/// <returns></returns> /// <param name="planInfo"></param>
public void SendPlanTaskToDevice() /// <param name="obj"></param>
public void SendPlanTask_WB(ExecutePlanInfo planInfo, PlcModel obj)
{ {
Thread.Sleep(5000); Thread.Sleep(5000);
try try
{ {
lock (string.Empty) lock (string.Empty)
{ {
string stationCode = Appsettings.app("StoreInfo", "StationCode"); if (obj != null)
//获取待执⾏的计划,根据计划序号进⾏排序依次下发
var list = _executePlanInfoServices.Query(d =>
d.ProductLineCode.Equals(stationCode) && d.ExecuteStatus == 1);
if (list != null)
{ {
//计划编号10个字D6000-D6009、物料编号10个字D6010-D6019、计划数量1个字D6020、应答字1个字D6021
if (list.Count > 0) obj.plc.WriteString("D6000", planInfo.TaskCode);
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
obj.plc.WriteString("D6010", "BCD/310NF");
obj.plc.WriteInt32("D6020", planInfo.PlanAmount);
obj.plc.WriteInt32("D6021", 1);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待围板设备应答。。。。。。");
//下发完成后读取PLC应答应答后复位应答信号
#region PLC反馈信号逻辑处理
//循环读取PLC应答信号PLC应答后复位应答信号、更新计划状态为执行中
bool isFlag = true;
do
{ {
ExecutePlanInfo task = list.OrderBy(x => x.ExecuteOrder).First(); if (obj.plc.ReadInt32("D6021") == 2)
var obj = PlcHelper.melsecList.FirstOrDefault(d =>
d.EquipName.Equals("OldTypePlc1"));
if (obj != null)
{ {
//计划编号10个字D6000-D6009、物料编号10个字D6010-D6019、计划数量1个字D6020、应答字1个字D6021 obj.plc.WriteInt32("D6021", 0);
obj.plc.WriteString("D6000", task.TaskCode); Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到围板设备应答信号,复位应答地址");
string processNumber = GetProcessNumberBy(task.MaterialCode); isFlag = false;
obj.plc.WriteString("D6010", "BCD/310NF");
obj.plc.WriteInt32("D6020", task.PlanAmount);
obj.plc.WriteInt32("D6021", 1);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待设备应答。。。。。。");
//下发完成后读取PLC应答应答后复位应答信号
ReadPlcFeedBack(obj);
//更新计划状态为2执行中
task.ExecuteStatus = 2;
_executePlanInfoServices.UpdateExecutePlanInfo(task);
RefreshCurrentPlanInfoEvent?.Invoke(task);
//读取设备进度,完成后再次下发新任务
ReadDeviceComplate(obj);
} }
} Thread.Sleep(2000);
else } while (isFlag);
{
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>未获取到需要下发的生产计划!"); //更新计划状态为2执行中
} planInfo.ExecuteStatus = 2;
//SheetMetalPlanTaskHandle handle = new SheetMetalPlanTaskHandle();
//plc1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));
//handle.SendPlanTask_WB(list, plc1);
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
RefreshCurrentPlanInfoEvent?.Invoke(planInfo);
#endregion
//读取设备进度,完成后再次下发新任务
ReadDeviceComplate_WB(obj);
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show($"箱壳⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBox.Show($"围板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
} }
} }
/// <summary> /// <summary>
/// 读取PLC应答反馈PLC反馈后复位应答地址 /// 读取围板生产数据
/// </summary> /// </summary>
private void ReadPlcFeedBack(PlcModel obj) /// <param name="obj"></param>
public void ReadDeviceComplate_WB(PlcModel obj)
{ {
bool isFlag = true; bool isFlag = true;
if (obj != null) try
{ {
do do
{ {
//计划编号D6030-D6039物料编号D6040-D6049计划完成数D6050计划下线数D6051设备状态D6052-D6056,生产节拍D6057-D6058
if (obj.plc.ReadInt32("D6021") == 1) byte[] info = obj.plc.Read("D6030", 59);
//计划编号
string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray());
//物料编号
string materialCode = Encoding.ASCII.GetString(info.Skip(20).Take(20).ToArray());
//完成数量
int complateAmount = short.Parse(bytesToHexStr(info.Skip(40).Take(1).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
//下线数量
int offLineAmount = short.Parse(bytesToHexStr(info.Skip(41).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
//设备状态
int deviceStatus = short.Parse(bytesToHexStr(info.Skip(43).Take(2).ToArray(), 2), 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}");
//添加完工记录
RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate()
{
ProductlineCode = "1001",
PlanCode = planCode,
MaterialCode = materialCode,
CompleteAmount = complateAmount,
OffLineAmount = offLineAmount,
DeviceStatus = deviceStatus,
ProductionBeat = productionBeat,
RecordTime = DateTime.Now
};
//先查询该计划编号下的前一条完工记录如果不存在本条记录产量为0
List<RecordSidePanelComplate> sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planCode);
int lastComplateAmount = 0; //前一条完成记录的计划完成数量
int sumComplateAmount = 0; //当前计划总产量
if (sidePanelComplates != null)
{ {
obj.plc.WriteInt32("D6021", 0); if (sidePanelComplates.Count > 0)
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到设备应答信号,复位应答地址"); {
isFlag = false; sidePanelComplates = sidePanelComplates.OrderByDescending(x => x.RecordTime).ToList();
lastComplateAmount = sidePanelComplates.First().CompleteAmount;
sidePanelComplate.OutPutAmount = complateAmount - lastComplateAmount;
sumComplateAmount = sidePanelComplates.Sum(x => x.OutPutAmount) + sidePanelComplate.OutPutAmount;
if (sidePanelComplate.OutPutAmount == 0)
{
Thread.Sleep(5000);
continue;
}
else
{
if (sumComplateAmount > 0)
{
ExecutePlanInfo planInfo = _executePlanInfoServices.Query(x => x.TaskCode.Equals(planCode.Substring(0, 13)) && x.ExecuteStatus == 2).FirstOrDefault();
if (planInfo != null)
{
if (sumComplateAmount > planInfo.CompleteAmount)
{
if (planInfo.PlanAmount - sumComplateAmount == 0)
{
Console.WriteLine($"计划:{planCode},执行完成!!!");
planInfo.CompleteAmount = sumComplateAmount;
planInfo.ExecuteStatus = 3;
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
isFlag = false;
}
else
{
Console.WriteLine(
$"设备当前计划:{planCode},计划数量:{planInfo.PlanAmount},实际完成:{sumComplateAmount},差异:{planInfo.PlanAmount - sumComplateAmount}");
planInfo.CompleteAmount = sumComplateAmount;
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
}
RefreshCurrentPlanInfoEvent?.Invoke(planInfo);
}
}
}
}
}
} }
Thread.Sleep(2000);
_sidePanelComplateServices.InsertSidePanelCimplate(sidePanelComplate);
Thread.Sleep(5000);
} while (isFlag); } while (isFlag);
} }
catch (Exception e)
{
Console.WriteLine($"读取设备完成数据异常:{e.Message}");
}
} }
/// <summary> /// <summary>
/// 读取设备完成数据 /// 下发背板生产计划
/// </summary> /// </summary>
/// <param name="planInfo"></param>
/// <param name="obj"></param> /// <param name="obj"></param>
public void ReadDeviceComplate(PlcModel obj) public void SendPlanTaskTo_BB(ExecutePlanInfo planInfo, PlcModel obj)
{ {
bool isFlag = true; Thread.Sleep(5000);
try try
{ {
if (obj != null) lock (string.Empty)
{ {
do if (obj != null)
{ {
//计划编号D6030-D6039物料编号D6040-D6049计划完成数D6050计划下线数D6051设备状态D6052-D6056,生产节拍D6057-D6058 //计划编号10个字D6000-D6009、物料编号10个字D6010-D6019、计划数量1个字D6020、应答字1个字D6021
obj.plc.WriteString("D6000", planInfo.TaskCode);
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
obj.plc.WriteString("D6010", "BCD/310NF");
obj.plc.WriteInt32("D6020", planInfo.PlanAmount);
obj.plc.WriteInt32("D6021", 1);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>等待背板设备应答。。。。。。");
#region PLC反馈信号逻辑处理
//循环读取PLC应答信号PLC应答后复位应答信号、更新计划状态为执行中
bool isFlag = true;
do
{
#region 单个地址读取 if (obj.plc.ReadInt32("D6021") == 2)
{
obj.plc.WriteInt32("D6021", 0);
Console.WriteLine($"{DateTime.Now.ToString("HH:m:s")}===>收到背板板设备应答信号,复位应答地址");
isFlag = false;
}
Thread.Sleep(2000);
} while (isFlag);
/* //更新计划状态为2执行中
string planCode = obj.plc.ReadString("D6030"); planInfo.ExecuteStatus = 2;
string materialCode = obj.plc.ReadString("D6040"); _executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
int complateAmount = obj.plc.ReadInt32("D6050"); RefreshCurrentPlanInfoEvent?.Invoke(planInfo);
int offLineAmount = obj.plc.ReadInt32("D6051");
int productionBeat = obj.plc.ReadInt32("D6057");
*/
#endregion #endregion
//读取设备进度,完成后再次下发新任务
ReadDeviceComplate_BB(obj);
}
else
{
return;
}
}
}
catch (Exception ex)
{
MessageBox.Show($"背板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
/// <summary>
/// 读取背板生产数据
/// </summary>
/// <param name="obj"></param>
public void ReadDeviceComplate_BB(PlcModel obj)
{
bool isFlag = true;
try
{
do
{
//计划编号D6030-D6039物料编号D6040-D6049计划完成数D6050计划下线数D6051设备状态D6052-D6056,生产节拍D6057-D6058
byte[] info = obj.plc.Read("D6030", 59); byte[] info = obj.plc.Read("D6030", 59);
//计划编号 //计划编号
string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()); string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray());
@ -162,38 +299,79 @@ public class SheetMetalPlanTaskHandle
Console.WriteLine($"设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}"); Console.WriteLine($"设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
//更新执行计划差异值为0后任务结束再次下发新任务 //添加完工记录
ExecutePlanInfo planInfo = _executePlanInfoServices.Query(x=>x.TaskCode.Equals(planCode.Substring(0,13)) && x.ExecuteStatus == 2).FirstOrDefault(); RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate()
{
if (planInfo != null) ProductlineCode = "1002",
PlanCode = planCode,
MaterialCode = materialCode,
CompleteAmount = complateAmount,
OffLineAmount = offLineAmount,
DeviceStatus = deviceStatus,
ProductionBeat = productionBeat,
RecordTime = DateTime.Now
};
//先查询该计划编号下的前一条完工记录如果不存在本条记录产量为0
List<RecordSidePanelComplate> sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1002" && x.PlanCode == planCode);
int lastComplateAmount = 0; //前一条完成记录的计划完成数量
int sumComplateAmount = 0; //当前计划总产量
if (sidePanelComplates != null)
{ {
if (complateAmount > planInfo.CompleteAmount) if (sidePanelComplates.Count > 0)
{ {
sidePanelComplates = sidePanelComplates.OrderByDescending(x => x.RecordTime).ToList();
if (planInfo.PlanAmount - complateAmount == 0) lastComplateAmount = sidePanelComplates.First().CompleteAmount;
sidePanelComplate.OutPutAmount = complateAmount - lastComplateAmount;
sumComplateAmount = sidePanelComplates.Sum(x => x.OutPutAmount) + sidePanelComplate.OutPutAmount;
if (sidePanelComplate.OutPutAmount == 0)
{ {
Console.WriteLine($"计划:{planCode},执行完成!!!"); Thread.Sleep(5000);
planInfo.CompleteAmount = complateAmount; continue;
planInfo.ExecuteStatus = 3;
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
isFlag = false;
} }
else else
{ {
Console.WriteLine( if (sumComplateAmount > 0)
$"设备当前计划:{planCode},计划数量:{planInfo.PlanAmount},实际完成:{complateAmount},差异:{planInfo.PlanAmount - complateAmount}"); {
planInfo.CompleteAmount = complateAmount; ExecutePlanInfo planInfo = _executePlanInfoServices.Query(x=>x.TaskCode.Equals(planCode.Substring(0,13)) && x.ExecuteStatus == 2).FirstOrDefault();
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
if (planInfo != null)
{
if (sumComplateAmount > planInfo.CompleteAmount)
{
if (planInfo.PlanAmount - sumComplateAmount == 0)
{
Console.WriteLine($"计划:{planCode},执行完成!!!");
planInfo.CompleteAmount = sumComplateAmount;
planInfo.ExecuteStatus = 3;
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
isFlag = false;
}
else
{
Console.WriteLine(
$"设备当前计划:{planCode},计划数量:{planInfo.PlanAmount},实际完成:{sumComplateAmount},差异:{planInfo.PlanAmount - sumComplateAmount}");
planInfo.CompleteAmount = sumComplateAmount;
_executePlanInfoServices.UpdateExecutePlanInfo(planInfo);
}
RefreshCurrentPlanInfoEvent?.Invoke(planInfo);
}
}
}
} }
RefreshCurrentPlanInfoEvent?.Invoke(planInfo);
} }
} }
_sidePanelComplateServices.InsertSidePanelCimplate(sidePanelComplate);
Thread.Sleep(5000); Thread.Sleep(5000);
} while (isFlag); } while (isFlag);
}
} }
catch (Exception e) catch (Exception e)
{ {
@ -201,6 +379,8 @@ public class SheetMetalPlanTaskHandle
} }
} }
/// <summary> /// <summary>
/// 通过物料编号获取工艺编号 /// 通过物料编号获取工艺编号
/// </summary> /// </summary>

@ -52,11 +52,10 @@ namespace Aucma.Core.SheetMetal.ViewModels
{ {
_taskExecutionPlanInfoServices = App.ServiceProvider.GetService<IExecutePlanInfoServices>(); _taskExecutionPlanInfoServices = App.ServiceProvider.GetService<IExecutePlanInfoServices>();
StationName = Appsettings.app("StoreInfo", "StationName"); _stationName = Appsettings.app("StationInfo", "StationName");
Job_SheetMetalTask_Quartz.SmEverDayDelegateEvent += InitEveryDayMethod; Job_SheetMetalTask_Quartz.SmEverDayDelegateEvent += InitEveryDayMethod;
Job_SheetMetalTask_Quartz.SmTaskDelegateEvent += UpdatePlanSHow;//计划内容展示 Job_SheetMetalTask_Quartz.SmTaskDelegateEvent += UpdatePlanSHow;//计划内容展示
WeakReferenceMessenger.Default.Register<string>(this, Recive); WeakReferenceMessenger.Default.Register<string>(this, Recive);
Task.WaitAll(LoadData(), InitExecMethod()); Task.WaitAll(LoadData(), InitExecMethod());
InitEveryDayMethod(); InitEveryDayMethod();
@ -69,7 +68,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
Task.Run(() => Task.Run(() =>
{ {
Thread.Sleep(5000); Thread.Sleep(5000);
_taskHandle.SendPlanTaskToDevice(); //_taskHandle.SendPlanTaskToDevice();
}); });
} }
#endregion #endregion
@ -631,7 +630,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
App.Current.Dispatcher.BeginInvoke((Action)(() => App.Current.Dispatcher.BeginInvoke((Action)(() =>
{ {
PlanInfoDataGrid.Clear(); PlanInfoDataGrid.Clear();
LoadData(); _= LoadData();
})); }));
} }
} }

@ -3,6 +3,7 @@ using Admin.Core.IService;
using Admin.Core.Model; using Admin.Core.Model;
using Admin.Core.Service; using Admin.Core.Service;
using Aucma.Core.HwPLc; using Aucma.Core.HwPLc;
using Aucma.Core.SheetMetal.Business;
using Aucma.Core.SheetMetal.Models; using Aucma.Core.SheetMetal.Models;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
@ -13,6 +14,7 @@ using Microsoft.IdentityModel.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection.Metadata;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -102,10 +104,24 @@ namespace Aucma.Core.SheetMetal.ViewModels
if (obj == null) { return; } if (obj == null) { return; }
if (obj.plc.IsConnected) if (obj.plc.IsConnected)
{ {
obj.plc.WriteInt16("D8000", _TransmitAmount);//计划编号 //obj.plc.WriteInt16("D8000", _TransmitAmount);//计划编号
obj.plc.WriteInt16("D8009", _TransmitAmount);//计划编号 //obj.plc.WriteInt16("D8009", _TransmitAmount);//计划编号
obj.plc.WriteInt16("D8050", _TransmitAmount);//计划数量 //obj.plc.WriteInt16("D8050", _TransmitAmount);//计划数量
obj.plc.ReadInt16("D8021");//应答字 //obj.plc.ReadInt16("D8021");//应答字
SheetMetalPlanTaskHandle handle = new SheetMetalPlanTaskHandle();
if (productPlanInfo.PlanType== 1)
{
handle.SendPlanTaskTo_BB(task, obj);
handle.SendPlanTask_WB(task, obj);
}
if (productPlanInfo.PlanType == 2)
{
handle.SendPlanTask_WB(task, obj);
}
if (productPlanInfo.PlanType == 2)
{
handle.SendPlanTaskTo_BB(task, obj);
}
} }
MessageBox.Show("计划拆分成功!", "系统提醒"); MessageBox.Show("计划拆分成功!", "系统提醒");
WeakReferenceMessenger.Default.Send<string>("Refresh");//刷新窗口 WeakReferenceMessenger.Default.Send<string>("Refresh");//刷新窗口

@ -19,6 +19,8 @@ using Aucma.Core.SheetMetal.Common;
using System.Windows.Input; using System.Windows.Input;
using Admin.Core.Common; using Admin.Core.Common;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using Aucma.Core.SheetMetal.Business;
using Aucma.Core.HwPLc;
namespace Aucma.Core.SheetMetal.ViewModels namespace Aucma.Core.SheetMetal.ViewModels
{ {
@ -141,6 +143,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
MessageBox.Show("请选中需要拆分的计划!", "系统提醒"); MessageBox.Show("请选中需要拆分的计划!", "系统提醒");
return; return;
} }
string productLineCode=Appsettings.app("StationInfo", "ProductLineCode");
string plan_code = SelectedCells.PlanCode; string plan_code = SelectedCells.PlanCode;
string order_code = SelectedCells.OrderCode; string order_code = SelectedCells.OrderCode;
string material_code = SelectedCells.MaterialCode; string material_code = SelectedCells.MaterialCode;
@ -165,6 +168,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
task.PlanAmount = SelectedCells.SpliteResidueAmount; task.PlanAmount = SelectedCells.SpliteResidueAmount;
task.CompleteAmount = 0; task.CompleteAmount = 0;
task.CreatedTime = DateTime.Now; task.CreatedTime = DateTime.Now;
var result = await _executePlanInfoServices.AddAsync(task); var result = await _executePlanInfoServices.AddAsync(task);
if (result>0) if (result>0)
{ {

@ -70,7 +70,7 @@
<Setter Property="Foreground" Value="White"/> <Setter Property="Foreground" Value="White"/>
</Trigger> </Trigger>
<DataTrigger Binding="{Binding ExecuteStatus}" Value="2"> <DataTrigger Binding="{Binding ExecuteStatus}" Value="2">
<Setter Property="Background" Value="Green" /> <Setter Property="Background" Value="CadetBlue" />
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
@ -311,7 +311,7 @@
<DataGridTextColumn Binding="{Binding TaskAmount}" Header="计划" Width="0.6*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding TaskAmount}" Header="计划" Width="0.6*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding CompleteAmount}" Header="完成" Width="0.6*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding CompleteAmount}" Header="完成" Width="0.6*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding PlanType}" Header="计划类型" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding PlanType}" Header="计划类型" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding PlanType}" Header="配方" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <!--<DataGridTextColumn Binding="{Binding PlanType}" Header="配方" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<DataGridTextColumn Binding="{Binding BeginTime ,StringFormat=\{0:MM-dd HH:mm\}}" Header="开始时间" Width="1.2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding BeginTime ,StringFormat=\{0:MM-dd HH:mm\}}" Header="开始时间" Width="1.2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding ExecuteStatus}" Header="执行状态" Visibility="Collapsed"/> <DataGridTextColumn Binding="{Binding ExecuteStatus}" Header="执行状态" Visibility="Collapsed"/>

@ -113,7 +113,7 @@
"Enabled": true "Enabled": true
} }
}, },
"StoreInfo": { "StationInfo": {
"StationName": "箱壳前后板生产", "StationName": "箱壳前后板生产",
"StationCode": "1001", "StationCode": "1001",
"ShellStoreCode": "XKJCK-001", "ShellStoreCode": "XKJCK-001",

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save