StationModel.cs 4.67 KB
using HHECS.Application.Enums;
using HHECS.Model.Entities;
using HHECS.Model.Enums;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace HHECS.WinCommon.ViewModel
{
    /// <summary>
    /// 站台模型类
    /// </summary>
    public class StationModel : INotifyPropertyChanged
    {
        /// <summary>
        /// 可出属性
        /// </summary>
        public string CanOut { get; set; }
        public string Name { get; set; }

        public string RequestMessage { get; set; }
        public string RequestLoadStatus { get; set; }
        public string RequestNumber { get; set; }
        public string RequestBarcode { get; set; }
        public string RequestWeight { get; set; }
        public string RequestLength { get; set; }
        public string RequestWidth { get; set; }
        public string RequestHeight { get; set; }
        public string RequestRetCode { get; set; }
        public string ArriveMessage { get; set; }
        public string ArriveResult { get; set; }
        public string ArriveRealAddress { get; set; }
        public string ArriveAllcationAddress { get; set; }
        public string ArriveBarcode { get; set; }
        public string WCSReplyMessage { get; set; }
        public string WCSReplyLoadStatus { get; set; }
        public string WCSReplyNumber { get; set; }
        public string WCSReplyBarcode { get; set; }
        public string WCSReplyWeight { get; set; }
        public string WCSReplyLength { get; set; }
        public string WCSReplyWidth { get; set; }
        public string WCSReplyHeight { get; set; }
        public string WCSReplyAddress { get; set; }
        public string WCSACKMessage { get; set; }
        public string WCSACKLoadStatus { get; set; }
        public string WCSACKNumber { get; set; }

        public string Code { get; set; }

        public string StationGroupGrid { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;

        public void SetProp(List<EquipmentProp> props, List<Equipment> allEquipments)
        {
            if (props == null)
            {
                return;
            }
            foreach (var item in GetType().GetProperties())
            {
                var temp = props.FirstOrDefault(t => t.EquipmentTypePropTemplateCode == item.Name);
                if (temp != null)
                {
                    item.SetValue(this, temp.Value);
                    if (PropertyChanged != null)
                    {
                        PropertyChanged.Invoke(this, new PropertyChangedEventArgs(item.Name));
                    }
                }
                else
                {
                    if (item.Name == "CanOut")
                    {
                        Equipment station = allEquipments.FirstOrDefault(t => t.Code == Code);
                        if (station == null)
                        {
                            item.SetValue(this, "未获取");
                        }
                        else
                        {
                            //var outMonitor = allEquipments.FirstOrDefault(t => t.EquipmentType.Code == EquipmentTypeConst.StationOutMonitor.ToString() && t.DestinationArea == station.DestinationArea);
                            //if (outMonitor == null)
                            //{
                            //    item.SetValue(this, "未获取");
                            //}
                            //else
                            //{
                            //    var canout = outMonitor.EquipmentProps.FirstOrDefault(t => t.EquipmentTypePropTemplateCode == station.StationIndex.ToString());
                            //    if (canout == null)
                            //    {
                            //        item.SetValue(this, "无");
                            //    }
                            //    else
                            //    {
                            //        //if (canout.Value == StationTaskLimit.Out.GetIndexString())
                            //        //{
                            //        //    item.SetValue(this, "可出");
                            //        //}
                            //        //else
                            //        //{
                            //        //    item.SetValue(this, "不可出");
                            //        //}
                            //    }
                            //}
                        }

                        if (PropertyChanged != null)
                        {
                            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(item.Name));
                        }
                    }
                }
            }
        }
    }
}