|
|
|
@ -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();
|
|
|
|
|