change - 老线发泡注料温度、压力数据采集,过点数据存储

dev
wenjy 1 year ago
parent 6d509fff5d
commit 5f2390df7b

@ -49,6 +49,10 @@ namespace Admin.Core.Model.Model_New
[SugarColumn(ColumnName = "STATION_NAME")]
public string StationName { get; set; }
[SugarColumn(ColumnName = "PRODUCT_LINE_CODE")]
public string ProductLineCode { get; set; }
/// <summary>
/// 完成时间
/// </summary>

@ -31,7 +31,9 @@ namespace Admin.Core.Service.Service_New
private readonly IProductPlanInfoServices _productPlanInfoServices;
public RecordBoxFoamFixtureComplateServices(IBaseRepository<RecordBoxFoamFixtureComplate> dal, IOldBoxFoamTypeServices boxFoamTypeServices, IBoxFoamPlanServices boxFoamPlanServices, IBoxFoamDataServices oldBoxFoamDataServices, ISysUserInfoServices sysUserInfoServices, IBaseSpaceInfoServices baseSpaceInfoServices, IProductPlanInfoServices productPlanInfoServices)
private readonly IMaterialCompletionServices _materialCompletionServices;
public RecordBoxFoamFixtureComplateServices(IBaseRepository<RecordBoxFoamFixtureComplate> dal, IOldBoxFoamTypeServices boxFoamTypeServices, IBoxFoamPlanServices boxFoamPlanServices, IBoxFoamDataServices oldBoxFoamDataServices, ISysUserInfoServices sysUserInfoServices, IBaseSpaceInfoServices baseSpaceInfoServices, IProductPlanInfoServices productPlanInfoServices, IMaterialCompletionServices materialCompletionServices)
{
this._dal = dal;
base.BaseDal = dal;
@ -41,6 +43,7 @@ namespace Admin.Core.Service.Service_New
_sysUserInfoServices = sysUserInfoServices;
_baseSpaceInfoServices = baseSpaceInfoServices;
_productPlanInfoServices = productPlanInfoServices;
_materialCompletionServices = materialCompletionServices;
}
/// <summary>
@ -139,7 +142,7 @@ namespace Admin.Core.Service.Service_New
Console.WriteLine($"生产计划更新成功:{boxPlan.CompleteAmount}");
//更新MES计划
UpdateMesPlanInfo(boxPlan.PlanCode, item.RealOutPut);
UpdateMesPlanInfo(boxPlan.PlanCode, item.RealOutPut,stationCode, productLineCode);
}
else
{
@ -319,7 +322,7 @@ namespace Admin.Core.Service.Service_New
/// <summary>
/// 更新MES计划信息
/// </summary>
private void UpdateMesPlanInfo(string planCode,int complateAmount)
private void UpdateMesPlanInfo(string planCode,int complateAmount,string stationCode, string productLine)
{
if (string.IsNullOrEmpty(planCode))
{
@ -338,8 +341,39 @@ namespace Admin.Core.Service.Service_New
_productPlanInfoServices.UpdateProductPlanInfo(planInfo);
}
//保存过点数据
SaveMaterialComplate(planInfo, complateAmount, stationCode, productLine);
}
}
/// <summary>
/// 保存过点数据
/// </summary>
/// <param name="planInfo"></param>
/// <param name="complateAmount"></param>
/// <param name="stationCode"></param>
private void SaveMaterialComplate(ProductPlanInfo planInfo,int complateAmount,string stationCode,string productLine)
{
try
{
for (int i = 0; i < complateAmount; i++)
{
MaterialCompletion materialCompletion = new MaterialCompletion();
materialCompletion.ProductLineCode = productLine;
materialCompletion.planCode = planInfo.PlanCode;
materialCompletion.OrderCode = planInfo.OrderCode;
materialCompletion.MaterialCode = planInfo.MaterialCode;
materialCompletion.MaterialName = planInfo.MaterialName;
materialCompletion.StationName = stationCode;
materialCompletion.CompleteDate = DateTime.Now;
_materialCompletionServices.AddAsync(materialCompletion);
}
}catch(Exception ex)
{
logHelper.Error($"保存过点数据异常:{ex.Message}");
}
}
}
}

@ -10,6 +10,9 @@
</ItemGroup>
<ItemGroup>
<Reference Include="HslCommunication">
<HintPath>..\dll\HslCommunication.dll</HintPath>
</Reference>
<Reference Include="HwCommunication">
<HintPath>..\dll\HwCommunication.dll</HintPath>
</Reference>

@ -1,6 +1,5 @@
using HwCommunication;
using HwCommunication.Profinet.Melsec;
using HwCommunication.Profinet.Siemens;
using HslCommunication;
using HslCommunication.Profinet.Siemens;
using log4net;
using System;
using System.Text;

@ -7,6 +7,7 @@ using Admin.Core.Service;
using Aucma.Core.HwPLc;
using Aucma.Core.OldBoxFoam.Models;
using Consul;
using log4net;
using Microsoft.Extensions.DependencyInjection;
using NetTaste;
using System;
@ -22,10 +23,7 @@ namespace Aucma.Core.OldBoxFoam.Business
{
public class Collection
{
public HwPLc.PlcModel plc1 = null;
public HwPLc.PlcModel plc2 = null;
public HwPLc.PlcModel plc3 = null;
public HwPLc.PlcModel plc4 = null;
private readonly log4net.ILog log = LogManager.GetLogger(typeof(Collection));
public static List<FixtureStatus> listFixtureStatus = new List<FixtureStatus>();
public static List<SpaceDetailModel> spaceDetailModel = new List<SpaceDetailModel>();
@ -59,10 +57,10 @@ namespace Aucma.Core.OldBoxFoam.Business
listFixtureStatus = new List<FixtureStatus>();
try
{
plc1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));
plc2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2"));
plc3 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc3"));
plc4 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc4"));
PlcModel plc1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));
PlcModel plc2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2"));
PlcModel plc3 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc3"));
PlcModel plc4 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc4"));
List<SpaceDetailModel> spaceTypeList = ReadStoreType(plc1, plc3);
List<SpaceDetailModel> spaceAmountList = ReadStoreAmount(plc1, plc3);
@ -126,10 +124,10 @@ namespace Aucma.Core.OldBoxFoam.Business
}
}
catch (Exception)
catch (Exception ex)
{
throw;
log.Error($"发泡线数据采集异常:{ex.Message}");
}
}

@ -0,0 +1,154 @@
using Admin.Core.Common.Helper;
using Admin.Core.IService;
using Admin.Core.Model;
using Aucma.Core.HwPLc;
using log4net;
using Microsoft.Extensions.DependencyInjection;
using NetTaste;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static NPOI.HSSF.Util.HSSFColor;
namespace Aucma.Core.OldBoxFoam.Business
{
public class CollectionFoamMachine
{
private readonly log4net.ILog log = LogManager.GetLogger(typeof(CollectionFoamMachine));
private readonly IBoxLastShotRecordServices? _lastShotRecordServices = App.ServiceProvider.GetService<IBoxLastShotRecordServices>();
public void startCollect()
{
try
{
Task.Run(() =>
{
Thread.Sleep(5000);
while(true)
{
List<BoxLastShotRecord> boxLastShots = new List<BoxLastShotRecord>();
Thread.Sleep(10000);
var obj_1 = PlcHelper.siemensList.FirstOrDefault(d => d.Id == 5);
var obj_2 = PlcHelper.siemensList.FirstOrDefault(d => d.Id == 6);
if (obj_1 != null)
{
#region 1#发泡机参数
byte[] info = obj_1.plc.Read("VD600", 50);
var temp1 = byteToFloat(info.Skip(0).Take(4).ToArray()).ToString("0.00");
var temp2 = byteToFloat(info.Skip(4).Take(4).ToArray()).ToString("0.00");
var temp3 = byteToFloat(info.Skip(20).Take(4).ToArray()).ToString("0.00");
var temp4 = byteToFloat(info.Skip(24).Take(4).ToArray()).ToString("0.00");
byte[] phInfo = obj_1.plc.Read("VD200", 100);
var pressure1 = byteToFloat(phInfo.Skip(0).Take(4).ToArray()).ToString("0.00");
var pressure2 = byteToFloat(phInfo.Skip(20).Take(4).ToArray()).ToString("0.00");
var pressure3 = byteToFloat(phInfo.Skip(40).Take(4).ToArray()).ToString("0.00");
var pressure4 = byteToFloat(phInfo.Skip(60).Take(4).ToArray()).ToString("0.00");
#endregion
boxLastShots.Add(new BoxLastShotRecord()
{
ProductLineCode = "CX_01",
StationNumber = "1105",
System = "1",
SystemStatus = 1,
PolTemp = temp1.ToString(),
IsoTemp = temp3.ToString(),
GunCode = "A1",
PolHp = pressure1.ToString(),
IsoHp = pressure3.ToString(),
CreateTime = DateTime.Now,
});
boxLastShots.Add(new BoxLastShotRecord()
{
ProductLineCode = "CX_01",
StationNumber = "1105",
System = "1",
SystemStatus = 1,
PolTemp = temp1.ToString(),
IsoTemp = temp3.ToString(),
GunCode = "B1",
PolHp = pressure2.ToString(),
IsoHp = pressure4.ToString(),
CreateTime = DateTime.Now,
});
}
if (obj_2 != null)
{
#region 2#发泡机参数
byte[] info = obj_1.plc.Read("VD600", 50);
var temp1 = byteToFloat(info.Skip(0).Take(4).ToArray()).ToString("0.00");
var temp2 = byteToFloat(info.Skip(4).Take(4).ToArray()).ToString("0.00");
var temp3 = byteToFloat(info.Skip(20).Take(4).ToArray()).ToString("0.00");
var temp4 = byteToFloat(info.Skip(24).Take(4).ToArray()).ToString("0.00");
byte[] phInfo = obj_1.plc.Read("VD200", 100);
var pressure1 = byteToFloat(phInfo.Skip(0).Take(4).ToArray()).ToString("0.00");
var pressure2 = byteToFloat(phInfo.Skip(20).Take(4).ToArray()).ToString("0.00");
var pressure3 = byteToFloat(phInfo.Skip(40).Take(4).ToArray()).ToString("0.00");
var pressure4 = byteToFloat(phInfo.Skip(60).Take(4).ToArray()).ToString("0.00");
#endregion
boxLastShots.Add(new BoxLastShotRecord()
{
ProductLineCode = "CX_01",
StationNumber = "1105",
System = "2",
SystemStatus = 1,
PolTemp = temp1.ToString(),
IsoTemp = temp3.ToString(),
GunCode = "A2",
PolHp = pressure1.ToString(),
IsoHp = pressure3.ToString(),
CreateTime = DateTime.Now,
});
boxLastShots.Add(new BoxLastShotRecord()
{
ProductLineCode = "CX_01",
StationNumber = "1105",
System = "2",
SystemStatus = 1,
PolTemp = temp1.ToString(),
IsoTemp = temp3.ToString(),
GunCode = "B2",
PolHp = pressure2.ToString(),
IsoHp = pressure4.ToString(),
CreateTime = DateTime.Now,
});
}
_lastShotRecordServices.AddAsync(boxLastShots);
}
});
}catch(Exception ex)
{
log.Error($"发泡机参数采集异常:{ex.Message}");
}
}
/// <summary>
/// byte数组转换为float
/// </summary>
private float byteToFloat(byte[] list)
{
float result = 0.00f;
Array.Reverse(list);
result = BitConverter.ToSingle(list, 0);
return result;
}
}
}

@ -26,11 +26,11 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
private FoamPlanPageView foamPlanPage = new FoamPlanPageView();
private RealRoadPageView realRoadPage = new RealRoadPageView();
private RoadKindPageView roadKindPage = new RoadKindPageView();
private CollectionFoamMachine collectionFoamMachine = new CollectionFoamMachine();
public MainWindowViewModel()
{
UserContent = oldBoxFoamPage;
// 创建一个DispatcherTimer对象
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
@ -41,6 +41,8 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
{
Init();
});
collectionFoamMachine.startCollect();
}
public Task Init()
@ -107,12 +109,45 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
}
}
}
else
{
PlcUIColor.Clear();
PlcState(false);
PlcState(false);
PlcState(false);
PlcState(false);
}
for(int i = PlcUIColor.Count - 1; i < 6; i++)
var machine = PlcHelper.siemensList.ToList();
if (machine != null)
{
PlcUIColor.Add("Red");
PlcUIIcon.Add("Assets/Images/Red.png");
if (machine.Count > 0)
{
machine = machine.OrderBy(x => x.Id).ToList();
foreach (var item in machine)
{
if (item.plc.IsConnected)
{
PlcState(true);
}
else
{
PlcState(false);
}
}
}
}
else
{
PlcState(false);
PlcState(false);
}
//for(int i = PlcUIColor.Count - 1; i < 6; i++)
//{
// PlcUIColor.Add("Red");
// PlcUIIcon.Add("Assets/Images/Red.png");
//}
#region 原逻辑Delete By wenjy 2024-01-11 17:47:00
//var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));

@ -87,42 +87,42 @@
<ImageBrush x:Name="PlcStatus" ImageSource="{Binding PlcUIIcon[0]}"/>
</Border.Background>
</Border>
<TextBlock x:Name="PLCState" Text="A区发泡线PLC" VerticalAlignment="Center" Foreground="{Binding PlcUIColor[0]}" FontSize="18" Margin="10,0"/>
<TextBlock x:Name="PLCState" Text="A区发泡线" VerticalAlignment="Center" Foreground="{Binding PlcUIColor[0]}" FontSize="18" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush ImageSource="{Binding PlcUIIcon[1]}"/>
</Border.Background>
</Border>
<TextBlock Text="B区发泡线PLC" VerticalAlignment="Center" Foreground="{Binding PlcUIColor[1]}" FontSize="18" Margin="10,0"/>
<TextBlock Text="B区发泡线" VerticalAlignment="Center" Foreground="{Binding PlcUIColor[1]}" FontSize="18" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush ImageSource="{Binding PlcUIIcon[2]}"/>
</Border.Background>
</Border>
<TextBlock Text="C区发泡线PLC" VerticalAlignment="Center" Foreground="{Binding PlcUIColor[2]}" FontSize="18" Margin="10,0"/>
<TextBlock Text="C区发泡线" VerticalAlignment="Center" Foreground="{Binding PlcUIColor[2]}" FontSize="18" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush ImageSource="{Binding PlcUIIcon[3]}"/>
</Border.Background>
</Border>
<TextBlock Text="D区发泡线PLC" VerticalAlignment="Center" Foreground="{Binding PlcUIColor[3]}" FontSize="18" Margin="10,0"/>
<TextBlock Text="D区发泡线" VerticalAlignment="Center" Foreground="{Binding PlcUIColor[3]}" FontSize="18" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush ImageSource="{Binding PlcUIIcon[4]}"/>
</Border.Background>
</Border>
<TextBlock Text="1#发泡机PLC" VerticalAlignment="Center" Foreground="Red" FontSize="18" Margin="10,0"/>
<TextBlock Text="1#发泡机" VerticalAlignment="Center" Foreground="{Binding PlcUIColor[4]}" FontSize="18" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush ImageSource="{Binding PlcUIIcon[5]}"/>
</Border.Background>
</Border>
<TextBlock Text="2#发泡机PLC" VerticalAlignment="Center" Foreground="Red" FontSize="18" Margin="10,0"/>
<TextBlock Text="2#发泡机" VerticalAlignment="Center" Foreground="{Binding PlcUIColor[5]}" FontSize="18" Margin="10,0"/>
<!--<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>

@ -232,6 +232,22 @@
"EquipName": "OldMelsecPlc4",
"IP": "10.10.93.154",
"Port": 5002
},
{
"Id": 5,
"EquipName": "foamLine1Plc_1",
"PlcType": "Siemens",
"Enabled": true,
"IP": "10.10.93.155",
"Port": 102
},
{
"Id": 6,
"EquipName": "foamLine1Plc_2",
"PlcType": "Siemens",
"Enabled": true,
"IP": "10.10.93.156",
"Port": 102
}
],
"IpRateLimiting": {

Loading…
Cancel
Save