using APT.BaseData.Domain.ApiModel.PF;
using APT.BaseData.Domain.Entities;
using APT.BaseData.Domain.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace APT.BaseData.Domain.ApiModel
{
    /// <summary>
    /// 图表配置
    /// </summary>
    public class ChartPageModel
    {
        /// <summary>
        /// 构造
        /// </summary>
        public ChartPageModel()
        {
            this.Nav_PageCharts = new List<T_PF_PAGE_CHART>();
        }
        /// <summary>
        /// 表单
        /// </summary>
        public T_PF_FORM Nav_PageForm { get; set; }

        /// <summary>
        /// 图表配置信息
        /// </summary>
        public List<T_PF_PAGE_CHART> Nav_PageCharts { get; set; }


    }

    /// <summary>
    /// 图表接口统一数据结构
    /// </summary>
    public class ChartDataModel
    {
        /// <summary>
        /// 图表名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 构造函数
        /// </summary>
        public ChartDataModel()
        {
            this.XAxis = new List<ChartDataXAxisModel>();
            this.YAxis = new List<ChartDataYAxisModel>();
            this.Data = new List<ChartDataDetailModel>();
            this.Radar = new List<IndiCatorModel>();
        }
        /// <summary>
        /// X轴数据   至少存在一笔记录 
        /// </summary>
        public List<ChartDataXAxisModel> XAxis { get; set; }

        /// <summary>
        /// Y轴数据（可选）
        /// </summary>
        public List<ChartDataYAxisModel> YAxis { get; set; }


        /// <summary>
        /// 分组数据  至少存在一笔
        /// </summary>
        public List<ChartDataDetailModel> Data { get; set; }

        public List<IndiCatorModel> Radar { get; set; }

    }


    /// <summary>
    /// X轴 数据
    /// </summary>
    public class ChartDataXAxisModel
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public ChartDataXAxisModel()
        {
            this.Data = new List<string>();
        }

        /// <summary>
        /// 数据
        /// </summary>
        public List<string> Data { get; set; }
    }

    /// <summary>
    /// Y轴数据
    /// </summary>
    public class ChartDataYAxisModel
    {
        /// <summary>
        /// 数据分组名称 与分组数据中的Name对应
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 最大值
        /// </summary>
        public double Max { get; set; }
        /// <summary>
        /// 最小值
        /// </summary>
        public double Min { get; set; }
        /// <summary>
        /// 是否翻转
        /// </summary>
        public bool IsInverse { get; set; }
    }

    /// <summary>
    /// 分组数据 
    /// </summary>
    public class ChartDataDetailModel
    {
        /// <summary>
        /// 
        /// </summary>
        public ChartDataDetailModel()
        {
            this.Data = new List<ChartDataValueModel>();
        }

        public string Key { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// PFChartTypeEnum
        /// </summary>
        public int ChartType { get; set; } = (int)PFChartTypeEnum.bar;

        public string Stack { get; set; }

        /// <summary>
        /// 颜色
        /// </summary>
        public string Color { get; set; }

        /// <summary>
        /// Y轴索引 从0开始 
        /// </summary>
        public int YAxisIndex { get; set; }

        /// <summary>
        /// X轴索引 从0开始 
        /// </summary>
        public int XAxisIndex { get; set; }

        /// <summary>
        /// 类型bar或者line
        /// </summary>
        public string Type
        {
            get { return ((PFChartTypeEnum)ChartType).ToString(); }
        }

        /// <summary>
        /// 类型dashed虚线
        /// </summary>
        public string LineType { get; set; }

        public bool LegendSelected { get; set; } = true;

        public string LegendIcon { get; set; }

        /// <summary>
        /// 值 个数必须与XAxis的Data个数相同
        /// </summary>
        public List<ChartDataValueModel> Data { get; set; }
        /// <summary>
        /// 分段样式
        /// </summary>
        public List<Piece> Pieces { get; set; }

        public PiecesOption PiecesOption { get; set; }
    }

    public class Piece
    {
        public int gt { get; set; }
        public int lte { get; set; }
        public string color { get; set; }

    }

    public class PiecesOption
    {
        public string symbol { get; set; }
        public AreaStyle areaStyle { get; set; }

    }
    /// <summary>
    /// 区域样式
    /// </summary>
    public class AreaStyle
    {
        /// <summary>
        /// 透明度
        /// </summary>
        public decimal opacity { get; set; }
    }
    /// <summary>
    /// 值
    /// </summary>
    public class ChartDataValueModel
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public ChartDataValueModel()
        {
            this.Heads = new List<string>();
            this.Data = new List<List<string>>();
        }
        /// <summary>
        /// 值
        /// </summary>
        public double Value { get; set; }
        public string TooltipValue { get; set; }
        public int YAxisIndex { get; set; }//Y轴

        /// <summary>
        /// 表头
        /// </summary>
        public List<string> Heads { get; set; }

        /// <summary>
        /// 表身
        /// </summary>
        public List<List<string>> Data { get; set; }
    }


    /// <summary>
    /// 桑基图图表数据实体模型
    /// </summary>
    public class SankeyCharModel
    {
        public List<NodeModel> Nodes { get; set; }

        public List<LinkModel> Links { get; set; }

        public List<LevelModel> Levels { get; set; }
    }

    public class LinkModel
    {
        /// <summary>
        /// 源
        /// </summary>
        public string source { get; set; }
        /// <summary>
        /// 目标
        /// </summary>
        public string target { get; set; }
        /// <summary>
        /// 值
        /// </summary>
        public decimal value { get; set; }
        /// <summary>
        /// 自定义显示内容
        /// </summary>
        public string text { get; set; }

        public Dictionary<string, string> lineStyle { get; set; }
    }

    public class NodeModel
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 编码
        /// </summary>
        public string code { get; set; }

        public decimal LossRate { get; set; }

        public decimal value { get; set; }

        public List<ViewModel> views { get; set; }

        public Dictionary<string, string> itemStyle { get; set; }
    }

    public class LevelModel
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string name { get; set; }

        /// <summary>
        /// 层级
        /// </summary>
        public int level { get; set; }

        /// <summary>
        /// 当前层级总用量
        /// </summary>
        public decimal value { get; set; }
        /// <summary>
        /// 颜色
        /// </summary>
        public string color { get; set; }

        /// <summary>
		/// 视图
		/// </summary>
		public List<ViewModel> views { get; set; }

        /// <summary>
        /// 层级节点数量
        /// </summary>
        public List<NodeModel> nodes { get; set; }
    }

    public class ViewModel
    {
        /// <summary>
        /// 名称
        /// </summary>
		public string name { get; set; }

        /// <summary>
        /// 值
        /// </summary>
        public decimal value { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        public string unit { get; set; }
    }

    /// <summary>
    /// 雷达图数据实体模型
    /// </summary>
    public class IndiCatorModel
    {
        public List<IndiCatorItemModel> IndiCator { get; set; }
    }

    public class IndiCatorItemModel
    {
        public string Text { get; set; }

        public decimal Max { get; set; }
    }

    #region 大屏
    public class ApplianceInfoModel
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        public string Code { get; set; }

        /// <summary>
        /// 总数
        /// </summary>
        public int Total { get; set; }

        /// <summary>
        /// 在线
        /// </summary>
        public int Online { get; set; }
        public string Img { get; set; }
    }


    public class EnergyDosageScan
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        public string Code { get; set; }
        /// <summary>
        /// 用量
        /// </summary>
        public List<EnergyDosageTime> EnergyList { get; set; }
    }

    public class EnergyDosageTime
    {
        public string Time { get; set; }

        public decimal Value { get; set; }
    }
    public class EneryUseModel
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        public string Code { get; set; }

        /// <summary>
        /// 总数
        /// </summary>
        public string Total { get; set; }


        /// <summary>
        /// 总数
        /// </summary>
        public decimal iTotal { get; set; }

        /// <summary>
        /// 在线
        /// </summary>
        public decimal Percent { get; set; }
        public string Color { get; set; }
    }

    public class EneryUseModelByDept
    {
        public string Title { get; set; }
        public List<EneryUseModel> Data { get; set; }
    }
    /// <summary>
    /// 部门本月用电量排行
    /// </summary>
    public class EneryDosageByDept
    {
        public string Title { get; set; }
        public List<RankingTableData> dataSource { get; set; }

        public List<Column> columns { get; set; }
    }
    public class RankingTableData
    {
        public int Ranking { get; set; }

        public string Name { get; set; }

        public string Value { get; set; }
        public string Ratio { get; set; }
    }
    public class SummaryInfoModel
    {
        /// <summary>
        /// 月总能耗
        /// </summary>
        public decimal MonthEnergyConsu { get; set; }
        /// <summary>
        /// 日总能耗
        /// </summary>
        public decimal DayEnergyConsu { get; set; }
        /// <summary>
        /// 同比能耗
        /// </summary>
        public decimal YearOnYearConsu { get; set; }
        /// <summary>
        /// 环比能耗
        /// </summary>
        public decimal MonthOnMonthConsu { get; set; }
        /// <summary>
        /// 用量
        /// </summary>
        public List<EnergyDosageSummary> EnergyDosageSummary { get; set; }
        public string Title { get; set; }
        public string Unit { get; set; }
    }

    public class EnergyDosageSummary
    {
        public string Title { get; set; }
        /// <summary>
        /// 能源名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 能源编码
        /// </summary>
        public string Code { get; set; }

        public string Unit { get; set; }
        public string Img { get; set; }

        /// <summary>
        /// 月总用量
        /// </summary>
        public decimal MonthEnergyDosage { get; set; }
        /// <summary>
        /// 日总用量
        /// </summary>
        public decimal DayEnergyDosage { get; set; }

        /// <summary>
        /// 月总能耗
        /// </summary>
        public decimal MonthEnergyConsu { get; set; }
        /// <summary>
        /// 日总能耗
        /// </summary>
        public decimal DayEnergyConsu { get; set; }
        /// <summary>
        /// 同比能耗
        /// </summary>
        public decimal YearOnYearDosage { get; set; }
        /// <summary>
        /// 环比能耗
        /// </summary>
        public decimal MonthOnMonthDosage { get; set; }

    }

    public class ListTableModel
    {
        public string Time { get; set; }
        public List<THeadModel> ListTableHead { get; set; }

        public List<Dictionary<string, dynamic>> DicList { get; set; }

    }
    public class THeadModel
    {
        public string Title { get; set; }

        public string DataIndex { get; set; }
    }

    #endregion

    public class FlowTableModel
    {
        public List<MargeCellModel> margeCellModels { get; set; }
        public List<LinkModel> Links { get; set; }
        public List<LevelModel> Levels { get; set; }
    }

    public class MargeCellModel
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 编码
        /// </summary>
        public string code { get; set; }
        /// <summary>
        /// 子节点数
        /// </summary>
        public int keyNode { get; set; }
    }

    public class TreeNodeModel
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 值
        /// </summary>
        public decimal value { get; set; }
        /// <summary>
        /// 损耗量
        /// </summary>
        public decimal loss { get; set; }
        /// <summary>
        /// 损耗率
        /// </summary>
        public decimal lossRate { get; set; }
        /// <summary>
        /// 单位
        /// </summary>
        public string unit { get; set; }
        public int childNodeKey { get; set; }
        /// <summary>
        /// 子节点
        /// </summary>
        public List<TreeNodeModel> childNode { get; set; }

    }

}
