change-门体发泡数据库加载速度优化

dev
liuwf 1 year ago
parent 7861188d02
commit 8ca8957c67

@ -58,6 +58,8 @@ namespace Admin.Core.Repository
/// </summary>
/// <returns></returns>
public bool GetConnectionState()
{
try
{
if (_db.CopyNew().Ado.IsValidConnection())
{
@ -68,7 +70,14 @@ namespace Admin.Core.Repository
{
_db.Close();
_db.Open();
return true;
return false;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return false;
}
}

@ -2,6 +2,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -51,8 +52,13 @@ namespace Aucma.Core.BoxFoam.ViewModels
[RelayCommand]
private void SaveSearchCriteria(Object window)
{
try
{
Console.WriteLine("==================初始配置文件数据"+ appConfig.searchItems);
Console.WriteLine("==================测试数据");
var config = ((Aucma.Core.BoxFoam.ViewModels.SearchCriteriaViewModel)((System.Windows.FrameworkElement)window).DataContext).Configurations;
var info = config.ToList();
Console.WriteLine("========待保存数据" + info.ToJson());
string items = string.Empty;
foreach (var configuration in info)
{
@ -60,9 +66,14 @@ namespace Aucma.Core.BoxFoam.ViewModels
}
appConfig.searchItems = string.Empty;
appConfig.searchItems = items;
Console.WriteLine("==========配置文件数据appConfig.searchItems" + appConfig.searchItems);
Init();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
}
}
#endregion

@ -99,7 +99,7 @@ namespace Aucma.Core.DoorFoam.Business
}
tempKeys.Add(kvPair.Key, record);
}
if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff))
if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff) && !kvPair.Value.MixpistOff.Equals("0"))
{
kvPair.Value.ProductLineCode = "CX_02";
kvPair.Value.StationNumber = "1004";

@ -43,13 +43,15 @@ namespace Aucma.Core.DoorFoam.Business
}
public void startCollect()
{
Task.Run(() =>
{
while (true)
{
//semaphore.WaitOne();
try
{
Thread.Sleep(5000);
Thread.Sleep(2000);
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("DoorPlc"));
@ -93,7 +95,7 @@ namespace Aucma.Core.DoorFoam.Business
GunNumber = moldStatus.GunNumber,
MoldStatus = moldStatus.MoldStatus,
MainId = moldStatus.MainId,
MoldType = moldType.MoldType.Replace("\b","").Replace("\u0001", "").Replace("\0", "").Trim(),
MoldType = moldType.MoldType.Replace("\b", "").Replace("\u0001", "").Replace("\0", "").Trim(),
MoldProdutionA = moldOutPut_A.MoldProdutionA,
MoldProdutionB = moldOutPut_B.MoldProdutionB,
DeviceStatus = deviceStatus,
@ -103,7 +105,7 @@ namespace Aucma.Core.DoorFoam.Business
CreateTime = DateTime.Now
};
result = mergedCollection.ToList();
if(result != null)
if (result != null)
{
RefreshDoorFoamMachineEvent?.Invoke(result);
@ -118,6 +120,8 @@ namespace Aucma.Core.DoorFoam.Business
Console.WriteLine($"门体发泡数据采集异常:{ex.Message}");
}
}
});
}
/// <summary>
/// 读取模位状态

@ -7,7 +7,10 @@ using Admin.Core.Tasks;
using Aucma.Core.DoorFoam.Business;
using Aucma.Core.DoorFoam.Models;
using CommunityToolkit.Mvvm.ComponentModel;
using log4net;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Logging;
using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -20,6 +23,8 @@ namespace Aucma.Core.DoorFoam.ViewModels
public partial class FoamMachinesPageViewModel : ObservableObject
{
IBoxLastShotRecordServices _boxLastShotRecordServices;
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(FoamMachinesPageViewModel));
public FoamMachinesPageViewModel()
{
@ -206,16 +211,21 @@ namespace Aucma.Core.DoorFoam.ViewModels
}
#region 加载DataGrid数据
private async Task LoadData()
private void LoadData()
{
try
{
var list = _boxLastShotRecordServices.QueryAsync(x => x.CreateTime >= System.DateTime.Now.AddDays(-1)).Result.Take(30).OrderByDescending(d => d.CreateTime);
if (list == null) return;
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
LastShotRecordDataGrid.Clear();
int i = 1;
var list = await _boxLastShotRecordServices.QueryAsync();
if (list == null) return;
list.OrderByDescending(d => d.CreateTime).Take(30);
// var list = await _boxLastShotRecordServices.QueryAsync();
// list.OrderByDescending(d => d.CreateTime).Take(30);
foreach (var item in list)
{
string system = string.Empty;
@ -244,6 +254,11 @@ namespace Aucma.Core.DoorFoam.ViewModels
}
}));
}
catch (Exception ex)
{
logHelper.Info(ex.Message.ToString());
}
}
#endregion

@ -40,17 +40,11 @@ namespace Aucma.Core.DoorFoam.ViewModels
RefreshDoorFoamMachineDataGrid(info);
};
Task.Run(() =>
{
Thread.Sleep(1000*10);
doorCollection.startCollect();
});
Task.Run(() =>
{
Thread.Sleep(1000 * 10);
collectionFoam.startCollect();
});
}
#region 获取今天的数据

Loading…
Cancel
Save