liulb@mesnac.com 1 year ago
parent d60a38ab26
commit cdaaa5726e

@ -1401,6 +1401,11 @@
创建时间
</summary>
</member>
<member name="P:Admin.Core.Model.BoxFoamPlan.CompleteAmount">
<summary>
计划完成数量
</summary>
</member>
<member name="T:Admin.Core.Model.BoxLastShotRecord">
<summary>
获取发泡机最后一枪记录

@ -106,7 +106,7 @@ namespace Admin.Core.Tasks
{
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
//把数据保存到记录表中,同时删除实时数据,重新更新数据
List<BoxFoamData> list = await _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == productLineCode);
List<BoxFoamDataRecord> recordList = new List<BoxFoamDataRecord>();
var currentTeamTimeList = await _sysUserInfoServices.GetTeamData();

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>

@ -1,6 +1,7 @@
using Admin.Core.Common.Helper;
using Aucma.Core.HwPLc;
using Aucma.Core.OldBoxFoam.Models;
using NetTaste;
using System;
using System.Collections.Generic;
using System.Linq;
@ -17,7 +18,7 @@ namespace Aucma.Core.OldBoxFoam.Business
public HwPLc.PlcModel plc2 = null;
public HwPLc.PlcModel plc3 = null;
public HwPLc.PlcModel plc4 = null;
public List<FixtureStatus> listFixtureStatus = new List<FixtureStatus>();
public static List<FixtureStatus> listFixtureStatus = new List<FixtureStatus>();
public List<int> BoxTypeList = new List<int>();
public List<int> HolderStatusList = new List<int>();
@ -80,13 +81,15 @@ namespace Aucma.Core.OldBoxFoam.Business
for(int i = 0; i < 24; i++)
{
FixtureStatus model = new FixtureStatus();
model.FixtureBoxType = BoxTypeList[i];
model.Status = HolderStatusList[i];
model.Yield = HolderOutPutList[i];
model.PlanCuringTime = SolidifyTimeList[i];
model.ObjId = i + 1;
if (BoxTypeList.Count>0) model.FixtureBoxType = BoxTypeList[i].ToString();
if (HolderStatusList.Count > 0) model.Status = HolderStatusList[i];
if (HolderOutPutList.Count > 0) model.Yield = HolderOutPutList[i];
if (SolidifyTimeList.Count > 0) model.PlanCuringTime = SolidifyTimeList[i];
listFixtureStatus.Add(model);
}
Thread.Sleep(100000);
Thread.Sleep(10000);
}
});
}
@ -95,7 +98,9 @@ namespace Aucma.Core.OldBoxFoam.Business
/// </summary>
static void ReadBoxType(HwPLc.PlcModel obj, List<int> BoxTypeList)
{
if (obj == null) return;
if (obj.plc.IsConnected)
{
byte[] result = obj.plc.Read("D3140", 48);
byte[] info = result;
int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
@ -112,12 +117,15 @@ namespace Aucma.Core.OldBoxFoam.Business
BoxTypeList.Add(temp6);
Console.WriteLine($"读取夹具箱型,1#:{temp1};2#{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}");
}
}
/// <summary>
/// 读取夹具状态
/// </summary>
static void ReadHolderStatus(PlcModel obj1, List<int> HolderStatusList)
{
if (obj1 == null) return;
if (obj1.plc.IsConnected == false) return;
byte[] result = obj1.plc.Read("YF0", 1);
//输出二进制字符串,1#-3#手动、自动数据
string str1 = ByteArrayToBinary(array(result));
@ -224,6 +232,8 @@ namespace Aucma.Core.OldBoxFoam.Business
/// </summary>
static void ReadHolderOutPut(PlcModel obj,List<int> HolderOutPutList)
{
if (obj==null) return;
if (obj.plc.IsConnected == false) return;
byte[] result = obj.plc.Read("D182", 24);
byte[] info = result;
int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
@ -247,6 +257,8 @@ namespace Aucma.Core.OldBoxFoam.Business
/// </summary>
static void ReadSolidifyTime(PlcModel obj,List<int> SolidifyTimeList)
{
if (obj == null) return;
if (obj.plc.IsConnected == false) return;
byte[] result = obj.plc.Read("D910", 24);
byte[] info = result;
int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
@ -269,6 +281,8 @@ namespace Aucma.Core.OldBoxFoam.Business
/// </summary>
static void ReadStoreType(PlcModel obj)
{
if (obj == null) return;
if (obj.plc.IsConnected == false) return;
//夹具箱型
byte[] result = obj.plc.Read("D2010", 40);
byte[] info = result;
@ -283,6 +297,8 @@ namespace Aucma.Core.OldBoxFoam.Business
/// </summary>
static void ReadStoreAmount(PlcModel obj)
{
if (obj == null) return;
if (obj.plc.IsConnected == false) return;
byte[] result = obj.plc.Read("L101", 1);
string str1 = ByteArrayToBinary(array(result)).Substring(0, 3);
int item1 = Regex.Matches(str1, "1").Count;

@ -12,10 +12,11 @@ namespace Aucma.Core.OldBoxFoam.Models
/// </summary>
public class FixtureStatus
{
public int ObjId { get; set; }
/// <summary>
/// 夹具箱型
/// </summary>
public int FixtureBoxType { get; set; }
public string FixtureBoxType { get; set; }
/// <summary>
/// 夹具状态
/// </summary>

@ -1,9 +1,12 @@
using Admin.Core.IService;
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 Admin.Core.Tasks;
using Aucma.Core.HwPLc;
using Aucma.Core.OldBoxFoam.Business;
using Aucma.Core.OldBoxFoam.Models;
using Aucma.Core.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
@ -30,26 +33,28 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
public static System.Threading.Timer GetStoreTimer;
private readonly IBoxFoamPlanServices _boxFoamPlanServices;
private readonly ISysUserInfoServices _sysUserInfoServices;
private readonly ICurrentTeamTimeServices _currentTeamTimeServices;
private readonly IBoxFoamDataRecordServices _boxFoamDataRecordServices;
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OldBoxFoamPageViewModel));
System.Timers.Timer timer1 = new System.Timers.Timer(2000);
System.Timers.Timer timer2 = new System.Timers.Timer(2000);
System.Timers.Timer timer2 = new System.Timers.Timer(10000);
public OldBoxFoamPageViewModel() {
_oldBoxFoamDataServices = App.ServiceProvider.GetService<IBoxFoamDataServices>();
_oldBoxFoamTypeServices = App.ServiceProvider.GetService<IOldBoxFoamTypeServices>();
_boxFoamPlanServices = App.ServiceProvider.GetService<IBoxFoamPlanServices>();
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
//Job_OldBoxFoam_Quartz.RefreshOldBoxFoamTypeDataDelegateEvent += OldBoxFoamTypeOnLoad3;
AucamTaskService.RefreshOldBoxFoamDataDelegateEvent += OldBoxFoamOnLoad3;
//GetStoreTimer = new System.Threading.Timer(OldBoxFoamOnLoad, null, 0, Timeout.Infinite);
//Task.WaitAll(OldBoxFoamOnLoad());
_currentTeamTimeServices = App.ServiceProvider.GetService<ICurrentTeamTimeServices>();
_currentTeamTimeServices = App.ServiceProvider.GetService<ICurrentTeamTimeServices>();
_boxFoamDataRecordServices = App.ServiceProvider.GetService<IBoxFoamDataRecordServices>();
//AucamTaskService.RefreshOldBoxFoamDataDelegateEvent += OldBoxFoamOnLoad3;
timer1.Elapsed += new System.Timers.ElapsedEventHandler(OldBoxFoamOnLoad); //到达时间的时候执行事件;
timer1.AutoReset = true;//设置是执行一次false还是一直执行(true)
timer1.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
timer1.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
timer2.Elapsed += new System.Timers.ElapsedEventHandler(OldBoxFoamOnLoad); //到达时间的时候执行事件;
timer2.Elapsed += new System.Timers.ElapsedEventHandler(RealTimeFoamingTask); //到达时间的时候执行事件;
timer2.AutoReset = true;//设置是执行一次false还是一直执行(true)
timer2.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它
timer2.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
@ -65,33 +70,35 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
_production.Clear();
_beat.Clear();
_statusColor.Clear();
List<BoxFoamData> list = _oldBoxFoamDataServices.QueryAsync().Result;
if (list == null) return;
if (Collection.listFixtureStatus == null) return;
int i = 0;
var prderList= list.OrderBy(d=>d.MainId);
var prderList= Collection.listFixtureStatus;
int num = prderList.Sum(d => d.Yield);
Console.WriteLine($"总产量{prderList.Sum(d => d.Yield)}");
_totle = $"总产量:{num}";
foreach (var item in prderList)
{
OldBoxFoamDataModel model = new OldBoxFoamDataModel();
model.ObjId = item.ObjId;
model.Fixtureboxtype = item.Fixtureboxtype;
model.Fixturestatus = item.Fixturestatus;
model.Production = item.Production;
model.CuringTimeSettingValue = item.CuringTimeSettingValue;
if (item.Fixturestatus == 1)//停止
//OldBoxFoamDataModel model = new OldBoxFoamDataModel();
//model.ObjId = item.ObjId;
//model.Fixtureboxtype = item.FixtureBoxType;
//model.Fixturestatus = item.Status;
//model.Production = item.Yield;
//model.CuringTimeSettingValue = item.PlanCuringTime.ToString();
if (item.Status == 1)//生产
{
_statusColor.Add("green");
}
else
{
_statusColor.Add("red");
}
_fixtureName.Add(item.Fixtureboxtype);
_production.Add(item.Production);
_beat.Add(item.BoxBeat);
i = +item.Production;
_fixtureName.Add(item.FixtureBoxType);
_production.Add(item.Yield);
//_beat.Add(item.BoxBeat);
i = +item.Yield;
}
_totle = list.Sum(d => d.Production);
_totle = $"总产量:{i}";
}
catch (Exception ex)
{
@ -109,7 +116,6 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
{
try
{
// List<BoxFoamData> list = await _oldBoxFoamDataServices.QueryAsync();
if (list == null) return;
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
{
@ -253,8 +259,8 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
#endregion
#region 总计
private int _totle = 0;
public int Totle
private string _totle;
public string Totle
{
get => _totle;
set => SetProperty(ref _totle, value);
@ -263,25 +269,218 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
/// <summary>
/// 将采集到的数据梳理
/// 将采集到的数据保存
/// </summary>
/// <param name="mode"></param>
public async void RealTimeFoamingTask(object? sender, ElapsedEventArgs e)
{
var list = _boxFoamPlanServices.QueryAsync().Result;
//根据夹具找箱型找货道,根据货道找物料
var spaceList=await _oldBoxFoamTypeServices.QueryAsync(d=>d.Boxtype== mode);
if (spaceList.Count>0)
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
if (Collection.listFixtureStatus == null) return;
DateTime now = DateTime.Now;
CurrentTeamTime time = await _currentTeamTimeServices.FirstAsync(d => d.StartTime <= now && d.EndTime >= now);
if (time != null)
{
ExecHourData(productLineCode);
}
else
{
ShiftChange(productLineCode);
}
}
private async void ShiftChange(string productLineCode)
{
//切换班组计划
var list = await _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == productLineCode);
List<BoxFoamDataRecord> recordList = new List<BoxFoamDataRecord>();
var currentTeamTimeList = await _sysUserInfoServices.GetTeamData();
if (currentTeamTimeList.Count == 0) return;
//更新计划表操作
CurrentTeamTime currentTeamTime = await _currentTeamTimeServices.FirstAsync();
currentTeamTime.TeamName = currentTeamTimeList.FirstOrDefault().TeamName;
currentTeamTime.StartTime = currentTeamTimeList.Min(d => d.StartTime);
currentTeamTime.EndTime = currentTeamTimeList.Max(d => d.EndTime);
await _currentTeamTimeServices.UpdateAsync(currentTeamTime);
//可以使用Mapping 映射
list.ForEach(d =>
{
BoxFoamDataRecord record = new BoxFoamDataRecord();
record.OrderCode = d.OrderCode;
record.ProductLineCode = d.ProductLineCode;
record.Fixturestatus = d.Production;
record.CuringTimeSettingValue = d.CuringTimeSettingValue;
record.ActualValue = d.ActualValue;
record.AnHour = d.AnHour;
record.TwoHour = d.TwoHour;
record.ThreeHour = d.ThreeHour;
record.FourHour = d.FourHour;
record.FiveHour = d.FiveHour;
record.SixHour = d.SixHour;
record.SevenHour = d.SevenHour;
record.EightHour = d.EightHour;
record.NineHour = d.NineHour;
record.TenHour = d.TenHour;
record.ElevenHour = d.ElevenHour;
record.TwelveHour = d.TwelveHour;
record.BoxFixturesideplate = d.BoxFixturesideplate;
record.BoxClosebetatemperature = d.BoxClosebetatemperature;
record.BoxBeat = d.BoxBeat;
record.CreateTime = DateTime.Now;
});
int result = await _boxFoamDataRecordServices.AddAsync(recordList);
if (result > 0)
{
var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));
if (obj2 == null) { return; }
//obj2.plc.WriteInt16("M216", "1");//换班 数据清空
//清空 当班计划
await _oldBoxFoamDataServices.DeletesAsync(list);
}
}
private async void ExecHourData(string productLineCode)
{
var boxList = Collection.listFixtureStatus;
foreach (var item in boxList)
{
OldBoxFoamType type= spaceList.FirstOrDefault();
BoxFoamPlan plan= list.FirstOrDefault(d=>d.MaterialCode== type.MaterialCode);
if (plan!=null)
OldBoxFoamType space = await _oldBoxFoamTypeServices.FirstAsync(d => d.Boxtype == item.FixtureBoxType);
//根据夹具找货道,根据货道找物料
if (space != null)
{
BoxFoamPlan plan = _boxFoamPlanServices.FirstAsync(d => d.MaterialCode == space.MaterialCode).Result;
if (plan != null)
{
plan.CompleteAmount = plan.CompleteAmount + 1;
await _boxFoamPlanServices.UpdateAsync(plan);
//更新小时数据
BoxFoamData bfd = await _oldBoxFoamDataServices.FirstAsync(d => d.Fixtureboxtype == item.FixtureBoxType && d.MainId == item.ObjId);
if (bfd != null)
{
UpdateBoxData(item, bfd);
}
else
{
SaveBoxData(productLineCode, item);
}
}
else
{
//更新小时数据
BoxFoamData bfd = await _oldBoxFoamDataServices.FirstAsync(d => d.Fixtureboxtype == item.FixtureBoxType && d.MainId == item.ObjId);
if (bfd != null)
{
UpdateBoxData(item, bfd);
}
else
{
SaveBoxData(productLineCode, item);
}
}
}
}
}
_boxFoamPlanServices.UpdateAsync(plan);
private async void UpdateBoxData(FixtureStatus item, BoxFoamData bfd)
{
bfd.Production = item.Yield;
switch (GetTeamHour().Seq)
{
case 1:
bfd.AnHour = item.Yield = bfd.Production;
break;
case 2:
bfd.TwoHour = item.Yield = bfd.Production;
break;
case 3:
bfd.ThreeHour = item.Yield = bfd.Production;
break;
case 4:
bfd.FourHour = item.Yield = bfd.Production;
break;
case 5:
bfd.FiveHour = item.Yield = bfd.Production;
break;
case 6:
bfd.SixHour = item.Yield = bfd.Production;
break;
case 7:
bfd.SevenHour = item.Yield = bfd.Production;
break;
case 8:
bfd.EightHour = item.Yield = bfd.Production;
break;
case 9:
bfd.NineHour = item.Yield = bfd.Production;
break;
case 10:
bfd.TenHour = item.Yield = bfd.Production;
break;
case 11:
bfd.ElevenHour = item.Yield = bfd.Production;
break;
case 12:
bfd.TwelveHour = item.Yield = bfd.Production;
break;
default:
break;
}
await _oldBoxFoamDataServices.UpdateAsync(bfd);
}
private async void SaveBoxData(string productLineCode, FixtureStatus item)
{
BoxFoamData bfdata = new BoxFoamData();
bfdata.MainId = item.ObjId;
bfdata.ProductLineCode = productLineCode;
bfdata.Fixtureboxtype = item.FixtureBoxType;
bfdata.Fixturestatus = item.Status;
bfdata.Production = item.Yield;
bfdata.CuringTimeSettingValue = item.PlanCuringTime.ToString();
bfdata.ActualValue = item.RealCuringTime.ToString();
switch (GetTeamHour().Seq)
{
case 1:
bfdata.AnHour = item.Yield = bfdata.Production;
break;
case 2:
bfdata.TwoHour = item.Yield = bfdata.Production;
break;
case 3:
bfdata.ThreeHour = item.Yield = bfdata.Production;
break;
case 4:
bfdata.FourHour = item.Yield = bfdata.Production;
break;
case 5:
bfdata.FiveHour = item.Yield = bfdata.Production;
break;
case 6:
bfdata.SixHour = item.Yield = bfdata.Production;
break;
case 7:
bfdata.SevenHour = item.Yield = bfdata.Production;
break;
case 8:
bfdata.EightHour = item.Yield = bfdata.Production;
break;
case 9:
bfdata.NineHour = item.Yield = bfdata.Production;
break;
case 10:
bfdata.TenHour = item.Yield = bfdata.Production;
break;
case 11:
bfdata.ElevenHour = item.Yield = bfdata.Production;
break;
case 12:
bfdata.TwelveHour = item.Yield = bfdata.Production;
break;
default:
break;
}
bfdata.MainId = item.ObjId;
await _oldBoxFoamDataServices.AddAsync(bfdata);
}
public CurrentTeamTimeView GetTeamHour()

@ -35,6 +35,8 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
public async void InitData()
{
List<OldBoxFoamType> list = await _oldBoxFoamTypeServices.QueryAsync();
if (list == null) return;
foreach (OldBoxFoamType item in list)
{
ListItems.Add(new OldBoxFoamTypeModel()

@ -33,6 +33,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
public async void InitData()
{
List<OldBoxFoamType> list = await _boxFoamTypeServices.QueryAsync();
if (list == null) return;
foreach(OldBoxFoamType item in list)
{
OldBoxFoamTypeModel model= new OldBoxFoamTypeModel();

@ -253,22 +253,22 @@
<TextBlock Text="{Binding Production[5]}" Foreground="White" FontSize="18" FontWeight="Bold"/>
</Border>
<Border Grid.Row="8" Grid.Column="3" >
<TextBlock Text="{Binding FixtureName[6]}" Foreground="White" FontSize="18"/>
<TextBlock Text="{Binding Production[6]}" Foreground="White" FontSize="18"/>
</Border>
<Border Grid.Row="9" Grid.Column="3">
<TextBlock Text="{Binding FixtureName[7]}" Foreground="White" FontSize="18"/>
<TextBlock Text="{Binding Production[7]}" Foreground="White" FontSize="18"/>
</Border>
<Border Grid.Row="10" Grid.Column="3">
<TextBlock Text="{Binding FixtureName[8]}" Foreground="White" FontSize="18"/>
<TextBlock Text="{Binding Production[8]}" Foreground="White" FontSize="18"/>
</Border>
<Border Grid.Row="11" Grid.Column="3">
<TextBlock Text="{Binding FixtureName[9]}" Foreground="White" FontSize="18"/>
<TextBlock Text="{Binding Production[9]}" Foreground="White" FontSize="18"/>
</Border>
<Border Grid.Row="12" Grid.Column="3">
<TextBlock Text="{Binding FixtureName[10]}" Foreground="White" FontSize="18"/>
<TextBlock Text="{Binding Production[10]}" Foreground="White" FontSize="18"/>
</Border>
<Border Grid.Row="13" Grid.Column="3">
<TextBlock Text="{Binding FixtureName[11]}" Foreground="White" FontSize="18"/>
<TextBlock Text="{Binding Production[11]}" Foreground="White" FontSize="18"/>
</Border>
<Border Grid.Row="0" Grid.Column="4" Grid.ColumnSpan="2" >
<TextBlock Text="{Binding Totle,Mode=TwoWay}" Foreground="White" FontSize="30" FontWeight="Bold"/>

@ -53,25 +53,25 @@ namespace Aucma.Core.Tasks
public void AucamTaskAsync()
{
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;
timer2.Elapsed += new System.Timers.ElapsedEventHandler(Run2); //到达时间的时候执行事件;
timer2.AutoReset = true;
timer2.Enabled = true;
timer2.Start();
timer3.Elapsed += new System.Timers.ElapsedEventHandler(Run3);
timer3.AutoReset = true;
timer3.Enabled = true;
timer3.Start();
timer4.Elapsed += new System.Timers.ElapsedEventHandler(Run4);
timer4.AutoReset = true;
timer4.Enabled = true;
timer4.Start();
//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;
//timer2.Elapsed += new System.Timers.ElapsedEventHandler(Run2); //到达时间的时候执行事件;
//timer2.AutoReset = true;
//timer2.Enabled = true;
//timer2.Start();
//timer3.Elapsed += new System.Timers.ElapsedEventHandler(Run3);
//timer3.AutoReset = true;
//timer3.Enabled = true;
//timer3.Start();
//timer4.Elapsed += new System.Timers.ElapsedEventHandler(Run4);
//timer4.AutoReset = true;
//timer4.Enabled = true;
//timer4.Start();
}

Loading…
Cancel
Save