dev
liuwf 1 year ago
parent 99e4752e98
commit 04237b6b7c

@ -4,7 +4,7 @@ using Admin.Core.Model;
using Aucma.Core.BoxFoam.Models;
using Aucma.Core.BoxFoam.ViewModels;
using Aucma.Core.HwPLc;
using Microsoft.Extensions.DependencyInjection;
using NetTaste;
using NPOI.Util;
using System;
@ -50,6 +50,10 @@ namespace Aucma.Core.BoxFoam.Business
// 系统参数
Dictionary<string, FoamMachinesModel> systemKeys = new Dictionary<string, FoamMachinesModel>();
Semaphore semaphore = new Semaphore(1, 1);
private readonly IBoxLastShotRecordServices? _lastShotRecordServices = App.ServiceProvider.GetService<IBoxLastShotRecordServices>();
public CollectionFoamMachine()
{
startCollect();
@ -77,19 +81,29 @@ namespace Aucma.Core.BoxFoam.Business
ReadGunData(obj, "DB50.1460", gunKeys,"B2"); //A2枪数据
RefreshSystemDataDelegateEvent?.Invoke(systemKeys);
RefreshGunDataDelegateEvent?.Invoke(gunKeys);
foreach (KeyValuePair<string, BoxLastShotRecord> kvPair in gunKeys)
{
//程序启动缓存没数据查数据库
if (!tempKeys.ContainsKey(kvPair.Key))
{
{
BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System == kvPair.Value.System && x.ProductLineCode == kvPair.Value.ProductLineCode && x.GunCode == kvPair.Value.GunCode).OrderByDescending(x => x.CreateTime).FirstOrDefault();
if (record == null) {
// 数据库也没数据
int a = _lastShotRecordServices.AddAsync(kvPair.Value).Result;
RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value);
continue;
}
tempKeys.Add(kvPair.Key, record);
}
// 关枪时间不同
else if(!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff))
if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff))
{
int b=_lastShotRecordServices.AddAsync(kvPair.Value).Result;
RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value);
}
}
}
@ -190,7 +204,7 @@ namespace Aucma.Core.BoxFoam.Business
BoxLastShotRecord lastShotRecord = new BoxLastShotRecord();
lastShotRecord.System = gunCode.Substring(1, 1);
lastShotRecord.GunCode = gunCode;
lastShotRecord.ProductLineCode = "";
lastShotRecord.ProductLineCode = "CX_02";
lastShotRecord.PolTemp = byteToFloat(info.Skip(0).Take(4).ToArray()).ToString();
lastShotRecord.PolHp = byteToFloat(info.Skip(4).Take(4).ToArray()).ToString();

@ -27,7 +27,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
CollectionFoamMachine.RefreshGunDataDelegateEvent += RefreshGunData;
CollectionFoamMachine.RefreshSystemDataDelegateEvent += RefreshSystemData;
_boxLastShotRecordServices = App.ServiceProvider.GetService<IBoxLastShotRecordServices>();
LoadData();
//Task.WaitAll(LoadData());
}
@ -215,7 +215,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
int i = 1;
var list = await _boxLastShotRecordServices.QueryAsync();
if (list == null) return;
list.OrderByDescending(d => d.CreateTime).Take(50);
list.OrderByDescending(d => d.CreateTime).Take(30);
foreach (var item in list)
{
string system = string.Empty;
@ -239,6 +239,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
model.IsoInjectiontemperature = item.IsoTemp;
model.LastTime = item.CreateTime;
model.Createtime = item.CreateTime;
model.StationNumber = item.PourNu;
LastShotRecordDataGrid.Insert(0,model);
}
}));

Loading…
Cancel
Save