add-添加投料产出统计记录

dev
liuwf 1 month ago
parent 4f43d6c2d2
commit 886c7f746c

@ -0,0 +1,156 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Security.Principal;
using System.Text;
namespace SlnMesnac.Model.domain
{
[SugarTable("wms_raw_outstock_detail"), TenantAttribute("mes")]
public class WmsRawOutstockDetail
{
/// <summary>
/// 原材料出库记录明细ID
/// </summary>
[SugarColumn(ColumnName = "raw_outstock_detail_id", IsPrimaryKey = true, IsIdentity = true)]
public long RawOutstockDetailId { get; set; }
/// <summary>
/// 原材料出库ID
/// </summary>
[SugarColumn(ColumnName = "raw_outstock_id")]
public long RawOutstockId { get; set; }
/// <summary>
/// 原材料出库任务编号
/// </summary>
[SugarColumn(ColumnName = "task_code")]
public string TaskCode { get; set; }
/// <summary>
/// 仓库ID关联仓库主键
/// </summary>
[SugarColumn(ColumnName = "warehouse_id")]
public long? WarehouseId { get; set; }
/// <summary>
/// 库位编码
/// </summary>
[SugarColumn(ColumnName = "location_code")]
public string LocationCode { get; set; }
/// <summary>
/// 物料条码;最终出库时保存
/// </summary>
[SugarColumn(ColumnName = "material_barcode")]
public string MaterialBarcode { get; set; }
/// <summary>
/// 物料ID
/// </summary>
[SugarColumn(ColumnName = "material_id")]
public long MaterialId { get; set; }
/// <summary>
/// 批次;扫描条码时,从打印条码记录表中获取
/// </summary>
[SugarColumn(ColumnName = "instock_batch")]
public string InstockBatch { get; set; }
/// <summary>
/// 生产日期;扫描条码时,从打印条码记录表中获取
/// </summary>
[SugarColumn(ColumnName = "material_production_date")]
public DateTime? MaterialProductionDate { get; set; }
/// <summary>
/// 计划数量
/// </summary>
[SugarColumn(ColumnName = "plan_amount")]
public decimal PlanAmount { get; set; }
/// <summary>
/// 出库数量
/// </summary>
[SugarColumn(ColumnName = "outstock_amount")]
public decimal? OutstockAmount { get; set; }
/// <summary>
/// 执行状态(0待执行,1执行中,2执行完成)
/// </summary>
[SugarColumn(ColumnName = "execute_status")]
public string ExecuteStatus { get; set; }
/// <summary>
/// 同步ERP状态(0:失败,1成功);此字段不用
/// </summary>
[SugarColumn(ColumnName = "erp_status")]
public string ErpStatus { get; set; }
/// <summary>
/// 同步给ERP的数量;此字段不用
/// </summary>
[SugarColumn(ColumnName = "erp_amount")]
public decimal? ErpAmount { get; set; }
/// <summary>
/// 出库人
/// </summary>
[SugarColumn(ColumnName = "outstock_person")]
public string OutstockPerson { get; set; }
/// <summary>
/// 出库时间
/// </summary>
[SugarColumn(ColumnName = "outstock_time")]
public DateTime? OutstockTime { get; set; }
/// <summary>
/// 出库方式1:人工出库 2:AGV出库
/// </summary>
[SugarColumn(ColumnName = "outstock_way")]
public string OutstockWay { get; set; }
/// <summary>
/// 使用机台名称;出库扫描条码时,从打印条码记录表中获取
/// </summary>
[SugarColumn(ColumnName = "machine_name")]
public string MachineName { get; set; }
/// <summary>
/// 质检状态(0:待质检,1:合格,2:NG)
/// </summary>
[SugarColumn(ColumnName = "quality_status")]
public string QualityStatus { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnName = "create_by")]
public string CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "create_date")]
public DateTime? CreateDate { get; set; }
/// <summary>
/// 最后更新人
/// </summary>
[SugarColumn(ColumnName = "update_by")]
public string UpdateBy { get; set; }
/// <summary>
/// 最后更新时间
/// </summary>
[SugarColumn(ColumnName = "update_date")]
public DateTime? UpdateDate { get; set; }
/// <summary>
/// 每托数量
/// </summary>
[SugarColumn(ColumnName = "stack_amount")]
public decimal? StackAmount { get; set; }
}
}

@ -0,0 +1,42 @@

using SlnMesnac.WPF.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace SlnMesnac.WPF.ConvertTo
{
public class MultiBindingConverter : IMultiValueConverter
{
/// <summary>
/// 对象转换
/// </summary>
/// <param name="values">所绑定的源的值</param>
/// <param name="targetType">目标的类型</param>
/// <param name="parameter">绑定时所传递的参数</param>
/// <param name="culture"><系统语言等信息</param>
/// <returns></returns>
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values != null && values.Count() ==2)
{
StatisticModel bsm = new StatisticModel();
bsm.BeginTime = values[0].ToString();
bsm.EndTime = values[1].ToString();
return bsm;
}
return null;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SlnMesnac.WPF.Model
{
public class StatisticModel
{
/// <summary>
/// 开始时间
/// </summary>
public string? BeginTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public string? EndTime { get; set; }
}
}

@ -2010,7 +2010,6 @@ namespace SlnMesnac.WPF.Page
MagNetStatus3.Fill = MagNet_MesUse_Flag ? Brushes.Green : Brushes.Red;
MagNetStatus4.Fill = signal3 ? Brushes.Red : Brushes.Green;
}));
MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1017;
machineStatusDto.status = MagNet_Shake_Status && MagNet_Status;

@ -2,22 +2,109 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SlnMesnac.WPF.Page"
xmlns:cvt="clr-namespace:SlnMesnac.WPF.ConvertTo"
mc:Ignorable="d"
d:DesignHeight="750" d:DesignWidth="1920" Background="Transparent">
<UserControl.Resources>
<cvt:MultiBindingConverter x:Key="QueryConvert"></cvt:MultiBindingConverter>
<!-- 定义样式 -->
<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>
</UserControl.Resources>
<Grid Margin="5,5">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="*"/>
<RowDefinition Height="6*"/>
<RowDefinition Height="6*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" Grid.Column="0" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<WrapPanel HorizontalAlignment="Left" VerticalAlignment="Center">
<TextBlock Text="开始时间" Margin="10 0" Foreground="White" FontSize="20" VerticalAlignment="Center"/>
<DatePicker Style="{StaticResource CustomDatePicker}" CalendarStyle="{StaticResource CustomCalendarStyle}"
x:Name="BeginTime" FontSize="20"
Width="170" Margin="10 0" BorderBrush="White"
materialDesign:CalendarAssist.IsHeaderVisible="False">
<DatePicker.SelectedDate >
<Binding
Path="BeginDate"
UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
</Binding.ValidationRules>
</Binding>
</DatePicker.SelectedDate>
</DatePicker>
<TextBlock Text="结束时间" Margin="10 0" Foreground="White" FontSize="20" VerticalAlignment="Center"/>
<DatePicker Style="{StaticResource CustomDatePicker}"
x:Name="EndTime" Margin="10 0"
Width="170" BorderBrush="White" FontSize="20"
materialDesign:CalendarAssist.IsHeaderVisible="False"
CalendarStyle="{StaticResource CustomCalendarStyle}">
<!-- 添加这一行 -->
<DatePicker.SelectedDate>
<Binding
Path="EndDate"
UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
</Binding.ValidationRules>
</Binding>
</DatePicker.SelectedDate>
</DatePicker>
<Button Margin="10 0"
Content="时间查询" Command="{Binding QueryCommand}"
Style="{StaticResource BUTTON_AGREE}" Background="LimeGreen">
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource QueryConvert}">
<Binding ElementName="BeginTime" Path="Text"/>
<Binding ElementName="EndTime" Path="Text"/>
</MultiBinding>
</Button.CommandParameter>
</Button>
</WrapPanel>
</Border>
<Border Grid.Row="1" Grid.Column="0" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
@ -30,35 +117,25 @@
<!--计划列表-->
<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 PalletTaskDataGrid}" Background="Transparent"
<DataGrid Grid.Row="0" ItemsSource="{Binding WmsRawOutstockDetailDataGrid}" Background="Transparent"
FontSize="15" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#FFFFFF" >
ScrollViewer.VerticalScrollBarVisibility="Visible" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="White" >
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding ObjId}" Header="序号" Width="1*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding PalletCode}" Header="托盘编号" Width="3*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding RecordTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="记录时间" Width="2*" IsReadOnly="True"/>
<!--<DataGridTextColumn Binding="{Binding RealEndTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="完成时间" Width="1*" IsReadOnly="True"/>-->
<DataGridTemplateColumn Header="操作" Width="2*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="删除" CommandParameter="{Binding PalletCode}" Background="Red" Foreground="White" Margin="10,0,0,0" Height="25" BorderBrush="Red" BorderThickness="0" Width="45" Command="{Binding DataContext.DeletePalletCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid }}"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTextColumn Binding="{Binding RawOutstockDetailId}" Header="序号" Width="1*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding LocationCode}" Header="库位编号" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding MaterialBarcode}" Header="原材料条码" Width="4*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding OutstockTime ,StringFormat=\{0:MM月dd日 HH:mm:ss\}}" Header="出库时间" Width="2*" IsReadOnly="True"/>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Border>
</Grid>
</Border>
<Border Grid.Row="0" Grid.Column="1" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Border Grid.Row="1" Grid.Column="1" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
@ -73,7 +150,7 @@
<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 BarCodeTaskDataGrid}" Background="Transparent"
FontSize="15" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#FFFFFF" >
@ -85,26 +162,25 @@ Foreground="#FFFFFF" >
<DataGridTextColumn Binding="{Binding MaterialCode}" Header="物料编号" Width="3*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding RecordTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="记录时间" Width="2*" IsReadOnly="True"/>
<!--<DataGridTextColumn Binding="{Binding RealEndTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="完成时间" Width="1*" IsReadOnly="True"/>-->
<DataGridTemplateColumn Header="操作" Width="2*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="删除" CommandParameter="{Binding BarCode}" Background="Red" Foreground="White" Margin="10,0,0,0" Height="25" BorderBrush="Red" BorderThickness="0" Width="45" Command="{Binding DataContext.DeleteBarCodeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid }}"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Border>
</Grid>
</Border>
<Border Grid.Row="1" Grid.Column="0" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Border Grid.Row="2" Grid.Column="0" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="9*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="CadetBlue" BorderThickness="0,0,0,0" CornerRadius="0" Background="Transparent" Margin="1,6,5,5" >
<TextBlock Text="日投料统计图" FontSize="20" FontWeight="Bold" Foreground="#0288d1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</Grid>
</Border>
<Border Grid.Row="1" Grid.Column="1" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Border Grid.Row="2" Grid.Column="1" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
</Border>
</Grid>

@ -4,12 +4,16 @@ 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.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
@ -42,37 +46,119 @@ namespace SlnMesnac.WPF.ViewModel
{
private readonly PalletStowBusiness _palletStowBusiness;
private readonly ProdCompletionBusiness _prodCompletionBusiness;
private readonly ISqlSugarClient sqlClient;
public ProdStatisticsViewModel()
{
_palletStowBusiness = App.ServiceProvider.GetService<PalletStowBusiness>();
_prodCompletionBusiness = App.ServiceProvider.GetService<ProdCompletionBusiness>();
sqlClient = App.ServiceProvider.GetService<ISqlSugarClient>();
QueryCommand = new RelayCommand<object>(obj => Query(obj));
DeletePalletCommand = new RelayCommand<string>(DeletePallet);
// DeleteBarCodeCommand = new RelayCommand<string> (DeleteBarCode);
BeginDate = DateTime.Now.AddDays(-3);
EndDate = DateTime.Now;
}
#region 时间查询
_palletStowBusiness.RefreshPalletTaskListEvent += RefreshPalletTaskDataGrid;
private async Task Query(object obj)
{
try
{
if (EndDate <= BeginDate)
{
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("结束时间要大于开始时间", 2, 3);
});
return;
}
else
{
await RefreshWmsRawOutstockDetailDataGrid(BeginDate, EndDate);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
#endregion
/// <summary>
/// 刷新原材料出库记录及图表
/// </summary>
private async Task RefreshWmsRawOutstockDetailDataGrid(DateTime beginDate, DateTime endDate)
{
List<WmsRawOutstockDetail> list;
list = await sqlClient.AsTenant().GetConnection("mes").Queryable<WmsRawOutstockDetail>().Where(x => x.WarehouseId==311 && x.OutstockTime >= beginDate && x.OutstockTime <= endDate).OrderBy(t => t.OutstockTime).ToListAsync();
if (list != null && list.Count > 0)
{
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
WmsRawOutstockDetailDataGrid.Clear();
int i = 1;
foreach (WmsRawOutstockDetail verify in list)
{
verify.RawOutstockDetailId = i++;
WmsRawOutstockDetailDataGrid.Add(verify);
}
}));
// 刷新图表
// ModelList(list);
}
}
#region 参数定义
private DateTime _BeginDate;
public DateTime BeginDate
{
get { return _BeginDate; }
set
{
if (_BeginDate != value)
{
_BeginDate = value;
RaisePropertyChanged();//属性通知
}
}
}
private DateTime _EndDate;
public DateTime EndDate
{
get { return _EndDate; }
set
{
_EndDate = value;
RaisePropertyChanged();//属性通知
}
}
/// <summary>
/// 托盘队列DataGrid
/// </summary>
private ObservableCollection<RealPalletTask> palletTaskDataGrid;
private ObservableCollection<WmsRawOutstockDetail> wmsRawOutstockDetailDataGrid = new ObservableCollection<WmsRawOutstockDetail>();
public ObservableCollection<RealPalletTask> PalletTaskDataGrid
public ObservableCollection<WmsRawOutstockDetail> WmsRawOutstockDetailDataGrid
{
get { return palletTaskDataGrid; }
set { palletTaskDataGrid = value; RaisePropertyChanged(() => PalletTaskDataGrid); }
get { return wmsRawOutstockDetailDataGrid; }
set { wmsRawOutstockDetailDataGrid = value; RaisePropertyChanged(() => WmsRawOutstockDetailDataGrid); }
}
/// <summary>
@ -90,24 +176,18 @@ namespace SlnMesnac.WPF.ViewModel
#region 事件定义
/// <summary>
/// 时间查询事件
/// </summary>
public RelayCommand<object> QueryCommand { get; set; }
public RelayCommand<string> DeletePalletCommand { get;set; }
public RelayCommand<string> DeleteBarCodeCommand { get; set; }
#endregion
/// <summary>
/// 刷新托盘队列信息
/// </summary>
/// <param name="palletTasks"></param>
private void RefreshPalletTaskDataGrid(List<RealPalletTask> palletTasks)
{
PalletTaskDataGrid = new ObservableCollection<RealPalletTask>();
foreach (var task in palletTasks)
{
PalletTaskDataGrid.Add(task);
}
}
///// <summary>
///// 刷新条码队列信息

Loading…
Cancel
Save