You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AUCMA_SCADA/Aucma.Core.BoxFoaming/ViewModels/BeforeFoamingPageModelView.cs

137 lines
4.8 KiB
C#

using Admin.Core.Common;
using Admin.Core.IService;
using Admin.Core.Service;
using Aucma.Core.BoxFoaming.Models;
using Aucma.Core.BoxFoaming.Views.UserPage;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using log4net;
using MaterialDesignThemes.Wpf;
using Microsoft.Extensions.DependencyInjection;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Windows;
using static NPOI.SS.Formula.PTG.AttrPtg;
namespace Aucma.Core.BoxFoaming.ViewModels
{
public partial class BeforeFoamingPageModelView : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
private readonly IBaseSpaceDetailServices? _baseSpaceDetailServices;
private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices;
public BeforeFoamingPageModelView() {
_baseSpaceDetailServices = App.ServiceProvider.GetService<IBaseSpaceDetailServices>();
_baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
this.LoadSpaceStoreMedthAsync();
}
#region 加载泡前库货道信息
/// <summary>
/// 加载泡前库货道信息
/// </summary>
private async void LoadSpaceStoreMedthAsync()
{
string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
var baseSpaceInfolist = await _baseSpaceInfoServices.QueryAsync(d => d.StoreCode.Equals(storeCode));//仓库
Shapes.Clear();
foreach (var item in baseSpaceInfolist)
{
SpaceInfoModel model=new SpaceInfoModel();
model.spaceCode = item.SpaceCode;
model.spaceStock = item.SpaceStock;
model.onTheWay = item.OnRouteAmount;
model.totalAmount = item.SpaceStock + item.OnRouteAmount;
model.materialType = item.MaterialType;
model.unusualFlag = item.UnusualFlag == 2 ? "Red" : "White";
if (item.SpaceStatus == 2)
{
model.setEnable = "False";
model.inStoreFlag = "Red";
model.isFlag = "Red";
}
else
{
model.isFlag = item.IsFlag.ToString(); //禁用状态
model.inStoreFlag ="White";
}
model.onlyOne = 1;
model.spaceType = item.SpaceType;
Shapes.Add(model);
}
}
#endregion
#region 初始化
private ObservableCollection<SpaceInfoModel> _shapes = new ObservableCollection<SpaceInfoModel>();
public ObservableCollection<SpaceInfoModel> Shapes
{
get => _shapes;
set => SetProperty(ref _shapes, value);
}
#endregion
#region 货道明细
[RelayCommand]
private void SpaceDetail(string spaceCode)
{
string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
SpaceDetailPageView page = new SpaceDetailPageView(storeCode, spaceCode);
page.ShowDialog();
}
#endregion
#region 禁用货道
[RelayCommand]
private async Task IsEnableSpace(string spaceCode)
{
string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
var list= await _baseSpaceInfoServices.QueryAsync(d => d.StoreCode.Equals(storeCode) && d.SpaceCode.Equals(spaceCode));
list.ForEach(d =>
{
d.SpaceStatus = 2;
});
var result= await _baseSpaceInfoServices.UpdateAsync(list);
if (result)
{
MessageBox.Show($"禁用货道[{spaceCode}] 成功!");
LoadSpaceStoreMedthAsync();
}
else
{
MessageBox.Show($"禁用货道[{spaceCode}] 失败!");
}
}
#endregion
#region 入库
[RelayCommand]
private void EnterSpace(string spaceCode)
{
string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
//SpaceDetailPageView page = new SpaceDetailPageView(storeCode, spaceCode);
//page.ShowDialog();
}
#endregion
#region 出库
[RelayCommand]
private void OutSpace(string spaceCode)
{
//string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
//SpaceDetailPageView page = new SpaceDetailPageView(storeCode, spaceCode);
//page.ShowDialog();
}
#endregion
}
}