change-分垛界面调整

main
liuwf 10 months ago
parent 9cbadc5a7e
commit 3e44f4453a

@ -54,7 +54,14 @@ namespace Aucma.Core.Palletiz.Business
/// </summary> /// </summary>
public delegate void RefreshMsg(string msg); public delegate void RefreshMsg(string msg);
public static event RefreshMsg? RefreshMsgEvent; public static event RefreshMsg? RefreshMsgEvent;
/// <summary>
///入库时DataGrid添加一条DataGrid记录
/// </summary>
public delegate void AddData(RecordInStore record);
public static event AddData? AddDataEvent;
#endregion #endregion
@ -177,6 +184,8 @@ namespace Aucma.Core.Palletiz.Business
} }
_ = _recordInstoreServices.AddAsync(recordInstore).Result; _ = _recordInstoreServices.AddAsync(recordInstore).Result;
//刷新页面
AddDataEvent?.Invoke(recordInstore);
#endregion #endregion
if (!result) if (!result)
@ -267,7 +276,7 @@ namespace Aucma.Core.Palletiz.Business
if (plcCon == null) if (plcCon == null)
{ {
Task.Delay(1000 * 5).Wait(); Task.Delay(1000 * 3).Wait();
plcCon = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("InStoreAPlc")); plcCon = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("InStoreAPlc"));
if(plcCon == null) if(plcCon == null)

@ -97,14 +97,18 @@ namespace Aucma.Core.Palletiz.ViewModels
[RelayCommand] [RelayCommand]
public void Save(Window window) public void Save(Window window)
{ {
Console.WriteLine(Area); if (Area == null)
{
MessageBox.Show("请先选择区域");
return;
}
if (string.IsNullOrEmpty(ProductCode)) if (string.IsNullOrEmpty(ProductCode))
{ {
MessageBox.Show("请先选择产品型号"); MessageBox.Show("请先选择产品型号");
return; return;
} }
HandSendEvent?.Invoke("A", productCode); HandSendEvent?.Invoke(Area.Content.ToString(), productCode);
MessageBox.Show("手动入库成功"); MessageBox.Show("手动入库成功");
window.Close(); window.Close();
// 入库 // 入库

@ -8,6 +8,8 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using Aucma.Core.Palletiz.Views; using Aucma.Core.Palletiz.Views;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using System.Threading.Tasks;
using static Aucma.Core.Palletiz.ViewModels.StatisticsPageViewModel;
/* /*
* *
@ -24,6 +26,7 @@ namespace Aucma.Core.Palletiz.ViewModels
new InStoreBusiness().Init(); new InStoreBusiness().Init();
SelectTypeViewModel.RefreshPageEvent += Init; SelectTypeViewModel.RefreshPageEvent += Init;
StatisticsPageViewModel.CountInstoreEvent += CountInstore;
this.inStoreBusiness = App.ServiceProvider.GetService<InStoreBusiness>(); this.inStoreBusiness = App.ServiceProvider.GetService<InStoreBusiness>();
InStoreBusiness.RefreshMsgEvent += RefreshMsg; InStoreBusiness.RefreshMsgEvent += RefreshMsg;
InStoreBusiness.RefreshProductInfoEvent += RefreshProductInfo; InStoreBusiness.RefreshProductInfoEvent += RefreshProductInfo;
@ -31,20 +34,26 @@ namespace Aucma.Core.Palletiz.ViewModels
{ {
Console.WriteLine($"{obj};设置"); Console.WriteLine($"{obj};设置");
BaseSpaceInfo space = inStoreBusiness.GetSpaceinfosById(obj); BaseSpaceInfo space = inStoreBusiness.GetSpaceinfosById(obj);
if(space != null ) if (space != null)
{ {
SelectType direct = new SelectType(space); SelectType direct = new SelectType(space);
direct.ShowDialog(); direct.ShowDialog();
} }
}); });
this.Init(); this.Init();
InStoreAmount = inStoreAmount + "19";
InStoreTaskContent = new StatisticsPageView(); InStoreTaskContent = new StatisticsPageView();
} }
public void CountInstore(int count)
{
InStoreAmount = "入库数量:";
InStoreAmount = inStoreAmount + count;
}
#region 参数定义 #region 参数定义
public string productSNCode = string.Empty; public string productSNCode = string.Empty;
@ -55,12 +64,12 @@ namespace Aucma.Core.Palletiz.ViewModels
} }
public string productModel = string.Empty; public string productModel = string.Empty;
public string ProductModel public string ProductModel
{ {
get { return this.productModel; } get { return this.productModel; }
set => SetProperty(ref productModel, value); set => SetProperty(ref productModel, value);
} }
public string orderCode = string.Empty; public string orderCode = string.Empty;
@ -69,7 +78,7 @@ namespace Aucma.Core.Palletiz.ViewModels
get { return this.orderCode; } get { return this.orderCode; }
set => SetProperty(ref orderCode, value); set => SetProperty(ref orderCode, value);
} }
public string productScanTime = string.Empty; public string productScanTime = string.Empty;
@ -77,7 +86,7 @@ namespace Aucma.Core.Palletiz.ViewModels
{ {
get { return this.productScanTime; } get { return this.productScanTime; }
set => SetProperty(ref productScanTime, value); set => SetProperty(ref productScanTime, value);
} }
public string msg = string.Empty; public string msg = string.Empty;
@ -85,7 +94,7 @@ namespace Aucma.Core.Palletiz.ViewModels
{ {
get { return this.msg; } get { return this.msg; }
set => SetProperty(ref msg, value); set => SetProperty(ref msg, value);
} }
public string inStoreAmount = "入库数量:"; public string inStoreAmount = "入库数量:";
public string InStoreAmount public string InStoreAmount
@ -93,7 +102,7 @@ namespace Aucma.Core.Palletiz.ViewModels
get { return this.inStoreAmount; } get { return this.inStoreAmount; }
set => SetProperty(ref inStoreAmount, value); set => SetProperty(ref inStoreAmount, value);
} }
public System.Windows.Controls.UserControl _content; public System.Windows.Controls.UserControl _content;
@ -104,7 +113,7 @@ namespace Aucma.Core.Palletiz.ViewModels
set => SetProperty(ref _content, value); set => SetProperty(ref _content, value);
} }
/// <summary> /// <summary>
@ -116,7 +125,7 @@ namespace Aucma.Core.Palletiz.ViewModels
{ {
get { return _areaA_SpaceInfo; } get { return _areaA_SpaceInfo; }
set => SetProperty(ref _areaA_SpaceInfo, value); set => SetProperty(ref _areaA_SpaceInfo, value);
} }
/// <summary> /// <summary>
@ -128,7 +137,7 @@ namespace Aucma.Core.Palletiz.ViewModels
{ {
get { return _areaB_SpaceInfo; } get { return _areaB_SpaceInfo; }
set => SetProperty(ref _areaB_SpaceInfo, value); set => SetProperty(ref _areaB_SpaceInfo, value);
} }
#endregion #endregion
@ -160,46 +169,55 @@ namespace Aucma.Core.Palletiz.ViewModels
OrderCode = orderCode; OrderCode = orderCode;
ProductScanTime = DateTime.Now.ToString(); ProductScanTime = DateTime.Now.ToString();
} }
private void Init() private async Task Init()
{ {
await Task.Run(() =>
var info = inStoreBusiness.GetBaseSpaceinfos("A");
info = info.OrderByDescending(x => x.ObjId).ToList();
if (info != null)
{ {
App.Current.Dispatcher.BeginInvoke((Action)(() => var info = inStoreBusiness.GetBaseSpaceinfos("A");
info = info.OrderByDescending(x => x.ObjId).ToList();
if (info != null)
{ {
if (spaceItems.Count > 0) App.Current.Dispatcher.BeginInvoke((Action)(() =>
{ {
spaceItems.Clear(); if (spaceItems.Count > 0)
} {
foreach (var item in info) spaceItems.Clear();
}
foreach (var item in info)
{
spaceItems.Add(item);
}
AreaA_SpaceInfo = spaceItems;
}));
}
var info2 = inStoreBusiness.GetBaseSpaceinfos("A");
info2 = info2.OrderBy(x => x.ObjId).ToList();
if (info2 != null)
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{ {
spaceItems.Add(item); if (spaceItemsB.Count > 0)
} {
AreaA_SpaceInfo = spaceItems; spaceItemsB.Clear();
})); }
} foreach (var item in info2)
{
spaceItemsB.Add(item);
//var info2 = inStoreBusiness.GetBaseSpaceinfos("A"); }
//info2 = info2.OrderBy(x => x.ObjId).ToList(); AreaB_SpaceInfo = spaceItemsB;
//if (info2 != null) }));
//{ }
// App.Current.Dispatcher.BeginInvoke((Action)(() =>
// { });
// if (spaceItemsB.Count > 0)
// {
// spaceItemsB.Clear();
// }
// foreach (var item in info2)
// {
// spaceItemsB.Add(item);
// }
// AreaB_SpaceInfo = spaceItemsB;
// }));
//}
} }
} }
} }

@ -20,7 +20,7 @@ namespace Aucma.Core.Palletiz.ViewModels
public PalletizPageViewModel() { public PalletizPageViewModel() {
_baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>(); _baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
LoadDataGrid(); LoadDataGrid();
SelectTypeViewModel.RefreshPageEvent += LoadDataGrid; // SelectTypeViewModel.RefreshPageEvent += LoadDataGrid;
} }
public void LoadDataGrid() public void LoadDataGrid()

@ -33,7 +33,7 @@ namespace Aucma.Core.Palletiz.ViewModels
/// 刷新货道页面 /// 刷新货道页面
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
public delegate void RefreshPage(); public delegate Task RefreshPage();
public static event RefreshPage RefreshPageEvent; public static event RefreshPage RefreshPageEvent;
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseSpaceInfoServices)); private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseSpaceInfoServices));

@ -1,6 +1,7 @@
using Admin.Core.Common; using Admin.Core.Common;
using Admin.Core.IService; using Admin.Core.IService;
using Admin.Core.Model; using Admin.Core.Model;
using Aucma.Core.Palletiz.Business;
using Aucma.Core.Palletiz.Models; using Aucma.Core.Palletiz.Models;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
@ -13,15 +14,28 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Documents;
namespace Aucma.Core.Palletiz.ViewModels namespace Aucma.Core.Palletiz.ViewModels
{ {
public partial class StatisticsPageViewModel : ObservableObject public partial class StatisticsPageViewModel : ObservableObject
{ {
// private static readonly Lazy<StatisticsPageViewModel> lazy = new Lazy<StatisticsPageViewModel>(() => new StatisticsPageViewModel());
// public static StatisticsPageViewModel Instance => lazy.Value;
public StatisticsPageViewModel() { /// <summary>
/// 入库数量统计
/// </summary>
public delegate void CountInstore(int count);
public static event CountInstore? CountInstoreEvent;
// private static readonly Lazy<StatisticsPageViewModel> lazy = new Lazy<StatisticsPageViewModel>(() => new StatisticsPageViewModel());
// public static StatisticsPageViewModel Instance => lazy.Value;
public StatisticsPageViewModel()
{
MainWindowViewModel.RefreshInfoEvent += LoadData; MainWindowViewModel.RefreshInfoEvent += LoadData;
InStoreBusiness.AddDataEvent += AddData;
LoadData(); LoadData();
} }
private readonly IRecordInStoreServices? _recordInstoreServices = App.ServiceProvider.GetService<IRecordInStoreServices>(); private readonly IRecordInStoreServices? _recordInstoreServices = App.ServiceProvider.GetService<IRecordInStoreServices>();
@ -30,36 +44,46 @@ namespace Aucma.Core.Palletiz.ViewModels
public string storeCodeB = Appsettings.app("StoreInfo", "PalletizStoreCodeB"); public string storeCodeB = Appsettings.app("StoreInfo", "PalletizStoreCodeB");
/// <summary>
/// 入库时DataGrid添加一条记录
/// </summary>
/// <returns></returns>
public void AddData(RecordInStore record)
{
MaterialDataGrid.Add(record);
CountInstoreEvent?.Invoke(MaterialDataGrid.Count);
}
#region 加载DataGrid数据 #region 加载DataGrid数据
private async Task LoadData() private async Task LoadData()
{ {
await Task.Run(() =>
{
try
{
await Task.Run(() => List<RecordInStore> list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.InStoreTime >= DateTime.Today).Result;
{ if (list != null && list.Count > 0)
try {
{ CountInstoreEvent?.Invoke(list.Count);
list.OrderByDescending(x => x.InStoreTime);
foreach (RecordInStore record in list)
{
App.Current.Dispatcher.Invoke(() =>
{
MaterialDataGrid.Add(record);
});
}
}
}
catch (Exception ex)
{
Console.WriteLine("" + ex.Message.ToString());
List<RecordInStore> list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.InStoreTime >= DateTime.Today).Result; }
if (list != null && list.Count > 0) });
{
list.OrderByDescending(x => x.InStoreTime);
foreach (RecordInStore record in list)
{
App.Current.Dispatcher.Invoke(() =>
{
MaterialDataGrid.Add(record);
});
}
}
}
catch (Exception ex)
{
Console.WriteLine("" + ex.Message.ToString());
}
});
//MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10 }); //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉SC", PlanAmount = 50, CompleteAmount = 10 });
} }
@ -93,14 +117,14 @@ namespace Aucma.Core.Palletiz.ViewModels
List<RecordInStore> list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.BarCodeCode.Contains(result)).Result; List<RecordInStore> list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.BarCodeCode.Contains(result)).Result;
if (list != null && list.Count > 0) if (list != null && list.Count > 0)
{ {
MaterialDataGrid.Clear(); App.Current.Dispatcher.Invoke(() =>
foreach (RecordInStore record in list)
{ {
App.Current.Dispatcher.Invoke(() => MaterialDataGrid.Clear();
foreach (RecordInStore record in list)
{ {
MaterialDataGrid.Add(record); MaterialDataGrid.Add(record);
}); }
} });
} }
}); });
} }

@ -108,12 +108,20 @@
<UniformGrid Grid.Row="1"> <UniformGrid Grid.Row="1">
<DataGrid ItemsSource="{Binding MaterialDataGrid}" <DataGrid ItemsSource="{Binding MaterialDataGrid}"
ColumnHeaderHeight="45" FontSize="18" ColumnHeaderHeight="45" FontSize="18"
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0" RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0" LoadingRow="DataGrid_LoadingRow"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden" GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True"
Foreground="White" > Foreground="White" >
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding No}" Header="序号" Width="1*" Visibility="Collapsed"/> <DataGridTemplateColumn Width="*" Header="序号" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow}}, Path=Header}" FontSize="18" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"></TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding BarCodeCode}" Header="成品条码" Width="3*" /> <DataGridTextColumn Binding="{Binding BarCodeCode}" Header="成品条码" Width="3*" />
<DataGridTextColumn Binding="{Binding MaterialName}" Header="成品型号" Width="3*" /> <DataGridTextColumn Binding="{Binding MaterialName}" Header="成品型号" Width="3*" />
<DataGridTextColumn Binding="{Binding StoreArea}" Header="区域" Width="1*" /> <DataGridTextColumn Binding="{Binding StoreArea}" Header="区域" Width="1*" />

@ -27,5 +27,9 @@ namespace Aucma.Core.Palletiz.Views
this.DataContext = new StatisticsPageViewModel(); this.DataContext = new StatisticsPageViewModel();
} }
private void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Header = (e.Row.GetIndex() + 1).ToString();
}
} }
} }

Loading…
Cancel
Save