change-成品下线加订单统计,条码搜索功能

dev
liuwf 11 months ago
parent 1ef4c6f9ab
commit be2d89db25

@ -27,7 +27,7 @@ namespace Aucma.Core.ProductOffLine.ConvertTo
bsm.BeginTime = values[0].ToString(); bsm.BeginTime = values[0].ToString();
bsm.EndTime = values[1].ToString(); bsm.EndTime = values[1].ToString();
return bsm; return bsm;
} }
return null; return null;

@ -8,6 +8,7 @@ namespace Aucma.Core.ProductOffLine.Models
{ {
public class StatisticModel public class StatisticModel
{ {
// public string? ProductCode { get; set; }
/// <summary> /// <summary>
/// 开始时间 /// 开始时间
/// </summary> /// </summary>

@ -2,6 +2,7 @@
using Admin.Core.Model; using Admin.Core.Model;
using Admin.Core.Model.Model_New; using Admin.Core.Model.Model_New;
using Aucma.Core.ProductOffLine.Models; using Aucma.Core.ProductOffLine.Models;
using Aucma.Core.ProductOffLine.Views;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -22,15 +23,26 @@ namespace Aucma.Core.ProductOffLine.ViewModels
// 成品下线操作mes数据 // 成品下线操作mes数据
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>(); private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
public RelayCommand ResetCommand { get; set; }
public StatisticsPageViewModel() public StatisticsPageViewModel()
{ {
_offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>(); _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
MainWindowViewModel.RefreshChartsEvent += LoadData; MainWindowViewModel.RefreshChartsEvent += LoadData;
ResetCommand = new RelayCommand(Reset);
LoadData(); LoadData();
} }
List<MaterialComplateInfo> materialComplateInfos = new List<MaterialComplateInfo>(); List<MaterialComplateInfo> materialComplateInfos = new List<MaterialComplateInfo>();
public void Reset()
{
ProductSNCode = string.Empty;
LoadData();
}
#region 加载DataGrid数据 #region 加载DataGrid数据
private void LoadData() private void LoadData()
{ {
@ -95,6 +107,17 @@ namespace Aucma.Core.ProductOffLine.ViewModels
OnPropertyChanged();//属性通知 OnPropertyChanged();//属性通知
} }
} }
#region 物料条码
private string _productSNCode;
public string ProductSNCode
{
get => _productSNCode;
set => SetProperty(ref _productSNCode, value);
}
#endregion
// 按照型号统计 // 按照型号统计
private ObservableCollection<TempInfo> totalItem = new ObservableCollection<TempInfo>() { }; private ObservableCollection<TempInfo> totalItem = new ObservableCollection<TempInfo>() { };
public ObservableCollection<TempInfo> TotalItem public ObservableCollection<TempInfo> TotalItem
@ -132,36 +155,44 @@ namespace Aucma.Core.ProductOffLine.ViewModels
[RelayCommand] [RelayCommand]
private void ExecQuery(object obj) private void ExecQuery(object obj)
{ {
List<OffLineInfo> list = null; List<OffLineInfo> list = null;
var result = (StatisticModel)obj; if (!string.IsNullOrEmpty(_productSNCode))
if (string.IsNullOrEmpty(result.BeginTime) && string.IsNullOrEmpty(result.EndTime))
{
return;
}
else if (string.IsNullOrEmpty(result.BeginTime))
{
DateTime EndTime = Convert.ToDateTime(result.EndTime);
list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime <= EndTime.AddDays(1)).Result;
}
else if (string.IsNullOrEmpty(result.EndTime))
{ {
DateTime BeginTime = Convert.ToDateTime(result.BeginTime); list = _offLineInfoServices.QueryAsync(x => x.ProductSNCode == _productSNCode).Result;
list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime).Result;
} }
else else
{ {
DateTime BeginTime = Convert.ToDateTime(result.BeginTime); var result = (StatisticModel)obj;
DateTime EndTime = Convert.ToDateTime(result.EndTime); if (result == null) return;
if (BeginTime > EndTime)
if (string.IsNullOrEmpty(result.BeginTime) && string.IsNullOrEmpty(result.EndTime))
{ {
MessageBox.Show("结束时间要大于开始时间!");
return; return;
} }
list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime && x.ProductScanTime <= EndTime.AddDays(1)).Result; else if (string.IsNullOrEmpty(result.BeginTime))
} {
DateTime EndTime = Convert.ToDateTime(result.EndTime);
list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime <= EndTime.AddDays(1)).Result;
}
else if (string.IsNullOrEmpty(result.EndTime))
{
DateTime BeginTime = Convert.ToDateTime(result.BeginTime);
list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime).Result;
}
else
{
DateTime BeginTime = Convert.ToDateTime(result.BeginTime);
DateTime EndTime = Convert.ToDateTime(result.EndTime);
if (BeginTime > EndTime)
{
MessageBox.Show("结束时间要大于开始时间!");
return;
}
list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime && x.ProductScanTime <= EndTime.AddDays(1)).Result;
}
}
if (list != null) if (list != null)
{ {
list = list.OrderByDescending(x => x.ProductScanTime).ToList(); list = list.OrderByDescending(x => x.ProductScanTime).ToList();

@ -61,14 +61,18 @@ namespace Aucma.Core.ProductOffLine.Views
{ {
directionSelected = true; directionSelected = true;
this.Close(); this.Close();
if (direction == "外侧提升机箱体") Task.Run(() =>
{ {
SendPlcPassEvent?.Invoke(2, "A"); if (direction == "外侧提升机箱体")
} {
else SendPlcPassEvent?.Invoke(2, "A");
{ }
SendPlcPassEvent?.Invoke(1, "A"); else
} {
SendPlcPassEvent?.Invoke(1, "A");
}
});
} }

@ -19,5 +19,10 @@ namespace Aucma.Core.ProductOffLine.Views
Login login = new Login(); Login login = new Login();
login.ShowDialog(); login.ShowDialog();
} }
private void Minimized_Click(object sender, RoutedEventArgs e)
{
}
} }
} }

@ -7,7 +7,7 @@
xmlns:local="clr-namespace:Aucma.Core.ProductOffLine.Views" xmlns:local="clr-namespace:Aucma.Core.ProductOffLine.Views"
xmlns:cvt="clr-namespace:Aucma.Core.ProductOffLine.ConvertTo" xmlns:cvt="clr-namespace:Aucma.Core.ProductOffLine.ConvertTo"
mc:Ignorable="d" FontFamily="Microsoft YaHei" Background="#1152AC" mc:Ignorable="d" FontFamily="Microsoft YaHei" Background="#1152AC"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="800" d:DesignWidth="1500">
<UserControl.Resources> <UserControl.Resources>
<cvt:MultiBindingConverter x:Key="QueryConvert"></cvt:MultiBindingConverter> <cvt:MultiBindingConverter x:Key="QueryConvert"></cvt:MultiBindingConverter>
@ -124,9 +124,13 @@
</Binding> </Binding>
</DatePicker.SelectedDate> </DatePicker.SelectedDate>
</DatePicker> </DatePicker>
<Button Margin="10 0" <TextBlock Text="条码:" Margin="30 0 0 0" Foreground="White" FontSize="20" VerticalAlignment="Center"/>
Content="查询" Command="{Binding ExecQueryCommand}" <TextBox x:Name="ProductSNCode" Text="{Binding ProductSNCode,Mode=TwoWay}" Width="300" FontSize="20" Foreground="White" HorizontalAlignment="Center">
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
</TextBox>
<Button Margin="30 0 0 0 " Width="100"
Content="查询" Command="{Binding ExecQueryCommand}" FontSize="20"
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource AncestorType={x:Type Window}, Mode=FindAncestor}}"
Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}" Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}"
ToolTip="Resource name: MaterialDesignRaisedSecondaryDarkButton"> ToolTip="Resource name: MaterialDesignRaisedSecondaryDarkButton">
<Button.CommandParameter> <Button.CommandParameter>
@ -136,6 +140,8 @@
</MultiBinding> </MultiBinding>
</Button.CommandParameter> </Button.CommandParameter>
</Button> </Button>
<Button Content="重置" FontSize="20" Margin="20 0 0 0" x:Name="Minimized" Command="{Binding ResetCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Width="100" Background="#FF9900" BorderBrush="#FF9900" />
</WrapPanel> </WrapPanel>
<UniformGrid Grid.Row="1"> <UniformGrid Grid.Row="1">
<DataGrid Grid.Row="0" ItemsSource="{Binding ListItems}" Background="#00000000" <DataGrid Grid.Row="0" ItemsSource="{Binding ListItems}" Background="#00000000"

Loading…
Cancel
Save