|
|
|
@ -22,7 +22,8 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
// 成品下线操作mes数据
|
|
|
|
|
private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
|
|
|
|
|
|
|
|
|
|
public StatisticsPageViewModel() {
|
|
|
|
|
public StatisticsPageViewModel()
|
|
|
|
|
{
|
|
|
|
|
_offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
|
|
|
|
|
MainWindowViewModel.RefreshChartsEvent += LoadData;
|
|
|
|
|
LoadData();
|
|
|
|
@ -31,40 +32,54 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
List<MaterialComplateInfo> materialComplateInfos = new List<MaterialComplateInfo>();
|
|
|
|
|
|
|
|
|
|
#region 加载DataGrid数据
|
|
|
|
|
private void LoadData()
|
|
|
|
|
private void LoadData()
|
|
|
|
|
{
|
|
|
|
|
ListItems.Clear();
|
|
|
|
|
TotalItem.Clear();
|
|
|
|
|
OrderListItem.Clear();
|
|
|
|
|
List<OffLineInfo> list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= DateTime.Now.AddDays(-2)).Result;
|
|
|
|
|
if (list == null || list.Count <= 0) return;
|
|
|
|
|
list = list.OrderByDescending(x => x.ProductScanTime).ToList();
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
List<OffLineInfo> list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= DateTime.Now.AddDays(-2)).Result;
|
|
|
|
|
if(list==null || list.Count<=0) return;
|
|
|
|
|
list = list.OrderByDescending(x => x.ProductScanTime).ToList();
|
|
|
|
|
|
|
|
|
|
if (list != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (OffLineInfo record in list)
|
|
|
|
|
if (list != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
foreach (OffLineInfo record in list)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ListItems.Add(new TempInfo() { No = ListItems.Count + 1, ProductOrderNo = record.ProductOrderNo, ProductSNCode = record.ProductSNCode, ProductModel = record.ProductModel, ProductRemark = record.ProductRemark, ProductScanTime = record.ProductScanTime });
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 按型号统计
|
|
|
|
|
var countByProductModel = list.GroupBy(x => x.ProductModel).Select(group => new
|
|
|
|
|
{
|
|
|
|
|
ProductCode = group.First().ProductCode,
|
|
|
|
|
ProductRemark = group.First().ProductRemark,
|
|
|
|
|
ProductModel = group.Key,
|
|
|
|
|
Count = group.Count()
|
|
|
|
|
}).ToList();
|
|
|
|
|
foreach (var item in countByProductModel)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
TotalItem.Add(new TempInfo() { No = TotalItem.Count + 1, ProductCode = item.ProductCode, ProductModel = item.ProductModel, ProductRemark = item.ProductRemark, Count = item.Count });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 按订单统计
|
|
|
|
|
var countOrderModel = list.GroupBy(x => x.ProductOrderNo).Select(group => new
|
|
|
|
|
{
|
|
|
|
|
ProductOrderNo = group.Key,
|
|
|
|
|
ProductCode = group.First().ProductCode,
|
|
|
|
|
ProductRemark = group.First().ProductRemark,
|
|
|
|
|
ProductModel = group.First().ProductModel,
|
|
|
|
|
Count = group.Count()
|
|
|
|
|
}).ToList();
|
|
|
|
|
foreach (var item in countOrderModel)
|
|
|
|
|
{
|
|
|
|
|
OrderListItem.Add(new TempInfo() { No = OrderListItem.Count + 1, ProductOrderNo =item.ProductOrderNo, ProductCode = item.ProductCode, ProductModel = item.ProductModel, ProductRemark = item.ProductRemark, Count = item.Count });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var countByProductModel = list.GroupBy(x => x.ProductModel).Select(group => new
|
|
|
|
|
{
|
|
|
|
|
ProductCode = group.First().ProductCode,
|
|
|
|
|
ProductRemark = group.First().ProductRemark,
|
|
|
|
|
ProductModel = group.Key,
|
|
|
|
|
Count = group.Count()
|
|
|
|
|
}).ToList();
|
|
|
|
|
foreach (var item in countByProductModel)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
TotalItem.Add(new TempInfo() { No = TotalItem.Count + 1,ProductCode = item.ProductCode, ProductModel = item.ProductModel,ProductRemark = item.ProductRemark, Count = item.Count });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
@ -91,9 +106,25 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
OnPropertyChanged();//属性通知
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 按照型号统计
|
|
|
|
|
private ObservableCollection<TempInfo> orderListItem = new ObservableCollection<TempInfo>() { };
|
|
|
|
|
public ObservableCollection<TempInfo> OrderListItem
|
|
|
|
|
{
|
|
|
|
|
get { return orderListItem; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
orderListItem = value;
|
|
|
|
|
OnPropertyChanged();//属性通知
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 查询
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询
|
|
|
|
@ -110,8 +141,8 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
else if (string.IsNullOrEmpty(result.BeginTime))
|
|
|
|
|
{
|
|
|
|
|
DateTime EndTime = Convert.ToDateTime(result.EndTime);
|
|
|
|
|
|
|
|
|
|
list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime <= EndTime.AddDays(1)).Result;
|
|
|
|
|
|
|
|
|
|
list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime <= EndTime.AddDays(1)).Result;
|
|
|
|
|
}
|
|
|
|
|
else if (string.IsNullOrEmpty(result.EndTime))
|
|
|
|
|
{
|
|
|
|
@ -127,7 +158,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
MessageBox.Show("结束时间要大于开始时间!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime && x.ProductScanTime<= EndTime.AddDays(1)).Result;
|
|
|
|
|
list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime && x.ProductScanTime <= EndTime.AddDays(1)).Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -135,28 +166,45 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
{
|
|
|
|
|
list = list.OrderByDescending(x => x.ProductScanTime).ToList();
|
|
|
|
|
|
|
|
|
|
ListItems.Clear();
|
|
|
|
|
TotalItem.Clear();
|
|
|
|
|
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
foreach (OffLineInfo record in list)
|
|
|
|
|
{
|
|
|
|
|
ListItems.Clear();
|
|
|
|
|
TotalItem.Clear();
|
|
|
|
|
OrderListItem.Clear();
|
|
|
|
|
foreach (OffLineInfo record in list)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ListItems.Add(new TempInfo() { No = ListItems.Count + 1, ProductOrderNo = record.ProductOrderNo, ProductSNCode = record.ProductSNCode, ProductModel = record.ProductModel, ProductRemark = record.ProductRemark, ProductScanTime = record.ProductScanTime });
|
|
|
|
|
ListItems.Add(new TempInfo() { No = ListItems.Count + 1, ProductOrderNo = record.ProductOrderNo, ProductSNCode = record.ProductSNCode, ProductModel = record.ProductModel, ProductRemark = record.ProductRemark, ProductScanTime = record.ProductScanTime });
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var countByProductModel = list.GroupBy(x => x.ProductModel).Select(group => new
|
|
|
|
|
{
|
|
|
|
|
ProductCode = group.First().ProductCode,
|
|
|
|
|
ProductRemark = group.First().ProductRemark,
|
|
|
|
|
ProductModel = group.Key,
|
|
|
|
|
Count = group.Count()
|
|
|
|
|
}).ToList();
|
|
|
|
|
foreach (var item in countByProductModel)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
var countByProductModel = list.GroupBy(x => x.ProductModel).Select(group => new
|
|
|
|
|
{
|
|
|
|
|
ProductCode = group.First().ProductCode,
|
|
|
|
|
ProductRemark = group.First().ProductRemark,
|
|
|
|
|
ProductModel = group.Key,
|
|
|
|
|
Count = group.Count()
|
|
|
|
|
}).ToList();
|
|
|
|
|
foreach (var item in countByProductModel)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
TotalItem.Add(new TempInfo() { No = TotalItem.Count + 1, ProductCode = item.ProductCode, ProductModel = item.ProductModel, ProductRemark = item.ProductRemark, Count = item.Count });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 按订单统计
|
|
|
|
|
var countOrderModel = list.GroupBy(x => x.ProductOrderNo).Select(group => new
|
|
|
|
|
{
|
|
|
|
|
ProductOrderNo = group.Key,
|
|
|
|
|
ProductCode = group.First().ProductCode,
|
|
|
|
|
ProductRemark = group.First().ProductRemark,
|
|
|
|
|
ProductModel = group.First().ProductModel,
|
|
|
|
|
Count = group.Count()
|
|
|
|
|
}).ToList();
|
|
|
|
|
foreach (var item in countOrderModel)
|
|
|
|
|
{
|
|
|
|
|
OrderListItem.Add(new TempInfo() { No = OrderListItem.Count + 1, ProductOrderNo = item.ProductOrderNo, ProductCode = item.ProductCode, ProductModel = item.ProductModel, ProductRemark = item.ProductRemark, Count = item.Count });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TotalItem.Add(new TempInfo() { No = TotalItem.Count + 1, ProductCode = item.ProductCode, ProductModel = item.ProductModel, ProductRemark = item.ProductRemark, Count = item.Count });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|