You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.9 KiB
C#
73 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Threading;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Sln.Wcs.Model.Domain;
|
|
using SqlSugar;
|
|
|
|
namespace Sln_Wpf.Page
|
|
{
|
|
/// <summary>
|
|
/// MainPage.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class MainPage : UserControl
|
|
{
|
|
private ISqlSugarClient? sqlSugarClient;
|
|
public MainPage()
|
|
{
|
|
InitializeComponent();
|
|
sqlSugarClient = App.ServiceProvider.GetService<ISqlSugarClient>();
|
|
sqlSugarClient.AsTenant().ChangeDatabase("wcs");
|
|
LoadStatistics();
|
|
DispatcherTimer timer = new DispatcherTimer();
|
|
timer.Interval = TimeSpan.FromSeconds(10);
|
|
timer.Tick += ReloadData;
|
|
timer.Start();
|
|
}
|
|
|
|
private void ReloadData(object sender, EventArgs e)
|
|
{
|
|
LoadStatistics();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载统计数据
|
|
/// </summary>
|
|
private void LoadStatistics()
|
|
{
|
|
#region 设备连接状态
|
|
List<BaseEquipInfo> agvEquipStatus = sqlSugarClient.Queryable<BaseEquipInfo>().Where(x => x.EquipType == 1).ToList();
|
|
List<BaseEquipInfo> elevatorEquipStatus = sqlSugarClient.Queryable<BaseEquipInfo>().Where(x => x.EquipType == 2).ToList();
|
|
ElevatorConnectedFlag.Text = "在线:"+$"{elevatorEquipStatus.Where(x => x.UseFlag == 1).Count()}" + "台,离线:"+$"{elevatorEquipStatus.Where(x => x.UseFlag == 0).Count()}" +"台";
|
|
AgvConnectedFlag.Text = "在线:"+$"{ agvEquipStatus.Where(x => x.UseFlag == 1).Count()}" + "台,离线:"+$"{ agvEquipStatus.Where(x => x.UseFlag == 0).Count()}" +"台";
|
|
#endregion
|
|
|
|
#region 库位储藏状态
|
|
List<BaseLocation> locations = sqlSugarClient.Queryable<BaseLocation>().ToList();
|
|
TotalStorageSpace.Text = locations.Count().ToString();
|
|
StorageSpaceUsage.Text = "已用库位:"+$"{locations.Where(x => x.ContainerCode != null).Count()}|空闲"+$"{locations.Where(x => x.ContainerCode == null).Count()}";
|
|
StorageSpaceUsageBar.Value = (int)((double)locations.Where(x => x.ContainerCode != null).Count() / locations.Count() * 100);
|
|
StorageSpaceUsageText.Text = $"库容使用率{StorageSpaceUsageBar.Value}%";
|
|
#endregion
|
|
|
|
#region 任务状态
|
|
List<WcsTaskInstance> taskList = sqlSugarClient.Queryable<WcsTaskInstance>().ToList();
|
|
TaskCountText.Text = taskList.Count().ToString();
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
}
|