|
|
using Admin.Core.Common;
|
|
|
using Admin.Core.IService;
|
|
|
using Admin.Core.Model;
|
|
|
using Admin.Core.Service;
|
|
|
using Aucma.Core.BoxFoam.Models;
|
|
|
using Aucma.Core.BoxFoam.Views.UserPage;
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
using log4net;
|
|
|
using MaterialDesignThemes.Wpf;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using Microsoft.IdentityModel.Logging;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using static NPOI.SS.Formula.PTG.AttrPtg;
|
|
|
|
|
|
namespace Aucma.Core.BoxFoam.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() {
|
|
|
|
|
|
// 设置型号
|
|
|
SubmitCommand = new RelayCommand<string>(obj => SubmitCommandExecute(obj));
|
|
|
SubmitCommand2 = new RelayCommand<string>(obj => SubmitCommandExecute2(obj));
|
|
|
SubmitCommand3 = new RelayCommand<string>(obj => SubmitCommandExecute3(obj));
|
|
|
SetBoxTypeCommand = new RelayCommand<string>(obj => SetBoxTypeCommandExecute(obj));
|
|
|
_baseSpaceDetailServices = App.ServiceProvider.GetService<IBaseSpaceDetailServices>();
|
|
|
_baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
|
|
|
SetBoxTypeViewModel.RefreshPageEvent += LoadSpaceStoreMedthAsync;
|
|
|
SelectTypeViewModel.RefreshPageEvent += LoadSpaceStoreMedthAsync;
|
|
|
this.LoadSpaceStoreMedthAsync();
|
|
|
}
|
|
|
#region 参数定义
|
|
|
/// <summary>
|
|
|
/// 设置型号
|
|
|
/// </summary>
|
|
|
public RelayCommand<string> SubmitCommand { get; set; }
|
|
|
|
|
|
private void SubmitCommandExecute(string spaceCode)
|
|
|
{
|
|
|
|
|
|
SelectType type = new SelectType(1, spaceCode);
|
|
|
type.ShowDialog();
|
|
|
|
|
|
}
|
|
|
|
|
|
public RelayCommand<string> SubmitCommand2 { get; set; }
|
|
|
|
|
|
private void SubmitCommandExecute2(string spaceCode)
|
|
|
{
|
|
|
|
|
|
SelectType type = new SelectType(2, spaceCode);
|
|
|
type.ShowDialog();
|
|
|
|
|
|
}
|
|
|
|
|
|
public RelayCommand<string> SubmitCommand3 { get; set; }
|
|
|
|
|
|
private void SubmitCommandExecute3(string spaceCode)
|
|
|
{
|
|
|
|
|
|
SelectType type = new SelectType(3, spaceCode);
|
|
|
type.ShowDialog();
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 设置夹具型号
|
|
|
/// </summary>
|
|
|
public RelayCommand<string> SetBoxTypeCommand { get; set; }
|
|
|
|
|
|
private void SetBoxTypeCommandExecute(string spaceCode)
|
|
|
{
|
|
|
SetBoxType boxTypePage = new SetBoxType(spaceCode);
|
|
|
boxTypePage.ShowDialog();
|
|
|
Console.WriteLine(spaceCode);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 加载泡前库货道信息
|
|
|
/// <summary>
|
|
|
/// 加载泡前库货道信息
|
|
|
/// </summary>
|
|
|
private void LoadSpaceStoreMedthAsync()
|
|
|
{
|
|
|
string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
|
|
|
|
|
|
var baseSpaceInfolist = _baseSpaceInfoServices.QueryAsync(d => d.StoreCode==storeCode).Result;//仓库
|
|
|
|
|
|
if (baseSpaceInfolist == null) return;
|
|
|
if (baseSpaceInfolist.Count > 0)
|
|
|
{
|
|
|
baseSpaceInfolist = baseSpaceInfolist.OrderBy(x => x.ObjId).ToList();
|
|
|
}
|
|
|
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.typeCodeB = item.typeCodeB;
|
|
|
model.typeCodeC = item.typeCodeC;
|
|
|
model.typeNameA = GetSubstringBetweenCommas(item.typeNameA);
|
|
|
model.typeNameB = GetSubstringBetweenCommas(item.typeNameB);
|
|
|
model.typeNameC = GetSubstringBetweenCommas(item.typeNameC);
|
|
|
model.unusualFlag = item.UnusualFlag == 2 ? "Red" : "White";
|
|
|
// 夹具型号
|
|
|
model.boxType = item.BoxType;
|
|
|
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
|
|
|
|
|
|
/// <summary>
|
|
|
/// 截取两个逗号之间的字符串
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
static string GetSubstringBetweenCommas(string input)
|
|
|
{
|
|
|
if (input == null) return null;
|
|
|
// 找到第一个逗号的位置
|
|
|
int firstCommaIndex = input.IndexOf(',');
|
|
|
if (firstCommaIndex != -1)
|
|
|
{
|
|
|
// 找到第二个逗号的位置
|
|
|
int secondCommaIndex = input.IndexOf(',', firstCommaIndex + 1);
|
|
|
if (secondCommaIndex != -1)
|
|
|
{
|
|
|
// 使用Substring截取第一个逗号和第二个逗号之间的字符
|
|
|
return input.Substring(firstCommaIndex + 1, secondCommaIndex - firstCommaIndex - 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#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 info)
|
|
|
{
|
|
|
var storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//内胆库号
|
|
|
List<BaseSpaceDetail> list = _baseSpaceDetailServices.GetSpaceDetailsBySpaceCode(storeCode, info).Result;
|
|
|
|
|
|
RefreshSpaceDetails(list);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 刷新货道明细列表
|
|
|
/// </summary>
|
|
|
/// <param name="spaceDetails"></param>
|
|
|
private void RefreshSpaceDetails(List<BaseSpaceDetail> spaceDetails)
|
|
|
{
|
|
|
SpaceDetailDataGrid = new ObservableCollection<BaseSpaceDetail>();
|
|
|
if (spaceDetails != null)
|
|
|
{
|
|
|
spaceDetails.ForEach(
|
|
|
arg =>
|
|
|
{
|
|
|
SpaceDetailDataGrid.Add(arg);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
private ObservableCollection<BaseSpaceDetail> spaceDetailDataGrid;
|
|
|
|
|
|
public ObservableCollection<BaseSpaceDetail> SpaceDetailDataGrid
|
|
|
{
|
|
|
get => spaceDetailDataGrid;
|
|
|
set => SetProperty(ref spaceDetailDataGrid, value);
|
|
|
}
|
|
|
#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
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 货道入库标识设置
|
|
|
/// </summary>
|
|
|
/// <param name="obj"></param>
|
|
|
private async void UpdateInStoreFlag(object obj)
|
|
|
{
|
|
|
string info = obj as string;
|
|
|
string shellStoreCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
|
|
|
bool result =await UpdateInStoreFlag(shellStoreCode, info);
|
|
|
if (result)
|
|
|
{
|
|
|
//Query();
|
|
|
//MessageBoxTimeoutA((IntPtr)0, $"货道入库状态修改成功,3秒后关闭提示", "提示", 0, 0, 3000);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("货道入库状态修改失败", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 修改货道入库标识
|
|
|
/// </summary>
|
|
|
/// <param name="storeCode"></param>
|
|
|
/// <param name="spaceCode"></param>
|
|
|
|
|
|
public async Task<bool> UpdateInStoreFlag(string storeCode, string spaceCode)
|
|
|
{
|
|
|
bool result = false;
|
|
|
try
|
|
|
{
|
|
|
|
|
|
BaseSpaceInfo spaceInfo =await _baseSpaceInfoServices.GetSpaceInfoBySpaceCode(storeCode, spaceCode);
|
|
|
if (spaceInfo != null)
|
|
|
{
|
|
|
spaceInfo.InStoreFlag = spaceInfo.InStoreFlag == 1 ? 2 : 1;
|
|
|
result =await _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo);
|
|
|
//logHelper.Info($"修改仓库:{storeCode};货道:{spaceCode};入库标识:{spaceInfo.inStoreFlag};修改{(result == true ? "成功" : "失败")}");
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
//logHelper.Error("修改货道入库标识异常", ex);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
}
|