using HandyControl.Controls; using Ping9719.WpfEx; using Ping9719.WpfEx.Mvvm; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Markup; using WCS.Model; using WCS.Model.ApiModel.Home; using 智能仓储WCS管理系统.Api; namespace 智能仓储WCS管理系统.ViewModel { public class DeviceViewModel : BindableBase { public ICommand ResetAllShelfCommand { get => new DelegateCommand(ResetAllShelf); } /// /// 打开用户 /// public void ResetAllShelf() { #region 调用接口 请求重置所有货架的状态 var body = new ResetShelfStatusRequest() { IsResetAll = true, GroupNames = LocalFile.Config.GroupName, UserName = LocalStatic.CurrentUser, DeviceType = LocalFile.Config.DeviceType, }; var Result = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "home/resetShelfStatus", body, "POST"); if (Result != null && Result.Code == 200) { Growl.Warning("复位成功!"); } else if (Result != null) { Growl.Warning(Result.Message); } else { Growl.Warning("调用接口失败!"); } #endregion } public ICommand BarcodePrintTemplateCommand { get => new DelegateCommand(BarcodePrintTemplate); } public void BarcodePrintTemplate() { try { Folder.OpenFolderAndSelectedFile(LocalFile.PrintTemplatePath); } catch (Exception) { Growl.Error("打开文件夹失败。"); } } public ICommand NoResponseResetCommand { get => new DelegateCommand(NoResponseReset); } /// /// 打开用户 /// public void NoResponseReset() { var result = HandyControl.Controls.MessageBox.Show("此功能用于“未成功退出入库、出库”等异常提示\r\n建议所有货架都处于待机模式时使用,继续复位请点击[确定]", "提示", MessageBoxButton.OKCancel); if (result == MessageBoxResult.Cancel) return; #region 调用接口 请求重置所有货架的状态 var body = new RequestBase() { UserName = LocalStatic.CurrentUser, DeviceType = LocalFile.Config.DeviceType, }; var Result = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "home/noResponseReset", body, "POST"); if (Result != null && Result.Code == 200) { Growl.Warning("已给状态不一致的板子发送复位指令,建议点击第一个按钮[货架状态初始化]重置所有货架状态!"); } else if (Result != null) { Growl.Warning(Result.Message); } else { Growl.Warning("调用接口失败!"); } #endregion } } public class DeviceReadModel : BindableBase { #region 属性 private string Name_; /// /// 名称 /// public string Name { get => Name_; set { SetProperty(ref Name_, value); } } private object Value_; /// /// 值 /// public object Value { get => Value_; set { SetProperty(ref Value_, value); } } /// /// 是否可见 /// public bool IsExpanded { get; set; } /// /// Excel原始数据 /// public ExcelDeviceReadModel ExcelTag { get; set; } #endregion } public class DeviceWriteModel : BindableBase { #region 属性 private string Name_; /// /// 名称 /// public string Name { get => Name_; set { SetProperty(ref Name_, value); } } private object Value_; /// /// 是否合格 /// public object Value { get => Value_; set { SetProperty(ref Value_, value); } } /// /// 是否可见 /// public bool IsExpanded { get; set; } /// /// Excel原始数据 /// public ExcelDeviceWriteModel ExcelTag { get; set; } #endregion } public class DeviceUrnModel : BindableBase { #region 属性 private string Name_; /// /// 名称 /// public string Name { get => Name_; set { SetProperty(ref Name_, value); } } private bool IsGoTo_; /// /// 是否推到位 /// public bool IsGoTo { get => IsGoTo_; set { SetProperty(ref IsGoTo_, value); } } private bool IsRetTo_; /// /// 是否回到位 /// public bool IsRetTo { get => IsRetTo_; set { SetProperty(ref IsRetTo_, value); } } /// /// 是否可见 /// public bool IsExpanded { get; set; } /// /// 自定义数据 /// public ExcelDeviceUrnModel ExcelTag { get; set; } #endregion } public class DeviceServoModel : BindableBase { #region 属性 private string Name_; /// /// 名称 /// public string Name { get => Name_; set { SetProperty(ref Name_, value); } } private double JogSpeed_; /// /// 手动模式速度 /// public double JogSpeed { get => JogSpeed_; set { SetProperty(ref JogSpeed_, value); } } private double AutoSpeed_; /// /// 自动模式速度 /// public double AutoSpeed { get => AutoSpeed_; set { SetProperty(ref AutoSpeed_, value); } } private double Location_; /// /// 伺服当前位置 /// public double Location { get => Location_; set { SetProperty(ref Location_, value); } } private bool IsJog_ = true; /// /// 是否主页显示为手动模式 /// public bool IsJog { get => IsJog_; set { SetProperty(ref IsJog_, value); } } private bool IsFold_ = true; /// /// 是否折叠 /// public bool IsFold { get => IsFold_; set { SetProperty(ref IsFold_, value); } } /// /// 是否可见 /// public bool IsExpanded { get; set; } private ExcelDeviceServoModel ExcelTag_; /// /// 自定义数据 /// public ExcelDeviceServoModel ExcelTag { get => ExcelTag_; set { SetProperty(ref ExcelTag_, value); } } #endregion } }