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.Palletiz/ViewModels/HandPalletizViewModel.cs

133 lines
3.8 KiB
C#

using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Service;
using Aucma.Core.Palletiz.Business;
using Aucma.Core.Palletiz.Models;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using log4net;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Aucma.Core.Palletiz.ViewModels
{
public partial class HandPalletizViewModel : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(HandPalletizViewModel));
public static StackInfoModel tempStackInfo = new StackInfoModel();
private readonly IBaseSpaceInfoServices _baseSpaceInfoServices;
private readonly IRecordInStoreServices _recordInstoreServices;
public HandPalletizViewModel()
{
_baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
_recordInstoreServices = App.ServiceProvider.GetService<IRecordInStoreServices>();
Range = 1;
SpaceNo ="001";
PromptInfo("请选择信息下传......", "White");
}
#region 分垛信息下传
/// <summary>
/// 分垛信息下传
/// </summary>
[RelayCommand]
public void Save()
{
try
{
DialogResult cr = MessageBox.Show("是否确认下传分垛信息?", "系统提醒", MessageBoxButtons.OKCancel);
if (cr != DialogResult.OK)
{
return;
}
PromptInfo("分垛信息下传中......", "White");
int range = Range;
int spaceNo =Convert.ToInt32(SpaceNo);
if (spaceNo==0)
{
MessageBox.Show("请选择目的货道!","系统提醒");
return;
}
string hh = "FD01_" + SpaceNo;
Admin.Core.Model.BaseSpaceInfo spaceInfo = _baseSpaceInfoServices.FirstAsync(X => X.StoreCode.Contains("FD") && X.SpaceCode == "FD01_"+SpaceNo).Result;
if (spaceInfo == null)
{
MessageBox.Show("货道未创建!", "系统提醒");
return;
}
}
catch (Exception ex)
{
PromptInfo($"分垛信息下传失败:{ex.Message}", "Red");
}
}
#endregion
#region 提示信息
private string? msgTxt;
public string? MsgTxt
{
get => msgTxt;
set => SetProperty(ref msgTxt, value);
}
#endregion
#region 字体颜色
private string? msgColor;
public string? MsgColor
{
get => msgColor;
set => SetProperty(ref msgColor, value);
}
#endregion
#region 提示信息
/// <summary>
/// 提示信息
/// </summary>
/// <param name="mesg">提示信息</param>
/// <param name="color">提示信息颜色</param>
public void PromptInfo(string mesg, string color)
{
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
{
MsgTxt = mesg;
MsgColor = color;
}));
}
#endregion
#region 目的货道
private string spaceNo;
public string SpaceNo
{
get => spaceNo;
set => SetProperty(ref spaceNo, value);
}
#endregion
#region 方向
private int range;
public int Range
{
get => range;
set => SetProperty(ref range, value);
}
#endregion
}
}