using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataVAPI.Tool.IOT
{

    /// <summary>
    /// 大屏监视Model
    /// </summary>
    public class ScreenMonitorModel
    {
        /// <summary>
        /// 服务商家数
        /// </summary>
        public string TotalSales { get; set; }
        /// <summary>
        /// 现场运营设备状态
        /// </summary>
        public OperatingDeviceStatus operatingDeviceStatus { get; set; }
        /// <summary>
        /// 通知消息
        /// </summary>
        public InfoMessage infoMessage { get; set; }
        /// <summary>
        /// 返回JSON
        /// </summary>
        /// <returns></returns>
        public string ToJSON()
        {
            try
            {
                return Tools.JsonConvertTools(this);
            }
            catch (Exception ex)
            {
                return string.Empty;
            }
        }
        /// <summary>
        /// 序列化为对象
        /// </summary>
        /// <param name="JSON"></param>
        /// <returns></returns>
        public ScreenMonitorModel JSONtoDX(string JSON)
        {
            try
            {
                return Tools.JsonToObjectTools<ScreenMonitorModel>(JSON);
            }
            catch (Exception ex)
            {
                return new ScreenMonitorModel();
            }
        }
    }
    /// <summary>
    /// 下订单统计
    /// </summary>
    public class PlaceOrderCount
    {
        /// <summary>
        /// 今日下单量统计
        /// </summary>
        public string ToDayPlaceCount { get; set; }
        /// <summary>
        /// 本月下单量统计
        /// </summary>
        public string MonthPlaceCount { get; set; }
        /// <summary>
        /// 本年下单量统计
        /// </summary>
        public string YearPlaceCount { get; set; }

    }
    /// <summary>
    /// 制作流程
    /// </summary>
    public class ProcessMessage
    {
        public List<ProcessModel> data { get; set; }
    }
    /// <summary>
    /// 制作流程Model
    /// </summary>
    public class ProcessModel
    {
        /// <summary>
        /// 告警程度：提示 一般 严重
        /// </summary>
        private bool _IsMark { get; set; }
        public bool IsMark
        {
            get { return _IsMark; }
            set
            {
                _IsMark = value;
                if (_IsMark) ProcessColor = new ALYColor { r = 253, g = 234, b = 1, a = 1 };
                else ProcessColor = new ALYColor { r = 151, g = 150, b = 140, a = 1 };
            }
        }
        /// <summary>
        /// 流程名称
        /// </summary>
        public string ProcessName { get; set; }
        /// <summary>
        /// 流程描述
        /// </summary>
        public string ProcessMS { get; set; }
        /// <summary>
        /// 颜色
        /// </summary>
        public ALYColor ProcessColor { get; set; }
        public ProcessModel()
        {
            IsMark = false;
            ProcessMS = string.Empty;
            ProcessName = string.Empty;
        }

    }

    /// <summary>
    /// 通知消息
    /// </summary>
    public class InfoMessage
    {
        public List<DeviceBase> data { get; set; }

    }
    /// <summary>
    /// 运营设备及状态
    /// </summary>
    public class OperatingDeviceStatus
    {
        public List<DevStatus> data { get; set; }
    }
    /// <summary>
    /// 设备状态
    /// </summary>
    public class DevStatus : DeviceBase
    {
        /// <summary>
        /// 设备状态
        /// </summary>
        public string DeviceZT
        {
            get { return _DeviceZT; }
            set
            {
                _DeviceZT = value;
                if (_DeviceZT == "在线") DeviceColor = new ALYColor { r = 13, g = 254, b = 73, a = 1 };
                else DeviceColor = new ALYColor { r = 249, g = 191, b = 0, a = 1 };
            }
        }
        private string _DeviceZT { get; set; }
        /// <summary>
        /// 是否有告警
        /// </summary>
        public bool IsAlarm
        {
            get { return _IsAlarm; }
            set
            {
                _IsAlarm = value;
                if (_IsAlarm) AlarmColor = new ALYColor { r = 245, g = 13, b = 13, a = 1 };
                else AlarmColor = new ALYColor { r = 245, g = 13, b = 13, a = 0 };
            }
        }
        private bool _IsAlarm { get; set; }

        /// <summary>
        /// 颜色
        /// </summary>
        public ALYColor DeviceColor { get; set; }
        /// <summary>
        /// 告警颜色
        /// </summary>
        public ALYColor AlarmColor { get; set; }
        /// <summary>
        /// 初始化
        /// </summary>
        public DevStatus()
        {
            IsAlarm = false;
            AlarmColor = new ALYColor { r = 245, g = 13, b = 13, a = 0 };
            DeviceColor = new ALYColor { r = 249, g = 191, b = 0, a = 1 };
        }
        /// <summary>
        /// 设置属性
        /// </summary>
        /// <param name="_deviceName"></param>
        /// <param name="_gmtCreate"></param>
        /// <param name="_DeviceMC"></param>
        /// <param name="_DeviceMS"></param>
        /// <param name="_DeviceSJ"></param>
        /// <param name="_DeviceZT"></param>
        public void SetTarget(string _deviceName, string _gmtCreate, string _DeviceMC, string _DeviceMS, string _DeviceSJ, string _DeviceZT)
        {
            deviceName = _deviceName;
            gmtCreate = _gmtCreate;
            DeviceMC = _DeviceMC;
            DeviceMS = _DeviceMS;
            DeviceSJ = _DeviceSJ;
            DeviceZT = _DeviceZT;
        }
        /// <summary>
        /// 状态
        /// </summary>
        /// <param name="_DeviceZT"></param>
        public void SetStatus(string _DeviceZT)
        {
            DeviceSJ = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            DeviceZT = _DeviceZT;
        }
    }
    /// <summary>
    /// 设备基本属性
    /// </summary>
    public class DeviceBase : DevBase
    {
        /// <summary>
        /// 设备名称
        /// </summary>
        public string DeviceMC { get; set; }
        /// <summary>
        /// 设备描述
        /// </summary>
        public string DeviceMS { get; set; }
        /// <summary>
        /// 设备时间
        /// </summary>
        public string DeviceSJ { get; set; }
        /// <summary>
        /// 设备状态：已处理 未处理
        /// </summary>
        public string DeviceZT { get; set; }
    }
    /// <summary>
    /// 设备基本信息
    /// </summary>
    public class DevBase
    {
        /// <summary>
        /// 唯一id
        /// </summary>
        public string id { get; set; }
        /// <summary>
        /// 设备key
        /// </summary>
        public string productKey { get; set; }
        /// <summary>
        /// 设备名称
        /// </summary>
        public string deviceName { get; set; }
        /// <summary>
        /// gmtCreate
        /// </summary>
        public string gmtCreate { get; set; }
        /// <summary>
        /// 客户端ID
        /// </summary>
        public string clientId { get; set; }

        public DevBase()
        {
            id = Guid.NewGuid().ToString();
        }
    }



}
