Esempio n. 1
0
        /// <summary>
        /// 显示柱状图
        /// </summary>
        /// <param name="itemName"></param>
        /// <param name="chartObject"></param>
        /// <param name="chartDept"></param>
        /// <param name="dir"></param>
        /// <returns></returns>
        public static ResultContrast IndexPeriodsContrastObjsChart(QueryContrastPeriods query, string areaName, string[] chartObject, string chartDept, Dictionary<string, List<decimal>> dir)
        {
            //表格数据定义
            List<EnergyContrst> enerList = new List<EnergyContrst>();

            ResultContrast contrast = new ResultContrast();
            ExecuteProcess execu = new ExecuteProcess();
            if (chartObject.Length == 0)
            {
                execu.Success = false;
                execu.ExceptionMsg = "暂无数据信息";
                execu.ActionName = "";
                execu.ActionUser = "";
                execu.ActionTime = System.DateTime.Now;
            }
            else
            {
                execu.Success = true;
                execu.ExceptionMsg = "";
            }

            string sql = " and ItemCodeNumber = '" + query.ItemCode + "'";
            List<NTS.WEB.Model.Itemcode> itemList = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                 .GetItemCodeList(sql, "");

            contrast.ActionInfo = execu;

            #region 数据series
            LineJson lineJson = new LineJson();
            List<EneryCompare> compareList = new List<EneryCompare>();

            #endregion

            int Index = 0;
            StringBuilder chartNew = new StringBuilder();
            {
                foreach (var d in dir)
                {
                    EnergyContrst ener = new EnergyContrst();

                    EneryCompare compareItem = new EneryCompare();

                    if (itemList.Count == 0)
                    {
                        ener.EneType = "总能耗";
                    }
                    else
                    {
                        ener.EneType = itemList[0].ItemCodeName;
                    }

                    ener.Obj = areaName;

                    ener.Tm = GetTimeTitleByStartTimeAndEndTime(query.PeriodLst[Index].StartTime, query.PeriodLst[Index].EndTime);
                    ener.Val = Math.Round(d.Value.Sum(), 2);

                    // 取小数点后2位
                    List<decimal> dirValue = new List<decimal>();
                    foreach (var item in d.Value)
                    {
                        dirValue.Add(Math.Round(item, 2));
                    }
                    compareItem.name = ener.Tm;
                    compareItem.data = dirValue;

                    compareList.Add(compareItem);

                    enerList.Add(ener);
                    Index++;
                }

                lineJson.Unit = chartDept;
                contrast.Unit = chartDept;

                lineJson.CompareType = "periods";
                contrast.ContrastLst = enerList; // 表格数据。

                lineJson.series = compareList;
                contrast.lineJson = lineJson;

                //lineJson.series =
                return contrast;
            }
        }
Esempio n. 2
0
        public static ResultContrast ShowEnergyAnalyseLineChart(QueryAnalyse queryAnalyse, string[] chartObject, string[] chartDept, Dictionary<string, List<decimal>> dir)
        {
            //表格数据定义
            List<EnergyContrst> enerList = new List<EnergyContrst>();

            ResultContrast contrast = new ResultContrast();
            ExecuteProcess execu = new ExecuteProcess();
            if (chartObject.Length == 0)
            {
                execu.Success = false;
                execu.ExceptionMsg = "暂无数据信息";
                execu.ActionName = "";
                execu.ActionUser = "";
                execu.ActionTime = System.DateTime.Now;
            }
            else
            {
                execu.Success = true;
                execu.ExceptionMsg = "";
            }

            string sql = " and ItemCodeNumber = '" + queryAnalyse.ItemCode + "'";
            List<NTS.WEB.Model.Itemcode> itemList = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                 .GetItemCodeList(sql, "");

            contrast.ActionInfo = execu;

            #region 数据series
            LineJson lineJson = new LineJson();
            List<EneryCompare> compareList = new List<EneryCompare>();
            #endregion

            int Index = 0;
            StringBuilder chartNew = new StringBuilder();
            {
                foreach (var d in dir)
                {

                    EnergyContrst ener = new EnergyContrst();

                    EneryCompare compareItem = new EneryCompare();

                    if (itemList.Count == 0)
                    {
                        ener.EneType = "总能耗";
                    }
                    else
                    {
                        ener.EneType = itemList[0].ItemCodeName;
                    }

                    ener.Obj = d.Key;
                    ener.Tm = queryAnalyse.StartTime.ToString();
                    ener.Val = Math.Round(d.Value.Sum(), 2);

                    compareItem.name = d.Key;
                    compareItem.data = d.Value;
                    compareList.Add(compareItem);

                    enerList.Add(ener);
                    Index++;
                }
                if (chartDept.Length > 0)
                {
                    lineJson.Unit = chartDept[0];
                    contrast.Unit = chartDept[0];
                }
                lineJson.CompareType = "object";

                contrast.ContrastLst = enerList; // 表格数据。

                lineJson.series = compareList;
                contrast.lineJson = lineJson;

                //lineJson.series =
                return contrast;
            }
        }