using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Waste.Domain;

namespace Waste.Application
{
    /// <summary>
    /// 投放记录列表
    /// </summary>
    public class ResultListByEquS2CDto
    {
        /// <summary>
        /// 垃圾类别
        /// </summary>
        public string WasteType { get; set; }

        /// <summary>
        /// 物品小类别
        /// </summary>
        public string WasteSType { get; set; } = string.Empty;

        /// <summary>
        /// 重量,单位KG
        /// </summary>
        public string Weight { get; set; }

        /// <summary>
        /// 垃圾桶编号
        /// </summary>
        public string TrashCode { get; set; }

        /// <summary>
        /// 上报时间
        /// </summary>
        public long Time { get; set; }
    }

    /// <summary>
    /// 投放记录列表
    /// </summary>
    public class ResultListByEquS2SDto : ResultListByEquS2CDto
    {
        /// <summary>
        /// 上报时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 测量记录ID
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 毛重
        /// </summary>
        public decimal GrossWeight { get; set; }
    }

    /// <summary>
    /// 查询投放记录
    /// </summary>
    public class ResultListByEquC2SDto : IValidatableObject
    {
        /// <summary>
        /// 当前页
        /// </summary>
        public int offset { get; set; } = 1;

        /// <summary>
        /// 每页显示的数量
        /// </summary>
        public int limit { get; set; } = 10;

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? StartTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndTime { get; set; }

        /// <summary>
        /// 设备ID
        /// </summary>
        public Guid DeviceId { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (DeviceId == Guid.Empty)
            {
                yield return new ValidationResult("设备ID不可为空", new[] { nameof(DeviceId) });
            }
            if (limit > 100)
            {
                yield return new ValidationResult("一次最多100条记录", new[] { nameof(limit) });
            }
            if (offset <= 0)
            {
                yield return new ValidationResult("页码需从1开始", new[] { nameof(offset) });
            }
            if (StartTime.HasValue && StartTime.Value.Date > DateTime.Now.Date)
            {
                yield return new ValidationResult("开始时间不可超过当天", new[] { nameof(StartTime) });
            }
            if (EndTime.HasValue && EndTime.Value.Date > DateTime.Now.Date)
            {
                yield return new ValidationResult("结束时间不可超过当天", new[] { nameof(StartTime) });
            }
        }
    }

    public class ResultList : W_Result
    {
        /// <summary>
        /// 商户名称
        /// </summary>
        public string BusinessName { get; set; }

        /// <summary>
        /// 设备名称
        /// </summary>
        public string DeviceName { get; set; }

        /// <summary>
        /// 设备地址
        /// </summary>
        public string DeviceAddress { get; set; }

        /// <summary>
        /// 设备出厂序列号
        /// </summary>
        public string DeviceFacEcode { get; set; }

        /// <summary>
        /// 设备编号
        /// </summary>
        public string DeviceEcode { get; set; }

        /// <summary>
        /// 上报是否成功,1-成功,0-失败
        /// </summary>
        public int PostStatus { get; set; }

        /// <summary>
        /// 物品小类
        /// </summary>
        public string Measure_WasteSType { get; set; }
        /// <summary>
        /// 价格
        /// </summary>
        public decimal? Measure_Price { get; set; }
        /// <summary>
        /// 金额
        /// </summary>
        public decimal? Measure_Amount { get; set; }
        /// <summary>
        /// 操作员
        /// </summary>
        public string Measure_OpUser { get; set; }
        /// <summary>
        /// 唯一消息ID
        /// </summary>
        public string Measure_UUID { get; set; }


        public string ID1 { get; set; }
        public string ID2 { get; set; }
        public string ID3 { get; set; }
        public string ID4 { get; set; }
        public string ID5 { get; set; }
        public string ID6 { get; set; }
        public string ID7 { get; set; }
        public string ID8 { get; set; }
    }

    /// <summary>
    /// 上传的数据包体
    /// </summary>
    public class MyPackage
    {
        /// <summary>
        /// 固定头
        /// </summary>
        public string Key { get; set; } = string.Empty;

        /// <summary>
        /// 数据体长度
        /// </summary>
        public int Len { get; set; } = 0;

        /// <summary>
        /// IMEI/设备编号
        /// </summary>
        public string IMEI { get; set; } = string.Empty;

        /// <summary>
        /// ICCID
        /// </summary>
        public string ICCID { get; set; } = string.Empty;

        /// <summary>
        /// IMSI
        /// </summary>
        public string IMSI { get; set; } = string.Empty;

        /// <summary>
        /// 信号强度
        /// </summary>
        public string GSLQ { get; set; } = string.Empty;

        /// <summary>
        /// 时间
        /// </summary>
        public string Time { get; set; }

        /// <summary>
        /// 经度
        /// </summary>
        public string Longitude { get; set; } = string.Empty;

        /// <summary>
        /// 纬度
        /// </summary>
        public string Latitude { get; set; } = string.Empty;

        /// <summary>
        /// 设备地区
        /// </summary>
        public string City { get; set; } = string.Empty;

        /// <summary>
        /// 设备详细地点
        /// </summary>
        public string Area { get; set; } = string.Empty;

        /// <summary>
        /// 垃圾类别
        /// </summary>
        public string WasteType { get; set; } = string.Empty;

        /// <summary>
        /// 重量,KG
        /// </summary>
        public string Weight { get; set; } = "0";

        /// <summary>
        /// 内容
        /// </summary>
        public string Body { get; set; } = string.Empty;

        /// <summary>
        /// 字符串结果
        /// </summary>
        public string Str { get; set; } = string.Empty;

        /// <summary>
        /// 是否是否通过校检,true-是,false-否
        /// </summary>
        public bool IsChecked { get; set; } = true;

        /// <summary>
        /// 是否为心跳包数据
        /// </summary>
        public bool IsHeart { get; set; } = false;

        /// <summary>
        /// 是否为有效测量
        /// </summary>
        public bool IsWeight { get; set; } = false;
    }

    /// <summary>
    /// A8协议包内容
    /// </summary>
    public class A8Package
    {
        /// <summary>
        /// 垃圾类别小类
        /// </summary>
        public string WasteSType { get; set; } = string.Empty;

        /// <summary>
        /// 消息ID
        /// </summary>
        public string UUID { get; set; } = string.Empty;

        /// <summary>
        /// 上报时间
        /// </summary>
        public string UploadTime { get; set; } = string.Empty;

        /// <summary>
        /// 价格
        /// </summary>
        public string Price { get; set; } = string.Empty;

        /// <summary>
        /// 金额
        /// </summary>
        public string Amount { get; set; } = string.Empty;

        /// <summary>
        /// 操作员
        /// </summary>
        public string OpUser { get; set; } = string.Empty;
        /// <summary>
        /// 设备出厂序列号/设备出厂编号
        /// </summary>
        public string DeviceFacEcode { get; set; } = string.Empty;
        /// <summary>
        /// 车牌号/物品编码/垃圾桶编号
        /// </summary>
        public string Registration { get; set; } = string.Empty;
        /// <summary>
        /// 毛重,KG
        /// </summary>
        public string GrossWeight { get; set; } = string.Empty;
        /// <summary>
        /// 皮重,KG
        /// </summary>
        public string Tare { get; set; } = string.Empty;
        /// <summary>
        /// 净重,KG
        /// </summary>
        public string NetWeight { get; set; } = string.Empty;
        public string ID1 { get; set; } = string.Empty;
        public string ID2 { get; set; } = string.Empty;
        public string ID3 { get; set; } = string.Empty;
        public string ID4 { get; set; } = string.Empty;
        public string ID5 { get; set; } = string.Empty;
        public string ID6 { get; set; } = string.Empty;
        public string ID7 { get; set; } = string.Empty;
        public string ID8 { get; set; } = string.Empty;
        public string DataHash { get; set; } = "";
    }

    /// <summary>
    /// A8协议模块上传的数据包体
    /// </summary>
    public class A8MyPackage : A8Package
    {
        /// <summary>
        /// 固定头
        /// </summary>
        public string Key { get; set; } = string.Empty;

        /// <summary>
        /// 数据体长度
        /// </summary>
        public int Len { get; set; } = 0;

        /// <summary>
        /// IMEI
        /// </summary>
        public string IMEI { get; set; } = string.Empty;

        /// <summary>
        /// ICCID
        /// </summary>
        public string ICCID { get; set; } = string.Empty;

        /// <summary>
        /// IMSI
        /// </summary>
        public string IMSI { get; set; } = string.Empty;

        /// <summary>
        /// 信号强度
        /// </summary>
        public string GSLQ { get; set; } = string.Empty;

        /// <summary>
        /// 时间
        /// </summary>
        public string Time { get; set; }

        /// <summary>
        /// 经度
        /// </summary>
        public string Longitude { get; set; } = string.Empty;

        /// <summary>
        /// 纬度
        /// </summary>
        public string Latitude { get; set; } = string.Empty;

        /// <summary>
        /// 桶大小
        /// </summary>
        public string size { get; set; } = string.Empty;

        /// <summary>
        /// 垃圾桶编号
        /// </summary>
        public string trashcode { get; set; } = string.Empty;

        /// <summary>
        /// 垃圾类别
        /// </summary>
        public string WasteType { get; set; } = string.Empty;

        /// <summary>
        /// 重量,KG
        /// </summary>
        public string Weight { get; set; } = "0";

        /// <summary>
        /// 内容
        /// </summary>
        public string Body { get; set; } = string.Empty;

        /// <summary>
        /// 字符串结果
        /// </summary>
        public string Str { get; set; } = string.Empty;

        /// <summary>
        /// 是否是否通过校检,true-是,false-否
        /// </summary>
        public bool IsChecked { get; set; } = true;

        /// <summary>
        /// 是否为心跳包数据
        /// </summary>
        public bool IsHeart { get; set; } = false;

        /// <summary>
        /// 是否为有效测量
        /// </summary>
        public bool IsWeight { get; set; } = false;
    }

    /// <summary>
    /// 新的4G模块上传的数据包体
    /// </summary>
    public class nMyPackage
    {
        /// <summary>
        /// 固定头
        /// </summary>
        public string Key { get; set; } = string.Empty;

        /// <summary>
        /// 数据体长度
        /// </summary>
        public int Len { get; set; } = 0;

        /// <summary>
        /// IMEI
        /// </summary>
        public string IMEI { get; set; } = string.Empty;

        /// <summary>
        /// ICCID
        /// </summary>
        public string ICCID { get; set; } = string.Empty;

        /// <summary>
        /// IMSI
        /// </summary>
        public string IMSI { get; set; } = string.Empty;

        /// <summary>
        /// 信号强度
        /// </summary>
        public string GSLQ { get; set; } = string.Empty;

        /// <summary>
        /// 时间
        /// </summary>
        public string Time { get; set; }

        /// <summary>
        /// 经度
        /// </summary>
        public string Longitude { get; set; } = string.Empty;

        /// <summary>
        /// 纬度
        /// </summary>
        public string Latitude { get; set; } = string.Empty;

        /// <summary>
        /// 桶大小
        /// </summary>
        public string size { get; set; } = string.Empty;

        /// <summary>
        /// 垃圾桶编号
        /// </summary>
        public string trashcode { get; set; } = string.Empty;

        /// <summary>
        /// 垃圾类别
        /// </summary>
        public string WasteType { get; set; } = string.Empty;

        /// <summary>
        /// 重量,KG
        /// </summary>
        public string Weight { get; set; } = "0";

        /// <summary>
        /// 内容
        /// </summary>
        public string Body { get; set; } = string.Empty;

        /// <summary>
        /// 字符串结果
        /// </summary>
        public string Str { get; set; } = string.Empty;

        /// <summary>
        /// 是否是否通过校检,true-是,false-否
        /// </summary>
        public bool IsChecked { get; set; } = true;

        /// <summary>
        /// 是否为心跳包数据
        /// </summary>
        public bool IsHeart { get; set; } = false;

        /// <summary>
        /// 是否为有效测量
        /// </summary>
        public bool IsWeight { get; set; } = false;
    }

    /// <summary>
    /// wifi模块上传的数据包体
    /// </summary>
    public class WifiPackage
    {
        /// <summary>
        /// 设备机器码
        /// </summary>
        public string sn { get; set; }

        /// <summary>
        /// 桶大小
        /// </summary>
        public string size { get; set; } = string.Empty;

        /// <summary>
        /// 垃圾桶编号
        /// </summary>
        public string trashcode { get; set; } = string.Empty;

        /// <summary>
        /// 垃圾类别
        /// </summary>
        public string WasteType { get; set; } = string.Empty;

        /// <summary>
        /// 重量,KG
        /// </summary>
        public string Weight { get; set; } = "0";

        /// <summary>
        /// 是否为心跳包
        /// </summary>
        public bool IsHeart { get; set; } = false;
    }
}