|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
using GalaSoft.MvvmLight;
|
|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using LiveCharts;
|
|
|
|
|
using LiveCharts.Defaults;
|
|
|
|
|
using LiveCharts.Wpf;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SlnMesnac.Business;
|
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
|
@ -14,6 +17,7 @@ using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
|
|
#region << 版 本 注 释 >>
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
@ -53,75 +57,44 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
_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);
|
|
|
|
|
QueryCommand = new RelayCommand<object>(obj => Query());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BeginDate = DateTime.Now.AddDays(-3);
|
|
|
|
|
EndDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
Query();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 参数定义
|
|
|
|
|
|
|
|
|
|
#region 日产量柱状图X轴日期
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日产量柱状图X轴日期
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<string> outDayList = new List<string>();
|
|
|
|
|
|
|
|
|
|
#region 时间查询
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
public List<string> OutDayList
|
|
|
|
|
{
|
|
|
|
|
get { return outDayList; }
|
|
|
|
|
set { outDayList = value; }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 型号统计柱状图
|
|
|
|
|
/// <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();
|
|
|
|
|
private SeriesCollection outAchievement = new SeriesCollection();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
public SeriesCollection OutAchievement
|
|
|
|
|
{
|
|
|
|
|
get { return outAchievement; }
|
|
|
|
|
set { outAchievement = value; }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参数定义
|
|
|
|
|
|
|
|
|
|
private DateTime _BeginDate;
|
|
|
|
|
public DateTime BeginDate
|
|
|
|
|
{
|
|
|
|
@ -151,7 +124,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 托盘队列DataGrid
|
|
|
|
|
/// 原材料投料明细DataGrid
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ObservableCollection<WmsRawOutstockDetail> wmsRawOutstockDetailDataGrid = new ObservableCollection<WmsRawOutstockDetail>();
|
|
|
|
|
|
|
|
|
@ -181,43 +154,108 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RelayCommand<object> QueryCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand<string> DeletePalletCommand { get;set; }
|
|
|
|
|
|
|
|
|
|
public RelayCommand<string> DeleteBarCodeCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 刷新条码队列信息
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="barCodeTasks"></param>
|
|
|
|
|
//private void RefreshBarCodeTaskDataGrid(List<RealBarCodeTask> barCodeTasks)
|
|
|
|
|
//{
|
|
|
|
|
// BarCodeTaskDataGrid = new ObservableCollection<RealBarCodeTask>();
|
|
|
|
|
// foreach (var task in barCodeTasks)
|
|
|
|
|
// {
|
|
|
|
|
// BarCodeTaskDataGrid.Add(task);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
#region 时间查询
|
|
|
|
|
|
|
|
|
|
private async Task Query()
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 原材料出库记录及图表
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 移除托盘队列信息
|
|
|
|
|
/// 刷新原材料出库记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="palletCode"></param>
|
|
|
|
|
private void DeletePallet(string palletCode)
|
|
|
|
|
private async Task RefreshWmsRawOutstockDetailDataGrid(DateTime beginDate, DateTime endDate)
|
|
|
|
|
{
|
|
|
|
|
_palletStowBusiness.RemovePalletInfo(palletCode);
|
|
|
|
|
List<WmsRawOutstockDetail> list;
|
|
|
|
|
|
|
|
|
|
list = await sqlClient.AsTenant().GetConnection("mes").Queryable<WmsRawOutstockDetail>().Where(x => x.WarehouseId == 311 && x.OutstockTime >= beginDate && x.OutstockTime <= endDate).OrderByDescending(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);
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// 刷新图表
|
|
|
|
|
RefreshWmsRawOutstockDetailChart(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 移除小包条码队列信息
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="barCode"></param>
|
|
|
|
|
//private void DeleteBarCode(string barCode)
|
|
|
|
|
//{
|
|
|
|
|
// _prodCompletionBusiness.RemoveBarCode(barCode);
|
|
|
|
|
//}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新原材料出库图表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="list"></param>
|
|
|
|
|
private void RefreshWmsRawOutstockDetailChart(List<WmsRawOutstockDetail> list)
|
|
|
|
|
{
|
|
|
|
|
App.Current.Dispatcher.BeginInvoke((Action)(() =>
|
|
|
|
|
{
|
|
|
|
|
OutAchievement.Clear();
|
|
|
|
|
OutDayList.Clear();
|
|
|
|
|
ChartValues<ObservablePoint> achievement = new ChartValues<ObservablePoint>();
|
|
|
|
|
var listByDate = list
|
|
|
|
|
.GroupBy(detail => detail.OutstockTime.Value.Date) // 按日期分组
|
|
|
|
|
.Select(group => new
|
|
|
|
|
{
|
|
|
|
|
Date = group.Key,
|
|
|
|
|
TotalAmount = group.Count() // 统计出库数量
|
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (var item in listByDate)
|
|
|
|
|
{
|
|
|
|
|
outDayList.Add(item.Date.ToString("MM-dd"));
|
|
|
|
|
achievement.Add(new ObservablePoint(i++, double.Parse(item.TotalAmount.ToString())));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//加一个汇总柱状图
|
|
|
|
|
outDayList.Add("合计");
|
|
|
|
|
achievement.Add(new ObservablePoint(i, list.Count));
|
|
|
|
|
var column = new ColumnSeries();
|
|
|
|
|
column.DataLabels = true;
|
|
|
|
|
column.Title = "日投料量";
|
|
|
|
|
column.Values = achievement;
|
|
|
|
|
column.Foreground = Brushes.White;
|
|
|
|
|
OutAchievement.Add(column);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|