liuwf 2 months ago
parent 352ef10b60
commit d4d39038eb

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SlnMesnac.WPF.Model
{
public class DmsShutDownModel
{
/// <summary>
/// 序号
/// </summary>
public int id { get; set; }
/// <summary>
/// 设备名
/// </summary>
public string deviceName { get; set; }
/// <summary>
/// 停机类型
/// </summary>
public string shutReason { get; set; }
/// <summary>
/// 停机开始时间
/// </summary>
public string shutBeginTime { get; set; } = "";
/// <summary>
/// 停机结束时间
/// </summary>
public string shutEndTime { get; set; } = "";
/// <summary>
/// 停机总时长单位min
/// </summary>
public string totalTime { get; set; } = "";
}
}

@ -32,7 +32,7 @@
<TextBlock Visibility="Collapsed" x:Name="BagsAmountTxt" Text="0" Width="80" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
<Button Visibility="Collapsed" x:Name="AmountChangeButton" Style="{StaticResource BUTTON_AGREE}" Content="数量调整" FontSize="30" Background="CadetBlue" Width="180" Height="60" Margin="0 0 20 0" HorizontalAlignment="Left" Click="AmountChangeButton_Click"/>
<Button x:Name="MachineStopHistoryButton" Content="停机记录历史" FontSize="25" Foreground="White" Background="CadetBlue" Width="200" Height="60" Margin="300 0 20 0" HorizontalAlignment="Left"/>
<Button x:Name="MachineStopHistoryButton" Content="停机记录历史" FontSize="25" Foreground="White" Background="CadetBlue" Width="200" Height="60" Margin="300 0 20 0" HorizontalAlignment="Left" Click="MachineStopHistoryButton_Click"/>
</StackPanel>
</Grid>

@ -10,6 +10,7 @@ using SlnMesnac.Repository.service;
using SlnMesnac.WPF.Dto;
using SlnMesnac.WPF.MessageTips;
using SlnMesnac.WPF.Model;
using SlnMesnac.WPF.Page.WindowPage;
using SlnMesnac.WPF.ViewModel;
using SqlSugar;
using System;
@ -2524,5 +2525,12 @@ namespace SlnMesnac.WPF.Page
});
}
private void MachineStopHistoryButton_Click(object sender, RoutedEventArgs e)
{
MachineStopHistoryWindow window = new MachineStopHistoryWindow();
window.ShowDialog();
}
}
}

@ -0,0 +1,76 @@
<Window x:Class="SlnMesnac.WPF.Page.WindowPage.MachineStopHistoryWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SlnMesnac.WPF.Page.WindowPage"
mc:Ignorable="d"
Title="MachineStopHistoryWindow" Height="500" Width="1000" Background="#1254AB" StateChanged="Window_StateChanged">
<Window.Resources>
<!-- 定义样式 -->
<Style x:Key="CustomDatePicker" TargetType="DatePicker">
<!-- 设置背景颜色 -->
<Setter Property="Background" Value="LightBlue"></Setter>
<!-- 设置边框颜色 -->
<Setter Property="BorderBrush" Value="DarkBlue"></Setter>
<!-- 设置字体样式 -->
<Setter Property="FontSize" Value="20"></Setter>
<!-- 设置前景色(文本颜色) -->
<Setter Property="Foreground" Value="Black"></Setter>
</Style>
<!-- 定义日历的样式 -->
<Style x:Key="CustomCalendarStyle" TargetType="Calendar">
<!-- 设置背景颜色 -->
<Setter Property="Background" Value="White"></Setter>
<!-- 设置边框颜色 -->
<Setter Property="BorderBrush" Value="Blue"></Setter>
<Setter Property="Width" Value="350"></Setter>
<Setter Property="Height" Value="250"></Setter>
<!-- 设置字体样式 -->
<Setter Property="FontSize" Value="16"></Setter>
</Style>
</Window.Resources>
<Grid Margin="5,5" >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<Border Grid.Row="1" Grid.Column="0" BorderBrush="Green" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<DataGrid Grid.Row="0" ItemsSource="{Binding DmsShutDownModelDataGrid}" Background="Transparent"
FontSize="20" ColumnHeaderHeight="35"
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Visible" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="White" >
<DataGrid.Resources>
<!-- 定制 ScrollBar 样式 -->
<Style TargetType="ScrollBar">
<Setter Property="Background" Value="Transparent"/>
</Style>
</DataGrid.Resources>
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<!--<DataGridTextColumn Binding="{Binding RawOutstockDetailId}" Header="序号" Width="1*" IsReadOnly="True"/>-->
<DataGridTextColumn Binding="{Binding id}" Header="序号" Width="*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding deviceName}" Header="设备名" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding shutReason}" Header="停机类型" Width="4*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding shutBeginTime ,StringFormat=\{0:MM月dd日 HH:mm:ss\}}" Header="停机开始时间" Width="4*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding shutEndTime ,StringFormat=\{0:MM月dd日 HH:mm:ss\}}" Header="停机结束时间" Width="4*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding totalTime ,StringFormat=\{0:MM月dd日 HH:mm:ss\}}" Header="停机总时长(min)" Width="2*" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
</Border>
</Grid>
</Grid>
</Window>

@ -0,0 +1,39 @@
using SlnMesnac.WPF.ViewModel;
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.Shapes;
namespace SlnMesnac.WPF.Page.WindowPage
{
/// <summary>
/// MachineStopHistoryWindow.xaml 的交互逻辑
/// </summary>
public partial class MachineStopHistoryWindow : Window
{
public MachineStopHistoryWindow()
{
InitializeComponent();
MachineStopHistoryViewModel vm = new MachineStopHistoryViewModel();
this.DataContext = vm;
}
private void Window_StateChanged(object sender, EventArgs e)
{
if (this.WindowState == WindowState.Minimized)
{
this.Close(); // 当窗口最小化时关闭窗口
}
}
}
}

@ -52,16 +52,16 @@
<Compile Update="Page\AgvAndTaskMonitorPage.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Page\Window\InputDialogWindow.xaml.cs">
<Compile Update="Page\WindowPage\InputDialogWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Page\Window\RecipeModeSetWindow.xaml.cs">
<Compile Update="Page\WindowPage\RecipeModeSetWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Page\Window\RecipeManageSetWindow.xaml.cs">
<Compile Update="Page\WindowPage\RecipeManageSetWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Page\Window\BagsAmountSetWindow.xaml.cs">
<Compile Update="Page\WindowPage\BagsAmountSetWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>

@ -0,0 +1,128 @@
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Business;
using SlnMesnac.Model.domain;
using SlnMesnac.Model.dto;
using SlnMesnac.WPF.MessageTips;
using SlnMesnac.WPF.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.WPF.ViewModel
* 14008fcc-0a31-4f1e-bc80-9f9ea84d3de5
*
* WenJY
* wenjy@mesnac.com
* 2024-04-10 16:18:57
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.ViewModel
{
/// <summary>
/// 生产统计ViewModel
/// </summary>
internal class MachineStopHistoryViewModel : ViewModelBase
{
private readonly ISqlSugarClient? sqlSugarClient;
private Dictionary<int,string> machineNameDic = new Dictionary<int, string>();
public MachineStopHistoryViewModel()
{
sqlSugarClient = App.ServiceProvider.GetService<ISqlSugarClient>();
InitList();
}
private async void InitList()
{
machineNameDic.Add(1016, "3楼拆包机");
machineNameDic.Add(1017, "2楼磁选机");
machineNameDic.Add(1018, "2楼螺旋机");
machineNameDic.Add(1019, "2楼烘干机");
machineNameDic.Add(1020, "2楼除尘机");
machineNameDic.Add(1021, "2楼喷码机");
await RefreshWcsTaskDataGrid();
}
#region 参数定义
/// <summary>
/// 停机记录DataGrid
/// </summary>
private ObservableCollection<DmsShutDownModel> dmsShutDownModelDataGrid = new ObservableCollection<DmsShutDownModel>();
public ObservableCollection<DmsShutDownModel> DmsShutDownModelDataGrid
{
get { return dmsShutDownModelDataGrid; }
set { dmsShutDownModelDataGrid = value; RaisePropertyChanged(() => DmsShutDownModelDataGrid); }
}
#endregion
/// <summary>
/// 刷新停机记录信息
/// </summary>
/// <param name="palletTasks"></param>
private async Task RefreshWcsTaskDataGrid(int pageNumber=1,int pageSize=20)
{
try
{
List<int> deviceIds = new List<int> { 1016, 1017, 1018, 1019, 1020, 1021 };
List<DmsRecordShutDown> list = await sqlSugarClient.AsTenant().GetConnection("mes").Queryable<DmsRecordShutDown>().Where(x=>deviceIds.Contains(x.DeviceId)).OrderByDescending(x=>x.ShutBeginTime).ToPageListAsync(pageNumber,pageSize);
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
dmsShutDownModelDataGrid.Clear();
int startId = (pageNumber-1)*pageSize+1;
foreach (var item in list)
{
DmsShutDownModel model = new DmsShutDownModel();
model.id = startId++;
model.deviceName = machineNameDic[item.DeviceId];
model.shutReason = item.ShutReason??"未知";
model.shutBeginTime = item.ShutBeginTime==null?"":item.ShutBeginTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
model.shutEndTime = item.ShutEndTime == null?"":item.ShutEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
model.totalTime = item.ShutEndTime == null ? "" : (item.ShutEndTime.Value - item.ShutBeginTime.Value).TotalMinutes.ToString("F2");
dmsShutDownModelDataGrid.Add(model);
}
}));
}catch(Exception ex)
{
Msg.MsgShow($"刷新停机记录信息{ex.Message}", 2, 3);
}
}
}
}
Loading…
Cancel
Save