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 ResultObjLst IndexContrastObjsLst(QueryContrastPeriods query, string[] chartObject, string chartDept, Dictionary<string, List<decimal>> dir)
        {
            ResultObjLst lstReult = new ResultObjLst();

            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 = "";
            }

            lstReult.Unit = chartDept;

            lstReult.ActionInfo = execu;

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

            #region 数据列表
            List<ObjRecord> objLst = new List<ObjRecord>();
            #endregion

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

                    record.ObjTime = query.PeriodLst[Index].StartTime.ToString("yyyy-MM-dd") + "~" + query.PeriodLst[Index].EndTime.ToString("yyyy-MM-dd"); //d.Key;
                    record.MaxValue = Math.Round(d.Value.Max(), 2);
                    record.MinValue = Math.Round(d.Value.Min(), 2);
                    record.TotalValue = Math.Round(d.Value.Sum(), 2);
                    record.AvgValue = Math.Round(d.Value.Average(), 2);
                    objLst.Add(record);
                    Index++;
                }
            }
            lstReult.ObjLst = objLst;
            return lstReult;
        }
Esempio n. 2
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. 3
0
        //objectList[0]
        public Dictionary<string, decimal> GetSingleItemCodeByObjectNew(QueryContrastPeriods query, string itemcode, TimePeriod time, int isCoal)
        {
            // var result = new ResultIndexLineChart { DatePick = new List<string>(), DatePickEnery = new List<decimal>() };
            var eneryDataList = new Dictionary<string, decimal>();
            var model = new BaseQueryModel();
            List<Model.BaseLayerObject> objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and layerobjectid={0}", query.AreaId), " order by LayerObjectID");
            model.IsDevice = 0;
            if (query.ObjType == AreaType.Area)
            {
                objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and layerobjectid={0}", query.AreaId), " order by LayerObjectID");
            }
            else
            {
                objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseFuncLayerObjectList(string.Format(" and layerobjectid={0}", query.AreaId), " order by LayerObjectID");
            }

            model.ObjectList = (from p in objectList select p.LayerObjectID).ToList<int>();
            model.ItemCode = itemcode;
            model.Unit = BaseTool.GetChartUnit(query.particle);
            model.Starttime = time.StartTime;
            model.Endtime = time.EndTime;
            model.areaType = query.ObjType;

            var resList = contsDal.GetBaseEneryDataListNew(model);
            for (int iCount = 0; iCount < query.PeriodLst.Count; iCount++)
            {
                TimePeriod tpTime = query.PeriodLst[iCount];
                //if (!eneryDataList.ContainsKey(d.DatePick))
                //{

                //    eneryDataList.Add(d.DatePick, isCoal == 0 ? d.DataValue : d.CoalDataValue);
                //}
                //else
                //{
                //    eneryDataList[d.DatePick] += isCoal == 0 ? d.DataValue : d.CoalDataValue;
                //}

            }
            foreach (var d in objectList.SelectMany(o => resList.BaseLayerObjectResults[o.LayerObjectID.ToString(CultureInfo.InvariantCulture)].Datas))
            {
                if (!eneryDataList.ContainsKey(d.DatePick))
                {
                    switch (query.QueryType)
                    {
                        case QueryOrderType.CarbanOut:
                            eneryDataList.Add(d.DatePick, d.Co2DataValue);
                            break;
                        case QueryOrderType.ConvCoal:
                            eneryDataList.Add(d.DatePick, d.CoalDataValue);
                            break;
                        case QueryOrderType.Renminbi:
                            eneryDataList.Add(d.DatePick, d.MoneyDataValue);
                            break;
                        default:
                            eneryDataList.Add(d.DatePick, d.DataValue);
                            break;
                    }
                }
                else
                {
                    eneryDataList[d.DatePick] += isCoal == 0 ? d.DataValue : d.CoalDataValue;
                    switch (query.QueryType)
                    {
                        case QueryOrderType.CarbanOut:
                            eneryDataList[d.DatePick] += d.Co2DataValue;
                            break;
                        case QueryOrderType.ConvCoal:
                            eneryDataList[d.DatePick] += d.CoalDataValue;
                            break;
                        case QueryOrderType.Renminbi:
                            eneryDataList[d.DatePick] += d.MoneyDataValue;
                            break;
                        default:
                            eneryDataList[d.DatePick] += d.DataValue;
                            break;
                    }
                }
            }

            //foreach (var e in eneryDataList)
            //{
            //    result.DatePick.Add(e.Key);
            //    result.DatePickEnery.Add(e.Value);
            //}
            return eneryDataList;
        }
Esempio n. 4
0
        public ResultItemCode GetPersonNumPeriodsQueryLineChart(QueryContrastPeriods query, TimePeriod time)
        {
            #region 定义区

            var resultList = new ResultView.ResultItemCode
            {
                ObjectName = new List<string>(),
                Enery = new Dictionary<string, List<decimal>>(),
                Dept = new List<string>()
            };

            #endregion

            var dept = string.Empty;
            var objectList =
                new BLL.BaseLayerObject().GetBaseLayerObjectList(
                    string.Format(" and layerobjectid={0}", query.AreaId), " order by LayerObjectID");
            var itList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID");
            if (itList.Count > 0)
            {
                dept = itList[0].Unit;
            }

            dept = query.ItemCode == "00000" ? "T" : dept;
            if (query.ItemCode == "00000")
            {
                // resultList.Dept = new List<string>() { "T" };
                var itemList = new BLL.Itemcode().GetItemcodeList(" and ParentID=0", " order by ItemcodeID");
                var eneryDataListTotal = new Dictionary<string, Dictionary<string, decimal>>();
                var maxcode = "01000";
                var count = 0;
                foreach (var itemcode in itemList)
                {
                    var lineChart = GetPersonNumSingleItemCodeByObject(query, itemcode.ItemCodeNumber, time, 1);

                    if (count < lineChart.Count)
                    {
                        count = lineChart.Count;
                        maxcode = itemcode.ItemCodeNumber;
                    }
                    eneryDataListTotal.Add(itemcode.ItemCodeNumber, lineChart);

                    //  resultList.Enery.Add(itemcode.ItemCodeName, lineChart.DatePickEnery);
                }

                // 重新赋值
                foreach (var itemcode in itemList)
                {
                    var itemcode1 = itemcode;
                    foreach (var max in eneryDataListTotal[maxcode].Where(max => !eneryDataListTotal[itemcode1.ItemCodeNumber].ContainsKey(max.Key)))
                    {
                        eneryDataListTotal[itemcode.ItemCodeNumber].Add(max.Key, 0);
                    }
                    var temp = eneryDataListTotal[itemcode.ItemCodeNumber].OrderBy(p => Convert.ToDateTime(p.Key));
                    var tempOrder = temp.ToDictionary(keyValuePair => keyValuePair.Key, keyValuePair => keyValuePair.Value);
                    eneryDataListTotal[itemcode.ItemCodeNumber] = tempOrder;
                    resultList.Enery.Add(itemcode.ItemCodeName, eneryDataListTotal[itemcode.ItemCodeNumber].Values.ToList());
                }
                resultList.ObjectName = eneryDataListTotal[maxcode].Select(p => p.Key.ToString(CultureInfo.InvariantCulture)).ToList();
            }
            else
            {
                var item = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID")[0];
                var lineChart = GetSingleItemCodeByObjectNew(query, query.ItemCode, time, 0);
                // resultList.Dept = new List<string>() {item.Unit};
                resultList.ObjectName = lineChart.Select(p => p.Key.ToString()).ToList();
                resultList.Enery.Add(item.ItemCodeName, lineChart.Select(p => decimal.Parse(p.Value.ToString())).ToList());
            }
            foreach (var baseLayerObject in resultList.ObjectName)
            {
                resultList.Dept.Add(dept);
            }
            return resultList;
        }
Esempio n. 5
0
        public ResultCompare GetPersonNumPeriodsCompareChart(QueryContrastPeriods query)
        {
            #region 定义区

            var resultList = new ResultView.ResultCompare
            {
                ObjectName = new List<string>(),
                Enery = new Dictionary<string, List<decimal>>(),
                Dept = new List<string>()
            };

            #endregion

            if (query.PeriodLst.Count > 0)
            {
                resultList.ObjectName.Clear();
                for (int iCount = 0; iCount < query.PeriodLst.Count; iCount++)
                {
                    //QueryContrastPeriods basicQuery = new QueryContrastPeriods();
                    //basicQuery.PeriodLst = query.PeriodLst;
                    //basicQuery.ItemCode = query.ItemCode;
                    //basicQuery.AreaId = query.AreaId;
                    //basicQuery.ObjectNum = o.LayerObjectID;
                    var result = GetPeriodsQueryLineChart(query, query.PeriodLst[iCount]);
                    resultList.ObjectName.Add(query.PeriodLst[iCount].StartTime.ToString("yyyy-MM-dd") + "~" + query.PeriodLst[iCount].EndTime.ToString("yyyy-MM-dd"));
                    if (query.ItemCode != "00000")
                    {
                        var itemList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID")[0];
                        resultList.Enery.Add((iCount + 1).ToString(), result.Enery[itemList.ItemCodeName]);
                        for (int i = 0; i < result.Dept.Count; i++)
                        {
                            resultList.Dept.Add(itemList.Unit);
                        }
                    }
                    else
                    {
                        var tempValue = new decimal[result.Enery[result.Enery.Keys.First<string>()].Count];
                        foreach (var re in result.Enery)
                        {
                            for (var i = 0; i < re.Value.Count; i++)
                            {
                                tempValue[i] += re.Value[i];
                            }
                        }
                        for (int i = 0; i < result.Dept.Count; i++)
                        {
                            resultList.Dept.Add("T");
                        }
                        resultList.Enery.Add(iCount.ToString(), tempValue.ToList());
                        //resultList.Enery.Add(o.LayerObjectName, tempValue.ToList().Select(p => p / decimal.Parse(o.PersonNum.ToString())).ToList());
                    }
                }
                return resultList;
            }
            return null;
        }
Esempio n. 6
0
        public Dictionary<string, decimal> GetSingleItemCodeByObject22(QueryContrastPeriods query2, int isCoal)
        {
            QueryContrastPeriods query = new QueryContrastPeriods();
            // var result = new ResultIndexLineChart { DatePick = new List<string>(), DatePickEnery = new List<decimal>() };
            var eneryDataList = new Dictionary<string, decimal>();
            var model = new BaseQueryModel();
            var objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and layerobjectid={0}", query.ItemCode), " order by LayerObjectID");
            model.IsDevice = 0;
            model.ObjectList = (from p in objectList select p.LayerObjectID).ToList<int>();
            model.ItemCode = query.ItemCode;
            //model.Unit = BaseTool.GetChartUnit(query);
            //model.Starttime = query.StartTime;
            //model.Endtime = query.EndTime;
            foreach (var perTime in query.PeriodLst)
            {
                model.Starttime = perTime.StartTime;
                model.Endtime = perTime.EndTime;
                var resList = _reportBll.GetBaseEneryDataList(model);
                //eneryDataList.Add(d.DatePick, isCoal == 0 ? d.DataValue : d.CoalDataValue);
            }

            // var resList = _reportBll.GetBaseEneryDataList(model);
            //foreach (var d in objectList.SelectMany(o => resList.BaseLayerObjectResults[o.LayerObjectID.ToString(CultureInfo.InvariantCulture)].Datas))
            //{
            //    if (!eneryDataList.ContainsKey(d.DatePick))
            //    {

            //        eneryDataList.Add(d.DatePick, isCoal == 0 ? d.DataValue : d.CoalDataValue);
            //    }
            //    else
            //    {
            //        eneryDataList[d.DatePick] += isCoal == 0 ? d.DataValue : d.CoalDataValue;
            //    }
            //}

            //foreach (var e in eneryDataList)
            //{
            //    result.DatePick.Add(e.Key);
            //    result.DatePickEnery.Add(e.Value);
            //}
            return eneryDataList;
        }
Esempio n. 7
0
 public ResultCompare GetPersonNumPeriodsCompareChart(QueryContrastPeriods query)
 {
     return entBll.GetPersonNumPeriodsCompareChart(query);
 }