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.Models;
using Aucma.Core.BoxFoam.ViewModels; using Aucma.Core.BoxFoam.ViewModels;
using Aucma.Core.HwPLc; using Aucma.Core.HwPLc;
using Microsoft.Extensions.DependencyInjection;
using NetTaste; using NetTaste;
using NPOI.Util; using NPOI.Util;
using System; using System;
@ -50,6 +50,10 @@ namespace Aucma.Core.BoxFoam.Business
// 系统参数 // 系统参数
Dictionary<string, FoamMachinesModel> systemKeys = new Dictionary<string, FoamMachinesModel>(); Dictionary<string, FoamMachinesModel> systemKeys = new Dictionary<string, FoamMachinesModel>();
Semaphore semaphore = new Semaphore(1, 1); Semaphore semaphore = new Semaphore(1, 1);
private readonly IBoxLastShotRecordServices? _lastShotRecordServices = App.ServiceProvider.GetService<IBoxLastShotRecordServices>();
public CollectionFoamMachine() public CollectionFoamMachine()
{ {
startCollect(); startCollect();
@ -77,19 +81,29 @@ namespace Aucma.Core.BoxFoam.Business
ReadGunData(obj, "DB50.1460", gunKeys,"B2"); //A2枪数据 ReadGunData(obj, "DB50.1460", gunKeys,"B2"); //A2枪数据
RefreshSystemDataDelegateEvent?.Invoke(systemKeys); RefreshSystemDataDelegateEvent?.Invoke(systemKeys);
RefreshGunDataDelegateEvent?.Invoke(gunKeys); RefreshGunDataDelegateEvent?.Invoke(gunKeys);
foreach (KeyValuePair<string, BoxLastShotRecord> kvPair in gunKeys) foreach (KeyValuePair<string, BoxLastShotRecord> kvPair in gunKeys)
{ {
//程序启动缓存没数据查数据库
if (!tempKeys.ContainsKey(kvPair.Key)) 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); RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value);
continue;
}
tempKeys.Add(kvPair.Key, record);
} }
// 关枪时间不同 if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff))
else if(!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff))
{ {
int b=_lastShotRecordServices.AddAsync(kvPair.Value).Result;
RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value); RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value);
} }
} }
} }
@ -190,7 +204,7 @@ namespace Aucma.Core.BoxFoam.Business
BoxLastShotRecord lastShotRecord = new BoxLastShotRecord(); BoxLastShotRecord lastShotRecord = new BoxLastShotRecord();
lastShotRecord.System = gunCode.Substring(1, 1); lastShotRecord.System = gunCode.Substring(1, 1);
lastShotRecord.GunCode = gunCode; lastShotRecord.GunCode = gunCode;
lastShotRecord.ProductLineCode = ""; lastShotRecord.ProductLineCode = "CX_02";
lastShotRecord.PolTemp = byteToFloat(info.Skip(0).Take(4).ToArray()).ToString(); lastShotRecord.PolTemp = byteToFloat(info.Skip(0).Take(4).ToArray()).ToString();
lastShotRecord.PolHp = byteToFloat(info.Skip(4).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.RefreshGunDataDelegateEvent += RefreshGunData;
CollectionFoamMachine.RefreshSystemDataDelegateEvent += RefreshSystemData; CollectionFoamMachine.RefreshSystemDataDelegateEvent += RefreshSystemData;
_boxLastShotRecordServices = App.ServiceProvider.GetService<IBoxLastShotRecordServices>(); _boxLastShotRecordServices = App.ServiceProvider.GetService<IBoxLastShotRecordServices>();
LoadData();
//Task.WaitAll(LoadData()); //Task.WaitAll(LoadData());
} }
@ -215,7 +215,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
int i = 1; int i = 1;
var list = await _boxLastShotRecordServices.QueryAsync(); var list = await _boxLastShotRecordServices.QueryAsync();
if (list == null) return; if (list == null) return;
list.OrderByDescending(d => d.CreateTime).Take(50); list.OrderByDescending(d => d.CreateTime).Take(30);
foreach (var item in list) foreach (var item in list)
{ {
string system = string.Empty; string system = string.Empty;
@ -239,6 +239,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
model.IsoInjectiontemperature = item.IsoTemp; model.IsoInjectiontemperature = item.IsoTemp;
model.LastTime = item.CreateTime; model.LastTime = item.CreateTime;
model.Createtime = item.CreateTime; model.Createtime = item.CreateTime;
model.StationNumber = item.PourNu;
LastShotRecordDataGrid.Insert(0,model); LastShotRecordDataGrid.Insert(0,model);
} }
})); }));

Loading…
Cancel
Save