Beispiel #1
0
        public decimal[] GetIndexCompareEnery(DateTime startTime, DateTime endTime)
        {
            decimal[] MonthResult = new decimal[2];
            //            string userid = "";
            //            try
            //            {
            //                userid = Utils.GetCookie("userid");
            //            }
            //            catch
            //            {
            //                userid = "";
            //            }
            //            var ObjectList = new List<Model.BaseLayerObject>();
            //            string where = "";
            //            if (string.IsNullOrEmpty(userid))
            //            {
            //                where = string.Format(@"and LayerObjectParentID={0} ", 0);
            //            }
            //            else
            //            {
            //                where = string.Format(@"and LayerObjectParentID={0} AND layerobjectid in( SELECT  AREAID from TB_USERGROUPAREARIGHT
            //WHERE USERGROUPID =(SELECT GROUPS FROM TB_USER WHERE ID={1} ))", 0, userid);
            //            }

            //            ObjectList = new DAL.BaseLayerObject().GetBaseLayerObjectList(where, string.Format(" order by LayerObjectID"));

            var ObjectList = new BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and LayerObjectParentID={0}", 0), " order by LayerObjectID");
            var ItemList = new BLL.Itemcode().GetItemcodeList(" and ParentID=0", " order by ItemcodeID");
            List<string> ItemCodeStr = (from item in ItemList select item.ItemCodeNumber).ToList<string>();
            BaseQueryModel model = new BaseQueryModel();
            model.IsDevice = 0;
            model.ObjectList = (from p in ObjectList select p.LayerObjectID).ToList<int>();
            decimal tempConvert = 0;
            foreach (var item in ItemCodeStr)
            {
                decimal tempCount = 0;
                decimal tempCountConvert = 0;
                model.ItemCode = item;
                model.Unit = ChartUnit.unit_month;
                model.Starttime = startTime;
                model.Endtime = endTime;
                var ResList = reportBll.GetBaseEneryDataList(model);
                foreach (var r in ResList.BaseLayerObjectResults)
                {
                    tempCount += r.Value.Total;
                    tempCountConvert += decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                }
                if (item == "01000")
                {
                    MonthResult[0] = tempCount;
                }
                tempConvert += tempCountConvert;
            }
            MonthResult[1] = tempConvert;
            return MonthResult;
        }
Beispiel #2
0
        /// <summary>
        /// 获取定额分析
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public ResultQuota GetQuotaAnalyseChart(QueryQuota query)
        {
            try
            {

                #region 返回对象定义
                ResultQuota result = new ResultQuota()
                {
                    Pie = new QuotaAnalysePie(),
                    BalanceHighChart = new QuotaHighChart() { series = new List<EneryAnalyseSeries>() },
                    TrendHighChart = new QuotaHighChart() { series = new List<EneryAnalyseSeries>() }
                };
                #endregion

                #region itemCodeList
                List<Model.Itemcode> itemCodeList = new List<Model.Itemcode>();

                if (query.ItemCode == "00000")
                {//总能耗
                    itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ParentID=0 ", " order by ItemcodeID");
                    result.Unit = "T";//标准煤单位
                }
                else
                {
                    itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID");
                    if (itemCodeList.Count > 0)
                    {
                        result.Unit = itemCodeList[0].Unit;//单个分类分项单位
                    }
                }
                #endregion

                #region 生成EndTime

                switch (query.Particle)
                {
                    case Particle.Month://月 query.StartTime格式为yyyy-MM-01
                        query.EndTime = query.StartTime.AddMonths(1).AddDays(-1);
                        int day = DateTime.Now.Day;
                        if (query.StartTime.Year == DateTime.Now.Year && query.StartTime.Month == DateTime.Now.Month )//月、年第一天不算进去
                        {//当月

                            query.EndTime = DateTime.Now;//精确到前一天的能耗值

                        }
                        break;
                    case Particle.Year://年  query.StartTime格式为yyyy-01-01
                        query.EndTime = query.StartTime.AddYears(1).AddMonths(-1);
                        if (query.StartTime.Year == DateTime.Now.Year)//月、年第一天不算进去
                        {
                            query.EndTime = DateTime.Now;
                        }
                        break;
                    default:
                        query.EndTime = query.StartTime.AddMonths(1).AddDays(-1);
                        if (query.StartTime.Year == DateTime.Now.Year && query.StartTime.Month == DateTime.Now.Month)
                        {
                            query.EndTime = DateTime.Now.AddDays(-1);
                        }
                        break;
                }
                #endregion

                #region 获取定额值
                Model.QuotaAnalyseModel quotaAnalyseModel = GetQuotaAnalyseModel(query);
                if (quotaAnalyseModel != null)
                {
                    result.Pie.QuotaValue = decimal.Round(quotaAnalyseModel.QuotaValue, 2);
                    if (!(quotaAnalyseModel.QuotaValue > 0))
                    {
                        throw new Exception("无效的定额值");
                    }
                }
                else
                {
                     throw new Exception("当前未设置定额值");
                    //result.Pie.QuotaValue = 10000;
                }
                #endregion

                var model = new BaseQueryModel();
                model.IsDevice = 0;
                model.ObjectList = new List<int>() { query.ObjectId };
                model.Unit = BaseTool.GetChartUnit((int)query.Particle - 1);//查询颗粒度比方法中的颗粒度大于一
                decimal averagequotavalue = 0;
                int TotalCount = 1;//月天数或者12月
                if (model.Unit == ChartUnit.unit_month)
                {//年定额分析 精确到天
                    model.Starttime = Convert.ToDateTime(query.StartTime.ToString("yyyy-MM-01"));
                    model.Endtime = Convert.ToDateTime(query.EndTime.ToString("yyyy-MM-01"));
                    //定额月平均值
                    averagequotavalue = decimal.Round(result.Pie.QuotaValue / 12, 2);
                    TotalCount = 12;
                }
                else
                {//月定额分析 精确到小时
                    model.Starttime = query.StartTime;
                    model.Endtime = query.EndTime;
                    //定额日平均值
                    TotalCount = DateTime.DaysInMonth(query.StartTime.Year, query.StartTime.Month);
                    averagequotavalue = decimal.Round(result.Pie.QuotaValue / TotalCount, 2);

                }

                Dictionary<string, decimal> tempConvert = new Dictionary<string, decimal>();
                if(query.EndTime>=query.StartTime)
                {
                    tempConvert = GetSingleItemCodeValue(model, query, itemCodeList);
                }

                result.Pie.ActualValue = decimal.Round(tempConvert.Select(t => t.Value).Sum(), 2);
                result.Pie.OverPlusValue = decimal.Round(result.Pie.QuotaValue - result.Pie.ActualValue, 2);
                result.Pie.OverPlusPercent = (result.Pie.OverPlusValue * 100 / result.Pie.QuotaValue).ToString("0.00") + "%";

                var balanceQuotaValue = new List<decimal>();
                for (int i = 0; i <= TotalCount - 1;i++ )
                {
                    balanceQuotaValue.Add(result.Pie.QuotaValue);
                }
                //趋势分析能耗值
                var TrendActualValue = new List<decimal>();
                TrendActualValue = (from item in tempConvert select decimal.Round(item.Value, 2)).ToList();
                for (int i = 0; i <= TrendActualValue.Count - 1; i++)
                {
                    if (i > 0)
                    {
                        TrendActualValue[i] = TrendActualValue[i] + TrendActualValue[i - 1];
                    }

                }
                //差额分析能耗值
                result.BalanceHighChart.series.Add(new EneryAnalyseSeries()
                {
                    name = "ActualLine",
                    //data = (from item in tempConvert select decimal.Round(item.Value, 2)).ToList()
                    data = TrendActualValue
                });
                //差额分析定额值

                result.BalanceHighChart.series.Add(new EneryAnalyseSeries()
                {
                    name = "QuotaLine",
                    data = balanceQuotaValue
                });
                //差额分析能耗差值
                result.BalanceHighChart.series.Add(new EneryAnalyseSeries()
                {
                    name = "BalanceLine",
                    data = ((from item in TrendActualValue select result.Pie.QuotaValue - decimal.Round(item, 2))).ToList()
                });
                //趋势分析定额值
                var TrendQuotaValue = new List<decimal>();

                //趋势分析预测值
                var TrendForeCastValue = new List<decimal>();

                result.TrendHighChart.series.Add(new EneryAnalyseSeries()
                {
                    name = "ActualLine",
                    data = TrendActualValue
                });
                int[] x = new int[TotalCount];
                int count = 1;
                //TrendQuotaValue.Add(0);//以0坐标开始
                for (int i = 0; i <= x.Length - 1; i++)
                {
                    x[i] = i;
                    if (count == x.Length)
                    {
                        TrendQuotaValue.Add(result.Pie.QuotaValue);
                    }
                    else
                    {
                        TrendQuotaValue.Add(averagequotavalue * count);
                    }
                    count++;
                }
                result.TrendHighChart.series.Add(new EneryAnalyseSeries()
                {
                    name = "QuotaLine",
                    data = TrendQuotaValue
                });
                TrendForeCastValue = SPT(x, TrendActualValue.ToArray());
                //预测节能率:定额值-线性回归公式值(最后一天或者12月)/定额值
                if (TrendForeCastValue.Count>0)
                {
                    result.Pie.ForecastSavingPercent = ((result.Pie.QuotaValue - TrendForeCastValue[TrendForeCastValue.Count - 1]) * 100 / result.Pie.QuotaValue).ToString("0.00") + "%";
                }
                else
                {
                    result.Pie.ForecastSavingPercent = "-";
                }

                #region 暂时禁用

                //decimal lastvalue = 0;
                //decimal lastsecondvalue = 0;
                //if (TrendActualValue.Count > 0)
                //{
                //    lastvalue = TrendActualValue[TrendActualValue.Count - 1];
                //    if (TrendActualValue.Count > 1)
                //    {
                //        lastsecondvalue = TrendActualValue[TrendActualValue.Count - 2];
                //    }
                //}
                //if (query.Particle == Particle.Year)
                //{
                //    if (query.StartTime.Year < DateTime.Now.Year)
                //    {
                //        result.Pie.ForecastSavingPercent = ((result.Pie.QuotaValue - result.Pie.ActualValue) * 100 / result.Pie.QuotaValue).ToString("0.00") + "%";

                //    }
                //    else
                //    {
                //        //当前理论计划值= 年定额值/12*(结束时间月-1)+年定额值/12/结束月的总天数*(结束时间天-1)
                //        decimal theoryPlanvalue = result.Pie.QuotaValue / 12 * (query.EndTime.Month - 1) + result.Pie.QuotaValue / 12 / DateTime.DaysInMonth(query.EndTime.Year, query.EndTime.Month) * (query.EndTime.Day - 1);
                //        //预测节能率=(当前理论计划值-实时能耗值)/年定额值,
                //        result.Pie.ForecastSavingPercent = ((theoryPlanvalue - result.Pie.ActualValue) * 100 / result.Pie.QuotaValue).ToString("0.00") + "%";
                //        if (query.EndTime.Month < 12)
                //        {//添加趋势预测线
                //            TrendForeCastValue.Add(lastvalue);

                //            for (int i = 1; i <= (12 - query.EndTime.Month); i++)
                //            {
                //                TrendForeCastValue.Add(lastvalue + (lastvalue - lastsecondvalue) * i);
                //            }
                //        }
                //    }

                //}
                //else
                //{
                //    if (query.StartTime.Month < DateTime.Now.Month)
                //    {
                //        result.Pie.ForecastSavingPercent = ((result.Pie.QuotaValue - result.Pie.ActualValue) * 100 / result.Pie.QuotaValue).ToString("0.00") + "%";
                //    }
                //    else
                //    {
                //        //当前理论计划值= 月定额值/当月天数*(当前天-1)+月定额值/当月天数/24*(当前小时数)
                //        decimal theoryPlanvalue = result.Pie.QuotaValue / DateTime.DaysInMonth(query.EndTime.Year, query.EndTime.Month) * (query.EndTime.Day - 1) + result.Pie.QuotaValue / DateTime.DaysInMonth(query.EndTime.Year, query.EndTime.Month) / 24 * (query.EndTime.Hour);
                //        //预测节能率=(当前理论计划值-实时能耗值)/年定额值,
                //        result.Pie.ForecastSavingPercent = ((theoryPlanvalue - result.Pie.ActualValue) * 100 / result.Pie.QuotaValue).ToString("0.00") + "%";
                //    }
                //    if (query.EndTime.Day < DateTime.DaysInMonth(query.StartTime.Year, query.StartTime.Month))
                //    {//添加趋势预测线
                //        TrendForeCastValue.Add(lastvalue);

                //        for (int i = 1; i <= (DateTime.DaysInMonth(query.StartTime.Year, query.StartTime.Month) - query.EndTime.Day); i++)
                //        {
                //            TrendForeCastValue.Add(lastvalue + (lastvalue - lastsecondvalue) * i);
                //        }
                //    }
                //}
                #endregion
                result.TrendHighChart.series.Add(new EneryAnalyseSeries()
                {
                    name = "ForeCastLine",
                    data = TrendForeCastValue
                });
                //同比
                query.StartTime = query.StartTime.AddYears(-1);
                query.EndTime = query.EndTime.AddYears(-1);
                quotaAnalyseModel = GetQuotaAnalyseModel(query);
                if (quotaAnalyseModel != null)
                {
                    result.Pie.LastYearQuotaValue = decimal.Round(quotaAnalyseModel.QuotaValue, 2); ;
                    if (!(quotaAnalyseModel.QuotaValue > 0))
                    {
                        throw new Exception("无效的定额值");
                    }
                }
                else
                {
                    //throw new Exception("当前未设置定额值");
                    result.Pie.LastYearQuotaValue = 0;
                }

                model.Unit = BaseTool.GetChartUnit((int)query.Particle - 1);
                if (model.Unit == ChartUnit.unit_month)
                {//年定额分析 精确到天
                    model.Starttime = Convert.ToDateTime(query.StartTime.ToString("yyyy-MM-01"));
                    model.Endtime = Convert.ToDateTime(query.EndTime.ToString("yyyy-12-01"));

                }
                else
                {//月定额分析 精确到小时

                    model.Starttime = query.StartTime;
                    model.Endtime = model.Starttime.AddMonths(1);

                }
                //model.Unit = ChartUnit.unit_month;
                //model.Starttime = Convert.ToDateTime(query.StartTime.ToString("yyyy-MM-01"));
                //model.Endtime = Convert.ToDateTime(query.EndTime.ToString("yyyy-MM-01"));
                //if(query.Particle==Particle.Year)
                //{
                //    model.Endtime = Convert.ToDateTime(query.EndTime.ToString("yyyy-12-01"));
                //}

                tempConvert = new Dictionary<string, decimal>();
                if (query.EndTime >= query.StartTime)
                {
                    tempConvert = GetSingleItemCodeValue(model, query, itemCodeList);
                }

                result.Pie.LastYearActualValue = decimal.Round(tempConvert.Select(t => t.Value).Sum(), 2);
                if (result.Pie.LastYearQuotaValue>0)
                {
                    result.Pie.LastYearSavingPercent =
                   ((result.Pie.LastYearActualValue - result.Pie.LastYearQuotaValue) * 100 / result.Pie.LastYearQuotaValue)
                       .ToString("0.00") + "%";
                }
                else
                {
                    result.Pie.LastYearSavingPercent = "-";
                }

                return result;
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 能耗集合
        /// </summary>
        /// <param name="model">查询的对象封装</param>
        /// <returns></returns>
        public static BaseResult GetBaseEneryDataList(BaseQueryModel model)
        {
            BaseResult Res = new BaseResult();
            Res.BaseLayerObjectResults = new Dictionary<string, BaseData>();
            //Res.DeviceResults = new Dictionary<Model.Device, BaseData>();
            bool IsDevice = model.IsDevice == 0 ? false : true;
            var datas = new DataTable();
            if (model != null && model.ObjectList.Count > 0)
            {
                foreach (var objects in model.ObjectList)
                {
                    decimal tempCount = 0;
                    BaseDataModel bmodel = new BaseDataModel();
                    bmodel.Starttime = model.Starttime;
                    if (model.Unit == ChartUnit.unit_hour)
                    {
                        bmodel.Endtime = (model.Starttime == model.Endtime)
                                             ? model.Starttime.AddDays(1).AddHours(-1)
                                             : model.Endtime;
                    }
                    else
                    {
                        bmodel.Endtime = model.Endtime;
                    }
                    bmodel.IsDevice = model.IsDevice;
                    bmodel.ItemCode = model.ItemCode;
                    bmodel.ObjectId = objects;
                    bmodel.Unit = model.Unit;
                    datas = GetBaseData(bmodel);
                    BaseData bsDatas = new BaseData();
                    bsDatas.itemCode = new Model.Itemcode();
                    var ItemCodeList = new DAL.Itemcode().GetItemcodeList(string.Format(" and ItemCodeNumber='{0}'", model.ItemCode), string.Format(" order by ItemcodeID"));
                    bsDatas.itemCode = ItemCodeList.Count > 0 ? ItemCodeList[0] : null;
                    Model.BaseLayerObject ObjectInfo = new Model.BaseLayerObject();

                    Model.Device DeviceObjectInfo = new Model.Device();
                    if (!IsDevice)
                    {
                        var infoList = new DAL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and LayerObjectID={0}", objects), string.Format(" order by LayerObjectID"));
                        ObjectInfo = infoList.Count > 0 ? infoList[0] : null;
                        bsDatas.Datas = new List<DataItems>();
                        foreach (DataRow item in datas.Rows)
                        {

                            tempCount += decimal.Parse(item["CountValue"].ToString());
                            bsDatas.Datas.Add(new DataItems()
                            {
                                DatePick = item["Starttime"].ToString(),
                                DataValue = decimal.Parse(item["CountValue"].ToString()),

                                CoalDataValue = decimal.Parse(item["CountValue"].ToString()) * (decimal)bsDatas.itemCode.ItemCoal,
                                Co2DataValue = decimal.Parse(item["CountValue"].ToString()) * (decimal)bsDatas.itemCode.ItemCO2,
                                MoneyDataValue = decimal.Parse(item["CountValue"].ToString()) * (decimal)bsDatas.itemCode.ItemMoney,
                                DataValueAndDept = item["CountValue"].ToString() + bsDatas.itemCode.Unit
                            });
                        }
                        bsDatas.baseLayerObject = ObjectInfo;
                    }
                    else
                    {
                        var infoList = new DAL.Device().GetDeviceList(string.Format(" and deviceid={0}", objects), string.Format(" order by DeviceID"));
                        DeviceObjectInfo = infoList.Count > 0 ? infoList[0] : null;
                        bsDatas.Datas = new List<DataItems>();
                        foreach (DataRow item in datas.Rows)
                        {
                            tempCount += decimal.Parse(item["CountValue"].ToString());
                            bsDatas.Datas.Add(new DataItems()
                            {
                                DatePick = item["Starttime"].ToString(),
                                DataValue = decimal.Parse(item["CountValue"].ToString()),
                                CoalDataValue = decimal.Parse(item["CountValue"].ToString()) *(decimal)bsDatas.itemCode.ItemCoal,
                                Co2DataValue = decimal.Parse(item["CountValue"].ToString()) * (decimal)bsDatas.itemCode.ItemCO2,
                                MoneyDataValue = decimal.Parse(item["CountValue"].ToString()) * (decimal)bsDatas.itemCode.ItemMoney,
                                DataValueAndDept = item["CountValue"].ToString() + bsDatas.itemCode.Unit
                            });
                        }
                        bsDatas.device = DeviceObjectInfo;
                    }
                    bsDatas.Total = tempCount;
                    bsDatas.ConvertDataValueList = new System.Collections.Hashtable();
                    bsDatas.ConvertDataValueList.Add("ITEMCOAL", decimal.Round(tempCount * (decimal)bsDatas.itemCode.ItemCoal, 4).ToString());
                    bsDatas.ConvertDataValueList.Add("ITEMCO2", decimal.Round(tempCount * (decimal)bsDatas.itemCode.ItemCO2, 4).ToString());
                    bsDatas.ConvertDataValueList.Add("ITEMMONEY", decimal.Round(tempCount * (decimal)bsDatas.itemCode.ItemMoney, 4).ToString());
                    Res.BaseLayerObjectResults.Add(
                        !IsDevice ? ObjectInfo.LayerObjectID.ToString() : DeviceObjectInfo.DeviceID.ToString(), bsDatas);
                }
                return Res;
            }
            return null;
        }
Beispiel #4
0
 //// static int AreaExtLevel = int.Parse(ConfigurationManager.AppSettings["AreaExtLevel"]);  
 // public DataTable GetItemcodeData(ReportQueryModel model)
 // {
 //     int objectid;
 //     decimal total = 0;
 //     DataTable dt = TableViews.BaseTable.CreateBaseDataTable();
 //     if (!new CommDataTool().ObjectIsConfig(model,out objectid))
 //     {
 //         return null;
 //     }
 //     try
 //     {
 //         string objectname = Getobjectname(model.Objectid);
 //         string itemcodename = Getitemcodename(model.Itemcode);
 //         BaseDataModel DataModel = new BaseDataModel();
 //         DataModel.Starttime = model.Startime;
 //         DataModel.Endtime = model.Endtime;
 //         DataModel.ObjectId = objectid;
 //         DataModel.ReportClass = model.Unit;
 //         #region 处理加工
 //         //DataTable dtdata = DataComm.GetBaseData(DataModel);
 //         DataTable dtdata = BigDataComm.GetBaseData(DataModel);
 //         if (dtdata.Rows.Count > 0)
 //         {
 //             for (int i = 0; i < dtdata.Rows.Count; i++)
 //             {
 //                 DataRow dr = dt.NewRow();
 //                 dr[1] = CommDataTool.FormatDate(dtdata.Rows[i]["Starttime"].ToString(), model.Unit);
 //                 dr[2] = model.Objectid;
 //                 dr[3] = objectname;
 //                 dr[4] = dtdata.Rows[i]["Starttime"].ToString();
 //                 dr[5] = dtdata.Rows[i]["endtime"].ToString();
 //                 dr[6] = itemcodename;
 //                 dr[7] = decimal.Round(decimal.Parse(dtdata.Rows[i]["CountValue"].ToString()), 2);
 //                 total += decimal.Parse(dr[7].ToString());
 //                 dt.Rows.Add(dr);
 //             }
 //             DataRow totaldr = dt.NewRow();
 //             totaldr[1] = CommDataTool.FormatDate(dtdata.Rows[0]["Starttime"].ToString(), model.Unit) + "-" +
 //                          CommDataTool.FormatDate(dtdata.Rows[dtdata.Rows.Count - 1]["Starttime"].ToString(),
 //                                                  model.Unit);
 //             totaldr[2] = model.Objectid;
 //             totaldr[3] = objectname;
 //             totaldr[4] = "-";
 //             totaldr[5] = "-";
 //             totaldr[6] = itemcodename;
 //             totaldr[7] = decimal.Round(total, 2).ToString();
 //             dt.Rows.Add(totaldr);
 //         }
 //         #endregion
 //         return dt;
 //     }
 //     catch (Exception e)
 //     {
 //         return null;
 //     }
 // }
 // /// <summary>
 // /// 根据分类分项集合,对象集合,以及查询量获取所有的数据
 // /// </summary>
 // /// <param name="ItemcodeArr">分类分项集合</param>
 // /// <param name="ObjectArr">对象集合</param>
 // /// <param name="model">查询量实体类</param>
 // /// <returns></returns>
 // public DataTable GetManayObjectAndItemcodeData(string[] ItemcodeArr, string[] ObjectArr, ReportQueryModel model)
 // {
 //     StringBuilder countidArr = new StringBuilder();
 //     countidArr = new CommDataTool().GetTrueCountID(ItemcodeArr, ObjectArr, model);
 //     if (string.IsNullOrEmpty(countidArr.ToString()))
 //     {
 //         return null;
 //     }
 //     try
 //     {
 //         BaseMDataModel MDataModel = new BaseMDataModel();
 //         MDataModel.Starttime = model.Startime;
 //         MDataModel.Endtime = model.Endtime;
 //         MDataModel.ObjectId = countidArr.ToString().Substring(1);
 //         #region 处理加工
 //        // DataTable dtdata = DataComm.GetBOMBaseData(MDataModel);
 //         DataTable dtdata = BigDataComm.GetBomBaseData(MDataModel);
 //         return dtdata;
 //         #endregion
 //     }
 //     catch (Exception)
 //     {
 //         return null;
 //     }
 // }
 // /// <summary>
 // ///
 // /// </summary>
 // /// <param name="model"></param>
 // /// <returns></returns>
 // public DataTable GetItemcodeDataOnlyTotal(ReportQueryModel model)
 // {
 //     int objectid;
 //     decimal total = 0;
 //     DataTable dt = TableViews.BaseTable.CreateBaseDataTable();
 //     if (!new CommDataTool().ObjectIsConfig(model, out objectid))
 //     {
 //         return null;
 //     }
 //     try
 //     {
 //         string objectname = Getobjectname(model.Objectid);
 //         string itemcodename = Getitemcodename(model.Itemcode);
 //         BaseDataModel DataModel = new BaseDataModel();
 //         DataModel.Starttime = model.Startime;
 //         DataModel.Endtime = model.Endtime;
 //         DataModel.ObjectId = objectid;
 //         DataModel.ReportClass = model.Unit;
 //         #region 处理加工
 //         //DataTable dtdata = DataComm.GetBaseData(DataModel);
 //         DataTable dtdata = BigDataComm.GetBaseData(DataModel);
 //         if (dtdata.Rows.Count > 0)
 //         {
 //             DataRow totaldr = dt.NewRow();
 //             decimal _total = 0;
 //             foreach (DataRow dr in dtdata.Rows)
 //             {
 //                // _total += decimal.Parse(dr[0].ToString()); 大数据量时修改
 //                 _total += decimal.Parse(dr["CountValue"].ToString());
 //             }
 //             totaldr[7] = decimal.Round(_total,2).ToString();
 //             dt.Rows.Add(totaldr);
 //         }
 //         #endregion
 //         return dt;
 //     }
 //     catch (Exception e)
 //     {
 //         return null;
 //     }
 // }
 // /// <summary>
 // /// 获取子分项的能耗值
 // /// </summary>
 // /// <param name="model"></param>
 // /// <param name="recordCount"></param>
 // /// <returns></returns>
 // public DataTable GetSmallItemcodeData(ReportQueryModel model, out int recordCount)
 // {
 //     DataTable ChildTableAll = new DataTable();
 //     DataTable TempTable = new DataTable();
 //     recordCount = 0;
 //     DataTable itemdt =
 //         GetItemcodeList(model.Itemcode);
 //     if (itemdt.Rows.Count > 0)
 //     {
 //         DataTable dtnew = TableViews.BaseTable.CreateSmallItemCodeDataTable(itemdt);
 //         for (int i = 0; i < itemdt.Rows.Count; i++)
 //         {
 //             ReportQueryModel newmodel = new ReportQueryModel();
 //             newmodel.Endtime = model.Endtime;
 //             newmodel.Startime = model.Startime;
 //             newmodel.Objectid = model.Objectid;
 //             newmodel.Itemcode = int.Parse(itemdt.Rows[i]["itemcodeid"].ToString());
 //             newmodel.Unit = model.Unit;
 //             DataTable ChildTable = GetItemcodeData(newmodel);
 //             if (ChildTable == null) { return null; }
 //             if (i == 0)
 //             {
 //                 recordCount = ChildTable.Rows.Count;
 //                 ChildTableAll = ChildTable.Copy();
 //                 TempTable = ChildTable;
 //             }
 //             else
 //             {
 //                 // 获取总共的记录数
 //                 ChildTableAll = Common.DataTool.UniteDataTable(ChildTableAll, ChildTable);
 //             }
 //         }
 //         for (int j = 0; j < TempTable.Rows.Count; j++)
 //         {
 //             DataRow dr = dtnew.NewRow();
 //             dr[1] = TempTable.Rows[j][1].ToString();//Date
 //             dr[2] = TempTable.Rows[j][2].ToString();//ObjectID
 //             dr[3] = TempTable.Rows[j][3].ToString();//ObjectName
 //             dr[4] = TempTable.Rows[j][4].ToString();//Starttime
 //             dr[5] = TempTable.Rows[j][5].ToString();//Endtime
 //             for (int k = 0; k < itemdt.Rows.Count; k++)
 //             {
 //                 string date = TempTable.Rows[j][1].ToString();
 //                 string ItemCode = itemdt.Rows[k]["itemcodeid"].ToString();
 //                 DataRow[] drs = ChildTableAll.Select(string.Format(" Date='{0}' and ItemCode='{1}'", date, ItemCode));
 //                 dr[k + 6] = drs.Length > 0 ? drs[0]["EneryValue"].ToString() : "0.00";
 //             }
 //             dtnew.Rows.Add(dr);
 //         }
 //         return dtnew;
 //     }
 //     return null;
 // }
 // #region 基础方法
 // /// <summary>
 // /// 获取对象的名称
 // /// </summary>
 // /// <param name="oid"></param>
 // /// <returns></returns>
 // public string Getobjectname(string oid)
 // {
 //     SqlParameter[] parameter = {
 //                                     new SqlParameter("@layerobjectid", SqlDbType.Int)
 //                                 };
 //     parameter[0].Value = int.Parse(oid);
 //     DataTable Dtobject = new BaseLayerObject().GetList(" layerobjectid=@layerobjectid ", "layerobjectid", parameter);
 //     if (Dtobject.Rows.Count > 0)
 //     {
 //         return Dtobject.Rows[0]["layerobjectname"].ToString();
 //     }
 //     return string.Empty;
 // }
 // public string Getitemcodename(int oid)
 // {
 //     SqlParameter[] parameter = {
 //                                     new SqlParameter("@itemcodeid", SqlDbType.Int)
 //                                 };
 //     parameter[0].Value = oid;
 //     DataTable DtItemcode = new Itemcode().GetList(" itemcodeid=@itemcodeid ", "itemcodeid", parameter);
 //     if (DtItemcode.Rows.Count > 0)
 //     {
 //         return DtItemcode.Rows[0]["itemcodename"].ToString();
 //     }
 //     return string.Empty;
 // }
 // public DataTable GetItemcodeList(int parentid)
 // {
 //     SqlParameter[] parameter = {
 //                                     new SqlParameter("@parentid", SqlDbType.Int)
 //                                 };
 //     parameter[0].Value = parentid;
 //     DataTable DtItemcode = new Itemcode().GetList(" parentid=@parentid ", "itemcodeid", parameter);
 //     return DtItemcode;
 // }
 // /// <summary>
 // /// 计算对象属性的单位能耗值
 // /// </summary>
 // /// <param name="values">能耗值</param>
 // /// <param name="classid">属性类型id</param>
 // /// <param name="objectid">对象id</param>
 // /// <returns></returns>
 // private static string GetPerData(string values, int classid, string objectid)
 // {
 //     decimal attribute = new BaseLayerObject().GetBaseLayerObjectCommAttribute(objectid, classid);
 //     if (attribute > 0)
 //     {
 //         return decimal.Round(decimal.Parse(values) / attribute, 2).ToString();
 //     }
 //     return "0.00";
 // }
 // #endregion
 // /// <summary>
 // /// 返回区域属性需要的单位能耗数据集
 // /// </summary>
 // /// <param name="Report"></param>
 // /// <returns></returns>
 // public  DataTable GetPerDataJson(DataTable Report)
 // {
 //     DataTable DtPerReport = TableViews.BaseTable.CreatePerTable(AreaExtLevel);
 //     for (int i = 0; i < Report.Rows.Count; i++)
 //     {
 //         DataRow dr = DtPerReport.NewRow();
 //         for (int k = 1; k < 8;k++ )
 //         {
 //             dr[k] = Report.Rows[i][k].ToString();
 //         }
 //         for (int j = 0; j < AreaExtLevel; j++)
 //         {
 //             dr[8 + j] =
 //                 decimal.Round(
 //                     decimal.Parse(GetPerData(Report.Rows[i][7].ToString(), j + 1,
 //                                              Report.Rows[i][2].ToString())), 2).ToString();
 //         }
 //         DtPerReport.Rows.Add(dr);
 //     }
 //     return DtPerReport;
 // }
 public BaseResult GetBaseEneryDataList(BaseQueryModel model)
 {
     return BigDataComm.GetBaseEneryDataList(model);
 }
Beispiel #5
0
        public Dictionary<string, EnergyValueCost> GetSingleItemCodeValue_OLD(QueryCost query, List<Model.Itemcode> itemCodeList)
        {
            var model = new BaseQueryModel();
            model.IsDevice = 0;
            model.ObjectList = new List<int>() { query.ObjectId };
            model.Unit = BaseTool.GetChartUnit((int)query.Particle - 1);

            if (model.Unit == ChartUnit.unit_month)
            {
                model.Starttime = Convert.ToDateTime(query.StartTime.ToString("yyyy-MM-1"));
                model.Endtime = Convert.ToDateTime(query.EndTime.ToString("yyyy-MM-1"));
            }
            else
            {
                model.Starttime = query.StartTime;
                model.Endtime = query.EndTime;
            }

            Dictionary<string, EnergyValueCost> tempConvert = new Dictionary<string, EnergyValueCost>();
            Dictionary<string, EnergyValueCost> tempConvertDay = new Dictionary<string, EnergyValueCost>();
            switch (model.Unit)
            {
                case ChartUnit.unit_month:
                    for (DateTime i = model.Starttime; i <= model.Endtime; i = i.AddMonths(1))
                    {
                        tempConvert.Add(i.ToString("yyyy-MM-01"), new EnergyValueCost { EnergyCost = 0, EnergyValue = 0 });
                    }
                    break;
                case ChartUnit.unit_hour:
                    for (DateTime i = model.Starttime; i < model.Endtime.AddDays(1); i = i.AddHours(1))
                    {
                        tempConvert.Add(i.ToString("yyyy-MM-dd HH:00:00"), new EnergyValueCost { EnergyCost = 0, EnergyValue = 0 });
                    }
                    break;
                case ChartUnit.unit_day:
                    for (DateTime i = model.Starttime; i <= model.Endtime; i = i.AddDays(1))
                    {
                        tempConvert.Add(i.ToString(("yyyy-MM-dd")), new EnergyValueCost { EnergyCost = 0, EnergyValue = 0 });
                    }
                    break;
            }
            foreach (var item in itemCodeList)
            {
                decimal price = _accssCommon.GetFeePrice(item.ItemCodeNumber);
                model.ItemCode = item.ItemCodeNumber;
                BaseResult resList = _reportBll.GetBaseEneryDataList(model, query.ObjType == AreaType.Liquid ? true : false);
                foreach (var r in resList.BaseLayerObjectResults)
                {
                    foreach (var rr in r.Value.Datas)
                    {
                        if (tempConvert.ContainsKey(rr.DatePick))
                        {
                            if (query.ItemCode == "00000")
                            {
                                tempConvert[rr.DatePick].EnergyValue += rr.CoalDataValue;
                                tempConvert[rr.DatePick].EnergyCost += rr.CoalDataValue * price;
                            }
                            else
                            {
                                tempConvert[rr.DatePick].EnergyValue += rr.DataValue;
                                tempConvert[rr.DatePick].EnergyCost += rr.DataValue * price;
                            }
                        }
                    }
                }
            }
            return tempConvert;
        }
Beispiel #6
0
 public BaseResult GetLoadForecastChart(BaseQueryModel loadCast)
 {
     return EnergyContrastCommon.GetBaseEneryDataListNew(loadCast);
 }
Beispiel #7
0
        public Dictionary<string, decimal> GetSingleItemCodeByObject(BasicQuery query, string itemcode)
        {
            // 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 List<Model.BaseLayerObject>();
            if (query.AreaType == AreaType.Area)
            {
                objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and layerobjectid={0}", query.ObjectNum), " order by LayerObjectID");
            }
            else
            {

                objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseFuncLayerObjectList(string.Format(" and layerobjectid={0}", query.ObjectNum), " order by LayerObjectID");
            }

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

            var resList = _energCon.GetBaseEneryDataListNew(model);
            foreach (var d in objectList.SelectMany(o => resList.BaseLayerObjectResults[o.LayerObjectID.ToString(CultureInfo.InvariantCulture)].Datas))
            {
                if (!eneryDataList.ContainsKey(d.DatePick))
                {
                    switch (query.QueryType)
                    {
                        case EnergyAnalyseQueryType.Convert2Co2:
                            eneryDataList.Add(d.DatePick, d.Co2DataValue);
                            break;
                        case EnergyAnalyseQueryType.Convert2Coal:
                            eneryDataList.Add(d.DatePick, d.CoalDataValue);
                            break;
                        case EnergyAnalyseQueryType.Convert2Money:
                            eneryDataList.Add(d.DatePick, d.MoneyDataValue);
                            break;
                        default:
                            eneryDataList.Add(d.DatePick, d.DataValue);
                            break;
                    }
                }
                else
                {
                    switch (query.QueryType)
                    {
                        case EnergyAnalyseQueryType.Convert2Co2:
                            eneryDataList[d.DatePick] += d.Co2DataValue;
                            break;
                        case EnergyAnalyseQueryType.Convert2Coal:
                            eneryDataList[d.DatePick] += d.CoalDataValue;
                            break;
                        case EnergyAnalyseQueryType.Convert2Money:
                            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;
        }
Beispiel #8
0
        public MainInfo GetIndexCompareEneryNew(DateTime startTime, DateTime endTime)
        {
            MainInfo mainInfo = new MainInfo();
            mainInfo.IsOnlyElec = false;
            mainInfo.ItemValues = new List<EneryStatistic>();
            mainInfo.PeriodValues = new List<EnerySum>();
            var ObjectList = new BLL.BaseLayerObject().GetBaseFuncLayerObjectList(string.Format(" and LayerObjectParentID={0}", 0), " order by LayerObjectID");
            var ItemList = new BLL.Itemcode().GetItemcodeList(" and ParentID=0", " order by ItemcodeID");
            //var ItemList = new BLL.Itemcode().GetItemcodeList("", " order by ItemcodeID");

            EneryStatistic eneryStatistic4Elec = new EneryStatistic();
            if (ItemList.Count == 1)
            {//只有电
                mainInfo.IsOnlyElec = true;//只有电
                eneryStatistic4Elec.CName = ItemList[0].ItemCodeName;
                eneryStatistic4Elec.ItemCode = ItemList[0].ItemCodeNumber;
                eneryStatistic4Elec.Unit = ItemList[0].Unit;
                ItemList = new BLL.Itemcode().GetItemcodeList(string.Format(" and ParentID={0}", ItemList[0].ItemcodeID), " order by ItemcodeID");
            }
            BaseQueryModel model = new BaseQueryModel();
            model.IsDevice = 0;
            model.ObjectList = (from p in ObjectList select p.LayerObjectID).ToList<int>();

            foreach (var item in ItemList)
            {
                EneryStatistic eneryStatistic = new EneryStatistic();
                eneryStatistic.CName = item.ItemCodeName;
                eneryStatistic.ItemCode = item.ItemCodeNumber;
                eneryStatistic.Unit = item.Unit;

                model.ItemCode = item.ItemCodeNumber;
                decimal tempItemCoalEneryValue = 0;
                decimal tempLastMonthItemCoalEneryValue = 0;
                BaseResult ResList = new BaseResult();
                if ((endTime - startTime).Days > 0)
                {
                    model.Unit = ChartUnit.unit_day;
                    model.Starttime = startTime;
                    model.Endtime = DateTime.Parse(endTime.AddDays(-1).ToString("yyyy-MM-dd 00:00:00"));
                    ResList = reportBll.GetBaseEneryDataList(model, true);
                    if (ResList == null)
                    {
                        continue;
                    }
                    foreach (var r in ResList.BaseLayerObjectResults)
                    {
                        eneryStatistic.EneryValue += r.Value.Total;
                        eneryStatistic.EnergyValue2Coal += decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                        tempItemCoalEneryValue += decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                    }
                }
                if (endTime.Hour > 0)
                {
                    model.Unit = ChartUnit.unit_hour;
                    model.Starttime = DateTime.Parse(endTime.ToString("yyyy-MM-dd 00:00:00"));
                    model.Endtime = DateTime.Parse(endTime.ToString("yyyy-MM-dd HH:00:00"));
                    ResList = reportBll.GetBaseEneryDataList(model, true);
                    if (ResList == null)
                    {
                        continue;
                    }
                    foreach (var r in ResList.BaseLayerObjectResults)
                    {
                        eneryStatistic.EneryValue += r.Value.Total;
                        eneryStatistic.EnergyValue2Coal += decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                        tempItemCoalEneryValue += decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                    }
                }

                eneryStatistic.EneryValue = decimal.Round(eneryStatistic.EneryValue, 2);
                eneryStatistic.EnergyValue2Coal = decimal.Round(eneryStatistic.EnergyValue2Coal, 2);
                tempItemCoalEneryValue = decimal.Round(tempItemCoalEneryValue, 2);

                model.Starttime = startTime.AddMonths(-1);
                model.Endtime = endTime.AddMonths(-1);

                if ((endTime - startTime).Days > 0)
                {
                    model.Unit = ChartUnit.unit_day;
                    model.Endtime = DateTime.Parse(model.Endtime.AddDays(-1).ToString("yyyy-MM-dd 00:00:00"));
                    ResList = reportBll.GetBaseEneryDataList(model, true);
                    if (ResList == null)
                    {
                        continue;
                    }
                    foreach (var r in ResList.BaseLayerObjectResults)
                    {
                        eneryStatistic.EnergyLastMonth += decimal.Round(r.Value.Total, 2);
                        tempLastMonthItemCoalEneryValue += decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                    }
                }
                if (endTime.Hour > 0)
                {
                    model.Unit = ChartUnit.unit_hour;
                    model.Starttime = DateTime.Parse(endTime.AddMonths(-1).ToString("yyyy-MM-dd 00:00:00"));
                    model.Endtime = DateTime.Parse(endTime.AddMonths(-1).ToString("yyyy-MM-dd HH:00:00"));
                    ResList = reportBll.GetBaseEneryDataList(model, true);
                    if (ResList == null)
                    {
                        continue;
                    }
                    foreach (var r in ResList.BaseLayerObjectResults)
                    {
                        eneryStatistic.EnergyLastMonth += decimal.Round(r.Value.Total, 2);
                        tempLastMonthItemCoalEneryValue += decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                    }
                }

                eneryStatistic.EnergyLastMonth = decimal.Round(eneryStatistic.EnergyLastMonth, 2);
                tempLastMonthItemCoalEneryValue = decimal.Round(tempLastMonthItemCoalEneryValue, 2);
                if (eneryStatistic.EnergyLastMonth > 0)
                {
                    eneryStatistic.MonthCompare = decimal.Round(100 * (eneryStatistic.EneryValue - eneryStatistic.EnergyLastMonth) / eneryStatistic.EnergyLastMonth, 2)
                                 .ToString(CultureInfo.InvariantCulture) + "%";
                }

                mainInfo.Total += Math.Round(tempItemCoalEneryValue, 2);
                mainInfo.TotalLastMon += Math.Round(tempLastMonthItemCoalEneryValue, 2);

                if (mainInfo.IsOnlyElec)
                {
                    eneryStatistic4Elec.EneryValue += eneryStatistic.EneryValue;
                    eneryStatistic4Elec.EnergyValue2Coal += eneryStatistic.EneryValue;
                    eneryStatistic4Elec.EnergyLastMonth += eneryStatistic.EnergyLastMonth;
                }
                mainInfo.ItemValues.Add(eneryStatistic);

                if (item.ItemCodeNumber == "01000")
                {

                    GeneratePeriodValues(model, mainInfo);
                }

            }

            if (mainInfo.TotalLastMon > 0)
            {
                mainInfo.TotalCompare = decimal.Round(100 * (mainInfo.Total - mainInfo.TotalLastMon) / mainInfo.TotalLastMon, 2)
                             .ToString(CultureInfo.InvariantCulture) + "%";
            }
            if (mainInfo.IsOnlyElec)
            {
                eneryStatistic4Elec.MonthCompare = mainInfo.TotalCompare;
                mainInfo.ItemValues.Insert(0, eneryStatistic4Elec);
                model.ItemCode = "01000";
                GeneratePeriodValues(model, mainInfo);
            }
            return mainInfo;
        }
Beispiel #9
0
        public ResultRealLine DeviceRealChart(RealQuery query)
        {
            var pAction = new ExecuteProcess();
            try
            {
                var result = new ResultRealLine { series = new List<EneryAnalyseSeries>(), Unit = "kwh" };
                //ResultItemCode result = new ResultItemCode();
                //result.Dept = new List<string>();
                //result.Enery = new Dictionary<string, List<decimal>>();
                //result.ObjectName = new List<string>();
                // 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().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
                model.IsDevice = 1;
                model.ObjectList = (from p in objectList select p.DeviceID).ToList<int>();
                model.ItemCode = objectList[0].ItemCodeID;
                model.Unit = ChartUnit.unit_hour;
                if (query.QueryType == EnergyAnalyseQueryType.Default)
                {
                    model.Starttime = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd"));
                    model.Endtime = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd"));
                }
                else if (query.QueryType == EnergyAnalyseQueryType.MonthCompare)
                {
                    model.Starttime = Convert.ToDateTime(System.DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd"));
                    model.Endtime = Convert.ToDateTime(System.DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd"));
                }
                else if (query.QueryType == EnergyAnalyseQueryType.YearCompare)
                {
                    model.Starttime = Convert.ToDateTime(System.DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd"));
                    model.Endtime = Convert.ToDateTime(System.DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd"));
                }
                var itemList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + model.ItemCode + "'", " order by ItemcodeID")[0];
                result.Unit = itemList.Unit;//by added wxy
                var resList = _reportBll.GetBaseEneryDataList(model);
                foreach (var d in objectList.SelectMany(o => resList.BaseLayerObjectResults[o.DeviceID.ToString(CultureInfo.InvariantCulture)].Datas))
                {
                    if (!eneryDataList.ContainsKey(d.DatePick))
                    {
                        eneryDataList.Add(d.DatePick, d.DataValue);
                    }
                    else
                    {
                        eneryDataList[d.DatePick] += d.DataValue;
                    }
                }

                List<decimal> dat = new List<decimal>();
                foreach (var e in eneryDataList)
                {
                    dat.Add(e.Value);

                }
                EneryAnalyseSeries eas = new EneryAnalyseSeries();
                eas.data = dat;

                result.series.Add(eas);

                pAction.Success = true;
                result.ActionInfo = pAction;
                return result;

            }
            catch (Exception ex)
            {
                pAction.Success = false;
                pAction.ExceptionMsg = ex.Message;
                return new ResultRealLine() { ActionInfo = pAction };

            }
        }
Beispiel #10
0
        private Dictionary<string, decimal> GenerateEnergyDicValue(BaseQueryModel model, QueryAnalyse query, Dictionary<string, decimal> tempConvert,ref string objName)
        {
            BaseResult resList = _reportBll.GetBaseEneryDataList(model, query.ObjType == AreaType.Liquid ? true : false);

             foreach (var r in resList.BaseLayerObjectResults)
             {
                 if (model.IsDevice == 0)
                 {
                     objName = r.Value.baseLayerObject.LayerObjectName; //取区域名称
                 }
                 else
                 {
                     objName = r.Value.device.DeviceName;
                 }
                 foreach (var rr in r.Value.Datas)
                 {
                     if (query.ItemCode == "00000")
                     {
                         switch (query.QueryType)
                         {
                             case EnergyAnalyseQueryType.Default: //默认
                             case EnergyAnalyseQueryType.YearCompare: //默认
                             case EnergyAnalyseQueryType.MonthCompare: //默认
                                 tempConvert[rr.DatePick] += rr.CoalDataValue;
                                 break;
                             case EnergyAnalyseQueryType.UnitArea: //单位面积
                                 tempConvert[rr.DatePick] += rr.CoalDataValue/
                                                             decimal.Parse(r.Value.baseLayerObject.AreaNum.ToString());

                                 break;
                             case EnergyAnalyseQueryType.UnitPerson: //人均
                                 tempConvert[rr.DatePick] += rr.CoalDataValue/
                                                             decimal.Parse(r.Value.baseLayerObject.PersonNum.ToString());
                                 break;
                             case EnergyAnalyseQueryType.Convert2Coal: //
                                 tempConvert[rr.DatePick] += rr.CoalDataValue;
                                 break;
                             case EnergyAnalyseQueryType.Convert2Co2: //
                                 tempConvert[rr.DatePick] += rr.Co2DataValue;
                                 break;
                             case EnergyAnalyseQueryType.Convert2Money: //
                                 tempConvert[rr.DatePick] += rr.MoneyDataValue;
                                 break;
                         }
                     }
                     else
                     {
                         switch (query.QueryType)
                         {
                             case EnergyAnalyseQueryType.Default: //默认
                             case EnergyAnalyseQueryType.YearCompare: //默认
                             case EnergyAnalyseQueryType.MonthCompare: //默认
                                 tempConvert[rr.DatePick] += rr.DataValue;
                                 break;
                             case EnergyAnalyseQueryType.UnitArea: //单位面积
                                 tempConvert[rr.DatePick] += rr.DataValue/
                                                             decimal.Parse(r.Value.baseLayerObject.AreaNum.ToString());

                                 break;
                             case EnergyAnalyseQueryType.UnitPerson: //人均
                                 tempConvert[rr.DatePick] += rr.DataValue/
                                                             decimal.Parse(r.Value.baseLayerObject.PersonNum.ToString());
                                 break;
                             case EnergyAnalyseQueryType.Convert2Coal: //
                                 tempConvert[rr.DatePick] += rr.CoalDataValue;
                                 break;
                             case EnergyAnalyseQueryType.Convert2Co2: //
                                 tempConvert[rr.DatePick] += rr.Co2DataValue;
                                 break;
                             case EnergyAnalyseQueryType.Convert2Money: //
                                 tempConvert[rr.DatePick] += rr.MoneyDataValue;
                                 break;
                         }

                     }
                 }
             }
            return tempConvert;
        }
Beispiel #11
0
        public ResultItemCode RealChart(RealQuery query)
        {
            ResultItemCode result = new ResultItemCode();
            result.Dept = new List<string>();
            result.Enery = new Dictionary<string, List<decimal>>();
            result.ObjectName = new List<string>();
            // 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().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
            model.IsDevice = 1;
            model.ObjectList = (from p in objectList select p.DeviceID).ToList<int>();
            model.ItemCode = objectList[0].ItemCodeID;
            model.Unit = ChartUnit.unit_hour;
            model.Starttime = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd"));
            model.Endtime = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd"));
            var itemList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + model.ItemCode + "'", " order by ItemcodeID")[0];

            var resList = _reportBll.GetBaseEneryDataList(model);
            foreach (var d in objectList.SelectMany(o => resList.BaseLayerObjectResults[o.DeviceID.ToString(CultureInfo.InvariantCulture)].Datas))
            {
                if (!eneryDataList.ContainsKey(d.DatePick))
                {
                    eneryDataList.Add(d.DatePick, d.DataValue);
                }
                else
                {
                    eneryDataList[d.DatePick] += d.DataValue;
                }
            }
            result.Enery.Add(objectList[0].DeviceID.ToString(CultureInfo.InvariantCulture), eneryDataList.Values.ToList());
            foreach (var e in eneryDataList)
            {
                result.Dept.Add(itemList.Unit);
                result.ObjectName.Add(e.Key);

            }
            return result;
        }
Beispiel #12
0
        public ResultRealLine IndexElectricityRealLine(DateTime startTime, DateTime endTime)
        {
            var pAction = new ExecuteProcess();
            try
            {
                var result = new ResultRealLine { series = new List<EneryAnalyseSeries>(), Unit = "kwh" };
                var eneryDataList = new Dictionary<string, decimal>();
                var model = new BaseQueryModel();
                var objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseFuncLayerObjectList(string.Format(" and LayerObjectParentID={0}", 0), " order by LayerObjectID");
                model.IsDevice = 0;
                model.ObjectList = (from p in objectList select p.LayerObjectID).ToList<int>();
                model.ItemCode = "01000";
                model.Unit = ChartUnit.unit_hour;
                model.Starttime = startTime;
                model.Endtime = endTime;
                var resList = _reportBll.GetBaseEneryDataList(model,true);
                foreach (var d in objectList.SelectMany(o => resList.BaseLayerObjectResults[o.LayerObjectID.ToString(CultureInfo.InvariantCulture)].Datas))
                {
                    if (!eneryDataList.ContainsKey(d.DatePick))
                    {
                        eneryDataList.Add(d.DatePick, d.DataValue);
                    }
                    else
                    {
                        eneryDataList[d.DatePick] += d.DataValue;
                    }
                }

                List<decimal> dat = new List<decimal>(24);//modified by wxy
                for (int i = 0; i < 24; i++)
                    dat.Add(0);
                foreach (var e in eneryDataList)
                {
                    DateTime dt = DateTime.Parse(e.Key);//dat.Add(e.Value);
                    dat[dt.Hour] = e.Value;

                }
                List<decimal> dat1 = new List<decimal>();
                EneryAnalyseSeries eas = new EneryAnalyseSeries();
                decimal rightValue = 0;//modified by wxy
                decimal leftValue = 0;
                for (int i = 0; i <= DateTime.Now.Hour; i++)
                {
                    if (dat[i].CompareTo(-1) == 0)
                    {
                        int tempIndex = i;
                        while (--i >= 0)
                        {
                            if (dat[i].CompareTo(-1) >= 0)
                            {
                                rightValue = dat[i];
                                break;
                            }
                        }
                        i = tempIndex;
                        while (++i < 24)
                        {
                            if (dat[i].CompareTo(-1) >= 0)
                            {
                                leftValue = dat[i];
                                break;
                            }
                        }
                        i = tempIndex;
                        decimal meanValue = (rightValue + leftValue)/2;
                        dat1.Add( Math.Round(meanValue, 2) );
                    }
                    else
                        dat1.Add(dat[i]);
                }
                eas.data = dat1;

                result.series.Add(eas);
                pAction.Success = true;
                result.ActionInfo = pAction;
                return result;
            }
            catch (Exception ex)
            {
                pAction.Success = false;
                pAction.ExceptionMsg = ex.Message;
                return new ResultRealLine() { ActionInfo = pAction };
            }
        }
Beispiel #13
0
        public ResultIndexLineChart IndexElectricityLineChart(DateTime startTime, DateTime endTime)
        {
            var pAction = new ExecuteProcess();
            try
            {
                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 LayerObjectParentID={0}", 0), " order by LayerObjectID");
                model.IsDevice = 0;
                model.ObjectList = (from p in objectList select p.LayerObjectID).ToList<int>();
                model.ItemCode = "01000";
                model.Unit = ChartUnit.unit_hour;
                model.Starttime = startTime;
                model.Endtime = endTime;
                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, d.DataValue);
                    }
                    else
                    {
                        eneryDataList[d.DatePick] += d.DataValue;
                    }
                }

                foreach (var e in eneryDataList)
                {
                    result.DatePick.Add(e.Key);
                    result.DatePickEnery.Add(e.Value);
                }
                pAction.Success = true;
                result.ActionInfo = pAction;
                return result;
            }
            catch (Exception ex)
            {
                pAction.Success = false;
                pAction.ExceptionMsg = ex.Message;
                return new ResultIndexLineChart() { ActionInfo = pAction };
            }
        }
Beispiel #14
0
        public Dictionary<string, decimal> GetSingleItemCodeValue(BaseQueryModel model, QueryQuota query, List<Model.Itemcode> itemCodeList)
        {
            Dictionary<string, decimal> tempConvert = new Dictionary<string, decimal>();
            //if (model.Endtime.Day==1)
            //{
            //    return tempConvert;
            //}
               // Dictionary<string, decimal> tempHourConvert = new Dictionary<string, decimal>();//暂时禁用小时
            switch (model.Unit)
            {
                case ChartUnit.unit_month:
                    for (DateTime i = model.Starttime; i <= model.Endtime; i = i.AddMonths(1))
                    {
                        tempConvert.Add(i.ToString("yyyy-MM-dd"), 0);
                    }
                    break;
                case ChartUnit.unit_hour:
                    for (DateTime i = model.Starttime; i < model.Endtime.AddDays(1); i = i.AddHours(1))
                    {
                        tempConvert.Add(i.ToString("yyyy-MM-dd HH:mm:ss"), 0);
                    }
                    break;
                case ChartUnit.unit_day:
                    if (query.EndTime.Hour > 0)
                    {
                        for (DateTime i = model.Starttime; i <=model.Endtime.AddDays(-1); i = i.AddDays(1))
                        {
                            tempConvert.Add(i.ToString(("yyyy-MM-dd")), 0);
                        }
                        //暂时禁用小时
                        //for (DateTime i = DateTime.Parse(model.Endtime.ToString("yyyy-MM-dd 00:00:00")); i < model.Endtime; i = i.AddHours(1))
                        //{
                        //    tempHourConvert.Add(i.ToString("yyyy-MM-dd HH:mm:ss"), 0);
                        //}
                    }
                    else
                    {
                        for (DateTime i = model.Starttime; i <= model.Endtime; i = i = i.AddDays(1))
                        {
                            tempConvert.Add(i.ToString(("yyyy-MM-dd")), 0);
                        }
                    }

                    break;
            }
            foreach (var item in itemCodeList)
            {
                model.ItemCode = item.ItemCodeNumber;
                BaseResult resList = _reportBll.GetBaseEneryDataList(model, query.ObjType == AreaType.Liquid ? true : false);
                foreach (var r in resList.BaseLayerObjectResults)
                {
                    foreach (var rr in r.Value.Datas)
                    {
                        if (tempConvert.ContainsKey(rr.DatePick))
                        {
                            if (query.ItemCode == "00000")
                            {
                                tempConvert[rr.DatePick] += rr.CoalDataValue;
                            }
                            else
                            {
                                tempConvert[rr.DatePick] += rr.DataValue;
                            }
                        }
                    }
                }

                //if (tempHourConvert.Count > 0)
                //{
                //    model.Starttime = DateTime.Parse(query.EndTime.ToString("yyyy-MM-dd 01:mm:ss"));
                //    model.Unit = ChartUnit.unit_hour;
                //    resList = _reportBll.GetBaseEneryDataList(model, query.ObjType == AreaType.Liquid ? true : false);
                //    foreach (var r in resList.BaseLayerObjectResults)
                //    {
                //        foreach (var rr in r.Value.Datas)
                //        {
                //            if (tempHourConvert.ContainsKey(rr.DatePick))
                //            {
                //                if (query.ItemCode == "00000")
                //                {
                //                    tempHourConvert[rr.DatePick] += rr.CoalDataValue;
                //                }
                //                else
                //                {
                //                    tempHourConvert[rr.DatePick] += rr.DataValue;
                //                }
                //            }

                //        }
                //    }
                //    decimal currentdayvalue = tempHourConvert.Select(t => t.Value).Sum();
                //    tempConvert.Add(model.Endtime.ToString(("yyyy-MM-dd")), currentdayvalue);
                //}
            }
            return tempConvert;
        }
Beispiel #15
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;
        }
Beispiel #16
0
        public ResultView.IndexWindowResult GetItemCodeListByObjectID(QueryIndexWindow query)
        {
            Dictionary<string, BaseResult> Res = new Dictionary<string, BaseResult>();
            IndexWindowResult Results = new IndexWindowResult();
            string[] ItemCodeStr = { "01000", "02000", "03000", "04000" };//daixy 该处需要修改
            DateTime[] Dates = { query.StatisticsDate, query.StatisticsDate.AddDays(-1) };
            List<Model.BaseLayerObject> queryObjectList = new BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and LayerObjectID={0}", query.BuildingNumber), " order by LayerObjectID");
            var queryObject = new Model.BaseLayerObject();
            if (queryObjectList.Count > 0)
            {
                queryObject = queryObjectList[0];
            }
            else
            {
                return null;
            }
            BaseQueryModel model1 = new BaseQueryModel();
            try
            {
                BaseQueryModel model = new BaseQueryModel();
                model.IsDevice = 0;
                model.ObjectList = new List<int>() { query.BuildingNumber };
                foreach (var i in ItemCodeStr)
                {
                    foreach (var d in Dates)
                    {
                        model.ItemCode = i;
                        model.Unit = ChartUnit.unit_day;
                        model.Starttime = d;
                        model.Endtime = d;
                        model1 = new BaseQueryModel();
                        model1.ItemCode = i;
                        model1.Unit = ChartUnit.unit_day;
                        model1.Starttime = d;
                        model1.Endtime = d;
                        Res.Add(i + "_" + d, reportBll.GetBaseEneryDataList(model));
                    }
                }
                if (Res.Count > 0)
                {
                    Results.Electricity = Res[ItemCodeStr[0] + "_" + Dates[0]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()].Total;
                    Results.Water = Res[ItemCodeStr[1] + "_" + Dates[0]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()].Total;
                    Results.Gas = Res[ItemCodeStr[2] + "_" + Dates[0]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()].Total;
                    Results.Warm = Res[ItemCodeStr[3] + "_" + Dates[0]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()].Total;
                    if (
                        Res[ItemCodeStr[0] + "_" + Dates[1]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()]
                            .Total == 0)
                    {
                        Results.ComparedElectricity = "-";
                    }
                    else
                    {
                        Results.ComparedElectricity =
                            decimal.Round(
                                100 * (Results.Electricity -
                                 Res[ItemCodeStr[0] + "_" + Dates[1]].BaseLayerObjectResults[
                                     queryObject.LayerObjectID.ToString()].Total) /
                                Res[ItemCodeStr[0] + "_" + Dates[1]].BaseLayerObjectResults[
                                    queryObject.LayerObjectID.ToString()].Total, 2).ToString() + "%";
                    }
                    if (Res[ItemCodeStr[1] + "_" + Dates[1]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()]
                            .Total == 0)
                    {
                        Results.ComparedWater = "-";
                    }
                    else
                    {
                        Results.ComparedWater =
                            decimal.Round(
                                100 * (Results.Water -
                                 Res[ItemCodeStr[1] + "_" + Dates[1]].BaseLayerObjectResults[
                                     queryObject.LayerObjectID.ToString()].Total) /
                                Res[ItemCodeStr[1] + "_" + Dates[1]].BaseLayerObjectResults[
                                    queryObject.LayerObjectID.ToString()].Total, 2).ToString() + "%";
                    }
                    if (Res[ItemCodeStr[2] + "_" + Dates[1]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()]
                            .Total == 0)
                    {
                        Results.ComparedGas = "-";
                    }
                    else
                    {
                        Results.ComparedGas =
                            decimal.Round(
                                100 * (Results.Gas -
                                 Res[ItemCodeStr[2] + "_" + Dates[1]].BaseLayerObjectResults[
                                     queryObject.LayerObjectID.ToString()].Total) /
                                Res[ItemCodeStr[2] + "_" + Dates[1]].BaseLayerObjectResults[
                                    queryObject.LayerObjectID.ToString()].Total, 2).ToString() + "%";
                    }
                    if (Res[ItemCodeStr[3] + "_" + Dates[1]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()]
                            .Total == 0)
                    {
                        Results.ComparedWarm = "-";
                    }
                    else
                    {
                        Results.ComparedWarm =
                            decimal.Round(
                                100 * (Results.Warm -
                                 Res[ItemCodeStr[3] + "_" + Dates[1]].BaseLayerObjectResults[
                                     queryObject.LayerObjectID.ToString()].Total) /
                                Res[ItemCodeStr[3] + "_" + Dates[1]].BaseLayerObjectResults[
                                    queryObject.LayerObjectID.ToString()].Total, 2).ToString() + "%";
                    }
                    return Results;
                }
            }
            catch (Exception ex)
            {
                return null;
            }

            return null;
        }
Beispiel #17
0
 public ResultView.IndexMonthEnery GetMonthItemCodeList(DateTime startTime, DateTime endTime)
 {
     IndexMonthEnery MonthResult = new IndexMonthEnery();
     var ObjectList = new BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and LayerObjectParentID='{0}'", 0), " order by LayerObjectID");
     string[] ItemCodeStr = { "01000", "02000", "03000", "04000" };
     Dictionary<string, decimal> SumMonth = new Dictionary<string, decimal>();
     BaseQueryModel model = new BaseQueryModel();
     model.IsDevice = 0;
     model.ObjectList = (from p in ObjectList select p.LayerObjectID).ToList<int>();
     foreach (var item in ItemCodeStr)
     {
         decimal tempCount = 0;
         model.ItemCode = item;
         model.Unit = ChartUnit.unit_month;
         model.Starttime = startTime;
         model.Endtime = endTime;
         var ResList = reportBll.GetBaseEneryDataList(model);
         foreach (var r in ResList.BaseLayerObjectResults)
         {
             tempCount += r.Value.Total;
         }
         SumMonth.Add(item, tempCount);
     }
     if (SumMonth.Count > 0)
     {
         MonthResult.MonthElectricity = SumMonth[ItemCodeStr[0]];
         MonthResult.MonthWater = SumMonth[ItemCodeStr[1]];
         MonthResult.MonthGas = SumMonth[ItemCodeStr[2]];
         MonthResult.MonthWarm = SumMonth[ItemCodeStr[3]];
         return MonthResult;
     }
     return null;
 }
Beispiel #18
0
        public ResultEnergyAnalyse GetEnergyAnalyseLineChart(QueryAnalyse query)
        {
            try
            {
                VerifyPersonOrAreaExist(query);
                #region 返回对象定义
                ResultEnergyAnalyse result = new ResultEnergyAnalyse()
                {
                    OrderLst = new List<EnergyOrder>(),
                    series = new List<EneryAnalyseSeries>()

                };
                result.series.Add(new EneryAnalyseSeries() { data = new List<decimal>() });
                #endregion

                List<Model.Itemcode> itemCodeList = new List<Model.Itemcode>();
                if (query.IsDevice == 0)
                {
                    if (query.ItemCode == "00000")
                    {//总能耗
                        itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ParentID=0 ", " order by ItemcodeID");
                        result.Unit = "T";//标准煤单位
                        result.series[0].name = "总能耗";
                    }
                    else
                    {
                        itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID");
                        if (itemCodeList.Count > 0)
                        {
                            result.Unit = itemCodeList[0].Unit;//单个分类分项单位
                            result.series[0].name = itemCodeList[0].ItemCodeName;
                        }

                    }
                }
                else
                {
                    var deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
                    itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + deviceList[0].ItemCodeID + "'", " order by ItemcodeID");
                    if (itemCodeList.Count > 0)
                    {
                        result.Unit = itemCodeList[0].Unit;//单个分类分项单位
                        result.series[0].name = itemCodeList[0].ItemCodeName;
                    }
                    if (query.ItemCode == "00000")
                    {//总能耗

                        result.Unit = "T";//标准煤单位
                        result.series[0].name = "总能耗";
                    }

                }

                switch (query.QueryType)
                {
                    case EnergyAnalyseQueryType.Convert2Co2:
                    case EnergyAnalyseQueryType.Convert2Coal:
                        result.Unit = "T";//标准煤单位
                        break;
                    case EnergyAnalyseQueryType.Convert2Money:
                        result.Unit = "元";//标准煤单位
                        break;
                }

                DateTime tempStartTime = query.StartTime;
                DateTime tempEndTime = query.EndTime;
                if ((DateTime.Now - tempEndTime).Days == 0)
                {
                    tempEndTime = DateTime.Now;
                }
                switch (query.QueryType)
                {
                    case EnergyAnalyseQueryType.YearCompare://同比值
                        tempStartTime = tempStartTime.AddYears(-1);
                        tempEndTime = tempEndTime.AddYears(-1);
                        break;
                    case EnergyAnalyseQueryType.MonthCompare://环比值

                        tempStartTime = tempStartTime.AddMonths(-1);
                        tempEndTime = tempEndTime.AddMonths(-1);

                        break;
                }
                Dictionary<string, decimal> tempConvert = new Dictionary<string, decimal>();
                Dictionary<string, decimal> tempConvertHour = new Dictionary<string, decimal>();
                var model = new BaseQueryModel();
                model.IsDevice = query.IsDevice;
                model.ObjectList = new List<int>();

                model.ObjectList = new List<int>() { query.ObjectId };

                model.Unit = BaseTool.GetChartUnit(query.particle);
                if (model.Unit == ChartUnit.unit_month)
                {
                    model.Starttime = Convert.ToDateTime(tempStartTime.ToString("yyyy-MM-1"));
                    model.Endtime = Convert.ToDateTime(tempEndTime.ToString("yyyy-MM-1"));
                }
                else
                {
                    model.Starttime = tempStartTime;
                    model.Endtime = tempEndTime;
                }
                int templastmonthdays = 0;
                switch (model.Unit)
                {
                    case ChartUnit.unit_month:
                        for (DateTime i = model.Starttime; i <= model.Endtime; i = i.AddMonths(1))
                        {
                            tempConvert.Add(i.ToString("yyyy-MM-dd"), 0);
                        }
                        break;
                    case ChartUnit.unit_hour:
                        for (DateTime i = model.Starttime; i < model.Endtime.AddDays(1); i = i.AddHours(1))
                        {
                            tempConvert.Add(i.ToString("yyyy-MM-dd HH:00:00"), 0);
                        }
                        break;
                    case ChartUnit.unit_day:
                        templastmonthdays = (model.Endtime - model.Starttime).Days;
                        if (model.Endtime.Hour== 0)
                        {
                            for (DateTime i = model.Starttime; i <= model.Endtime; i = i.AddDays(1))
                            {
                                tempConvert.Add(i.ToString(("yyyy-MM-dd")), 0);
                            }
                        }
                        else
                        {

                            for (DateTime i = model.Starttime; i <= model.Endtime.AddDays(-1); i = i.AddDays(1))
                            {
                                tempConvert.Add(i.ToString(("yyyy-MM-dd")), 0);
                            }

                            for (DateTime i = DateTime.Parse(model.Endtime.ToString("yyyy-MM-dd 00:00:00")); i <= model.Endtime; i = i.AddHours(1))
                            {
                                tempConvertHour.Add(i.ToString("yyyy-MM-dd HH:00:00"), 0);
                            }
                            model.Endtime = DateTime.Parse(tempEndTime.AddDays(-1).ToString("yyyy-MM-dd"));
                        }

                        break;
                }
                string objName = "";

                decimal temphourValue = 0;
                foreach (var item in itemCodeList)
                {
                    model.ItemCode = item.ItemCodeNumber;
                    GenerateEnergyDicValue(model, query, tempConvert,ref objName);
                    if (tempConvertHour.Count>0)
                    {
                        model.Unit = ChartUnit.unit_hour;
                        model.Starttime = DateTime.Parse(tempEndTime.ToString("yyyy-MM-dd 00:00:00"));
                        model.Endtime = DateTime.Parse(tempEndTime.ToString("yyyy-MM-dd HH:00:00"));
                        GenerateEnergyDicValue(model, query, tempConvertHour, ref objName);
                        temphourValue = tempConvertHour.Sum(i => i.Value);

                        model.Starttime = tempStartTime;
                        model.Endtime = DateTime.Parse(tempEndTime.AddDays(-1).ToString("yyyy-MM-dd"));
                        model.Unit = ChartUnit.unit_day;
                    }

                }
                if (tempConvertHour.Count > 0)
                {
                    tempConvert.Add(DateTime.Now.ToString("yyyy-MM-dd"), temphourValue);
                }
                int order = 1;
                foreach (var item in tempConvert)
                {

                    var time = item.Key;
                    if (model.Unit == ChartUnit.unit_month)
                    {
                        time = Convert.ToDateTime(time).ToString("yyyy-MM");
                    }

                    decimal value = decimal.Round(item.Value, 2);
                    result.series[0].data.Add(value);
                    result.OrderLst.Add(new EnergyOrder()
                    {
                        Order = order,
                        Tm = time,
                        Obj = objName,
                        Val = value,
                        EneType = result.series[0].name
                        // EneType =itemCodeList.Count > 1 ? "总能耗" : itemCodeList[0].ItemCodeName

                    });
                    order++;
                }
                if (query.QueryType == EnergyAnalyseQueryType.MonthCompare)
                {
                    int tempcurrentdays = (query.EndTime - query.StartTime).Days;
                    //int index = (28 - query.StartTime.Day) < 0 ? 0 : (28 - query.StartTime.Day);

                    if (model.Unit == ChartUnit.unit_day)
                    {
                        if (tempcurrentdays > templastmonthdays)
                        {//当前时间范围大于上月环比范围
                            int index = System.DateTime.DaysInMonth(query.StartTime.AddMonths(-1).Year, query.StartTime.AddMonths(-1).Month) - query.StartTime.Day;
                            if (index < 0)
                            {
                                index = 0;
                            }
                            for (int i = templastmonthdays; i < tempcurrentdays; i++)
                            {
                                result.series[0].data.Insert(index, result.series[0].data[index]);
                            }

                        }
                        else
                        {
                            if (tempcurrentdays < templastmonthdays)
                            {
                                int index = System.DateTime.DaysInMonth(query.StartTime.AddMonths(-1).Year, query.StartTime.AddMonths(-1).Month) - query.StartTime.Day;
                                for (int i = tempcurrentdays; i < templastmonthdays; i++)
                                {
                                    result.series[0].data.RemoveAt(index);
                                    index--;
                                }
                            }
                        }

                        //for (int i = 0; i < ((query.EndTime - query.StartTime).Days - tempdaycount); i++)
                        //{
                        //    result.series[0].data.Insert(index, result.series[0].data[index]);

                        //}

                    }
                }

                return result;
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }
Beispiel #19
0
        private void GeneratePeriodValues(BaseQueryModel model, MainInfo mainInfo)
        {
            decimal lastmonthEnergyValue = 0;
            model.Unit = ChartUnit.unit_month;
            model.Starttime = DateTime.Parse(model.Starttime.ToString("yyyy-MM-01"));
            model.Endtime = DateTime.Parse(model.Endtime.ToString("yyyy-MM-01"));
            var ResList = reportBll.GetBaseEneryDataList(model, true);
            if (ResList != null)
            {
                foreach (var r in ResList.BaseLayerObjectResults)
                {
                    lastmonthEnergyValue += decimal.Round(r.Value.Total, 2);
                }
            }

            #region 电能耗综合评价 上月日均用电量PK昨日用电量
            //取日的
            EnerySum enerySum = new EnerySum();
            enerySum.PeriodType = 1;//日
            //上月日均用电量:
            enerySum.Value1 =
                (lastmonthEnergyValue / System.DateTime.DaysInMonth(DateTime.Now.AddMonths(-1).Year, DateTime.Now.AddMonths(-1).Month));
            enerySum.Value1 = decimal.Round(enerySum.Value1, 2);
            model.Unit = ChartUnit.unit_day;
            model.Starttime = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"));//昨天
            model.Endtime = model.Starttime;
            ResList = reportBll.GetBaseEneryDataList(model, true);
            foreach (var r in ResList.BaseLayerObjectResults)
            {
                //昨日用电量
                enerySum.Value2 += r.Value.Total;
            }
            enerySum.Value2 = decimal.Round(enerySum.Value2, 2);
            if (enerySum.Value1 > 0)
            {
                //环比
                enerySum.MonthCompare = decimal.Round(100 * (enerySum.Value2 - enerySum.Value1) / enerySum.Value1, 2)
                             .ToString(CultureInfo.InvariantCulture) + "%";
            }
            mainInfo.PeriodValues.Add(enerySum);
            #endregion

            #region 电能耗综合评价 上月周均用电量PK上周用电量
            //取周的
            enerySum = new EnerySum();
            enerySum.PeriodType = 2;//周
            //上月周均用电量:
            enerySum.Value1 =
                (lastmonthEnergyValue * 7 / DateTime.DaysInMonth(DateTime.Now.AddMonths(-1).Year, DateTime.Now.AddMonths(-1).Month));
            enerySum.Value1 = decimal.Round(enerySum.Value1, 2);
            model.Unit = ChartUnit.unit_day;
            //上周一:
            DateTime lastMonday = getWeekUpOfDate(DateTime.Now, DayOfWeek.Monday, -1);
            model.Starttime = DateTime.Parse(lastMonday.ToString("yyyy-MM-dd"));
            model.Endtime = model.Starttime.AddDays(6);
            ResList = reportBll.GetBaseEneryDataList(model, true);
            foreach (var r in ResList.BaseLayerObjectResults)
            {
                //上周用电量
                enerySum.Value2 += r.Value.Total;
            }
            enerySum.Value2 = decimal.Round(enerySum.Value2, 2);
            if (enerySum.Value1 > 0)
            {
                //环比
                enerySum.MonthCompare = decimal.Round(100 * (enerySum.Value2 - enerySum.Value1) / enerySum.Value1, 2)
                             .ToString(CultureInfo.InvariantCulture) + "%";
            }
            mainInfo.PeriodValues.Add(enerySum);
            #endregion

            #region 电能耗综合评价 去年同月用电量PK本月用电量(精确到小时)
            //取月的,//本月用电量:取法为取昨天之前每天用电量之和加上今天当前时间之前每小时用电量
            enerySum = new EnerySum();
            enerySum.PeriodType = 3;//日
            int tempcount = DateTime.Now.Day - 1;//前几天
            //当前月的一号
            DateTime temptime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01"));
            if (tempcount > 0)
            {
                model.Unit = ChartUnit.unit_day;
                model.Starttime = temptime;
                model.Endtime = model.Starttime.AddDays(tempcount - 1);
                ResList = reportBll.GetBaseEneryDataList(model, true);
                foreach (var r in ResList.BaseLayerObjectResults)
                {
                    //本月用电量:取法为取昨天之前每天用电量之和加上今天当前时间之前每小时用电量
                    enerySum.Value2 += r.Value.Total;//上周用电量
                }
            }
            //-----------------------
            model.Unit = ChartUnit.unit_hour;
            //当前时间零点
            temptime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
            model.Starttime = temptime;
            model.Endtime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:00:00"));
            ResList = reportBll.GetBaseEneryDataList(model, true);
            foreach (var r in ResList.BaseLayerObjectResults)
            {
                enerySum.Value2 += r.Value.Total;
            }
            //-----------------------
            //去年同月用电量
            tempcount = DateTime.Now.AddYears(-1).Day - 1;
            if (tempcount > 0)
            {
                model.Unit = ChartUnit.unit_day;
                //去年当月一号
                temptime = DateTime.Parse(DateTime.Now.AddYears(-1).ToString("yyyy-MM-01"));
                model.Starttime = temptime;
                model.Endtime = model.Starttime.AddDays(tempcount - 1);

                ResList = reportBll.GetBaseEneryDataList(model, true);
                foreach (var r in ResList.BaseLayerObjectResults)
                {
                    enerySum.Value1 += r.Value.Total;
                }
            }
            //-----------------------

            model.Unit = ChartUnit.unit_hour;
            //去年同时时间零点
            temptime = DateTime.Parse(DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd 00:00:00"));
            model.Starttime = temptime;
            model.Endtime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:00:00"));
            ResList = reportBll.GetBaseEneryDataList(model, true);
            foreach (var r in ResList.BaseLayerObjectResults)
            {
                enerySum.Value1 = r.Value.Total;
            }
            //-----------------------
            enerySum.Value1 = decimal.Round(enerySum.Value1, 2);
            enerySum.Value2 = decimal.Round(enerySum.Value2, 2);
            if (enerySum.Value1 > 0)
            {
                enerySum.MonthCompare = decimal.Round(100 * (enerySum.Value2 - enerySum.Value1) / enerySum.Value1, 2)
                             .ToString(CultureInfo.InvariantCulture) + "%";
            }
            mainInfo.PeriodValues.Add(enerySum);

            #endregion

            #region 电能耗综合评价 去年同期用电PK今年截止本日用电量(精确到天)
            //取年的,//今年截止本日用电量:取法为取这个月之前每月用电量之和加上当前时间之前每天用电量
            enerySum = new EnerySum();
            enerySum.PeriodType = 4;//年
            tempcount = DateTime.Now.Month - 1;//前几月
            model.Unit = ChartUnit.unit_month;
            //当前时间的一月一号
            temptime = DateTime.Parse(DateTime.Now.ToString("yyyy-01-01"));
            if (tempcount>0)
            {
                model.Starttime = temptime;
                model.Endtime = model.Starttime.AddMonths(tempcount-1);
                ResList = reportBll.GetBaseEneryDataList(model, true);
                foreach (var r in ResList.BaseLayerObjectResults)
                {
                    enerySum.Value2 += r.Value.Total;
                }
            }
            //-----------------------
            tempcount = DateTime.Now.Day - 1;//前几天
            model.Unit = ChartUnit.unit_day;
            //当前月的一号
            temptime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01"));
            if (tempcount>0)
            {
                model.Starttime = temptime;
                model.Endtime = model.Starttime.AddDays(tempcount-1);
                ResList = reportBll.GetBaseEneryDataList(model, true);
                foreach (var r in ResList.BaseLayerObjectResults)
                {
                    enerySum.Value2 += r.Value.Total;
                }
            }
            //-----------------------

            //去年同期用电量

            tempcount = DateTime.Now.AddYears(-1).Month - 1;
            model.Unit = ChartUnit.unit_month;
            //去年一月一号
            temptime = DateTime.Parse(DateTime.Now.AddYears(-1).ToString("yyyy-01-01"));
            if (tempcount>0)
            {
                model.Starttime = temptime;
                model.Endtime = model.Starttime.AddMonths(tempcount-1);
                ResList = reportBll.GetBaseEneryDataList(model, true);
                foreach (var r in ResList.BaseLayerObjectResults)
                {
                    enerySum.Value1 += r.Value.Total;
                }
            }

            //-----------------------

            tempcount = DateTime.Now.AddYears(-1).Day - 1;//前几天
            model.Unit = ChartUnit.unit_day;
            //去年同期月一号
            temptime = DateTime.Parse(DateTime.Now.AddYears(-1).ToString("yyyy-MM-01"));
            if (tempcount>0)
            {
                model.Starttime = temptime;
                model.Endtime = model.Starttime.AddDays(tempcount-1);
                ResList = reportBll.GetBaseEneryDataList(model, true);
                foreach (var r in ResList.BaseLayerObjectResults)
                {
                    enerySum.Value1 += r.Value.Total;//上周用电量
                }
            }
            //-----------------------
            enerySum.Value1 = decimal.Round(enerySum.Value1, 2);
            enerySum.Value2 = decimal.Round(enerySum.Value2, 2);
            if (enerySum.Value1 > 0)
            {
                enerySum.MonthCompare = decimal.Round(100 * (enerySum.Value2 - enerySum.Value1) / enerySum.Value1, 2)
                             .ToString(CultureInfo.InvariantCulture) + "%";
            }
            mainInfo.PeriodValues.Add(enerySum);
            #endregion
        }
Beispiel #20
0
        public ResultEnergyAnalyse GetEnergyAnalyseLineChart_OLD(QueryAnalyse query)
        {
            try
            {

                VerifyPersonOrAreaExist(query);
                #region 返回对象定义
                ResultEnergyAnalyse result = new ResultEnergyAnalyse()
                {
                    OrderLst = new List<EnergyOrder>(),
                    series = new List<EneryAnalyseSeries>()

                };
                result.series.Add(new EneryAnalyseSeries() { data = new List<decimal>() });
                #endregion

                List<Model.Itemcode> itemCodeList = new List<Model.Itemcode>();
                if (query.IsDevice == 0)
                {
                    if (query.ItemCode == "00000")
                    {//总能耗
                        itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ParentID=0 ", " order by ItemcodeID");
                        result.Unit = "T";//标准煤单位
                        result.series[0].name = "总能耗";
                    }
                    else
                    {
                        itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID");
                        if (itemCodeList.Count > 0)
                        {
                            result.Unit = itemCodeList[0].Unit;//单个分类分项单位
                            result.series[0].name = itemCodeList[0].ItemCodeName;

                            //var itemchildCodeList = new BLL.Itemcode().GetItemcodeList(string.Format(" and ParentID={0} ", itemCodeList[0].ItemcodeID), " order by ItemcodeID");

                            //if (itemchildCodeList.Count > 0)
                            //{
                            //    itemCodeList = itemchildCodeList;
                            //}
                        }

                    }
                }
                else
                {
                    var deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
                    itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + deviceList[0].ItemCodeID + "'", " order by ItemcodeID");
                    if (itemCodeList.Count > 0)
                    {
                        result.Unit = itemCodeList[0].Unit;//单个分类分项单位
                        result.series[0].name = itemCodeList[0].ItemCodeName;
                    }
                    if (query.ItemCode == "00000")
                    {//总能耗

                        result.Unit = "T";//标准煤单位
                        result.series[0].name = "总能耗";
                    }

                }

                switch (query.QueryType)
                {
                    case EnergyAnalyseQueryType.Convert2Co2:
                    case EnergyAnalyseQueryType.Convert2Coal:
                        result.Unit = "T";//标准煤单位
                        break;
                    case EnergyAnalyseQueryType.Convert2Money:
                        result.Unit = "元";//标准煤单位
                        break;
                }

                DateTime tempStartTime = query.StartTime;
                DateTime tempEndTime = query.EndTime;
                switch (query.QueryType)
                {
                    case EnergyAnalyseQueryType.YearCompare://同比值
                        tempStartTime = tempStartTime.AddYears(-1);
                        tempEndTime = tempEndTime.AddYears(-1);
                        break;
                    case EnergyAnalyseQueryType.MonthCompare://环比值
                        tempStartTime = tempStartTime.AddMonths(-1);
                        tempEndTime = tempEndTime.AddMonths(-1);

                        break;
                }
                Dictionary<string, decimal> tempConvert = new Dictionary<string, decimal>();
                Dictionary<string, decimal> tempConvertHour = new Dictionary<string, decimal>();
                var model = new BaseQueryModel();
                model.IsDevice = query.IsDevice;
                model.ObjectList = new List<int>();

                model.ObjectList = new List<int>() { query.ObjectId };

                //if (model.IsDevice == 0)
                //{//区域
                //    model.ObjectList = new List<int>() { query.ObjectId };
                //}
                //else
                //{
                //    var device = new BLL.BaseLayerObject().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
                //    if (device.Count > 0)
                //    {
                //        model.ObjectList = (from p in device select p.DeviceID).ToList<int>();
                //    }
                //}
                //model.Unit = GetUnit(query.StartTime, query.EndTime);
                model.Unit = BaseTool.GetChartUnit(query.particle);
                if (model.Unit == ChartUnit.unit_month)
                {
                    model.Starttime = Convert.ToDateTime(tempStartTime.ToString("yyyy-MM-1"));
                    model.Endtime = Convert.ToDateTime(tempEndTime.ToString("yyyy-MM-1"));
                }
                else
                {
                    model.Starttime = tempStartTime;
                    model.Endtime = tempEndTime;
                }
                int templastmonthdays = 0;
                switch (model.Unit)
                {
                    case ChartUnit.unit_month:
                        for (DateTime i = model.Starttime; i <= model.Endtime; i = i.AddMonths(1))
                        {
                            tempConvert.Add(i.ToString("yyyy-MM-dd"), 0);
                        }
                        break;
                    case ChartUnit.unit_hour:
                        for (DateTime i = model.Starttime; i < model.Endtime.AddDays(1); i = i.AddHours(1))
                        {
                            tempConvert.Add(i.ToString("yyyy-MM-dd HH:00:00"), 0);
                        }
                        break;
                    case ChartUnit.unit_day:
                        if ((DateTime.Now- model.Endtime).Days>0)
                        {
                            for (DateTime i = model.Starttime; i <= model.Endtime; i = i.AddDays(1))
                            {
                                tempConvert.Add(i.ToString(("yyyy-MM-dd")), 0);
                            }
                        }
                        else
                        {
                            for (DateTime i = model.Starttime; i <= model.Endtime.AddDays(-1); i = i.AddDays(1))
                            {
                                tempConvert.Add(i.ToString(("yyyy-MM-dd")), 0);
                            }
                            for (DateTime i = model.Endtime; i <= DateTime.Now; i = i.AddHours(1))
                            {
                                tempConvertHour.Add(i.ToString("yyyy-MM-dd HH:00:00"), 0);
                            }

                        }

                        templastmonthdays = (model.Endtime - model.Starttime).Days;
                        break;
                }
                string objName = "";
                foreach (var item in itemCodeList)
                {
                    model.ItemCode = item.ItemCodeNumber;

                    BaseResult resList = _reportBll.GetBaseEneryDataList(model, query.ObjType == AreaType.Liquid ? true : false);

                    foreach (var r in resList.BaseLayerObjectResults)
                    {
                        if (model.IsDevice == 0)
                        {
                            objName = r.Value.baseLayerObject.LayerObjectName;//取区域名称
                        }
                        else
                        {
                            objName = r.Value.device.DeviceName;
                        }
                        foreach (var rr in r.Value.Datas)
                        {
                            if (query.ItemCode == "00000")
                            {
                                switch (query.QueryType)
                                {
                                    case EnergyAnalyseQueryType.Default://默认
                                    case EnergyAnalyseQueryType.YearCompare://默认
                                    case EnergyAnalyseQueryType.MonthCompare://默认
                                        tempConvert[rr.DatePick] += rr.CoalDataValue;
                                        break;
                                    case EnergyAnalyseQueryType.UnitArea://单位面积
                                        tempConvert[rr.DatePick] += rr.CoalDataValue / decimal.Parse(r.Value.baseLayerObject.AreaNum.ToString());

                                        break;
                                    case EnergyAnalyseQueryType.UnitPerson://人均
                                        tempConvert[rr.DatePick] += rr.CoalDataValue / decimal.Parse(r.Value.baseLayerObject.PersonNum.ToString());
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Coal://
                                        tempConvert[rr.DatePick] += rr.CoalDataValue;
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Co2://
                                        tempConvert[rr.DatePick] += rr.Co2DataValue;
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Money://
                                        tempConvert[rr.DatePick] += rr.MoneyDataValue;
                                        break;
                                }
                            }
                            else
                            {
                                switch (query.QueryType)
                                {
                                    case EnergyAnalyseQueryType.Default://默认
                                    case EnergyAnalyseQueryType.YearCompare://默认
                                    case EnergyAnalyseQueryType.MonthCompare://默认
                                        tempConvert[rr.DatePick] += rr.DataValue;
                                        break;
                                    case EnergyAnalyseQueryType.UnitArea://单位面积
                                        tempConvert[rr.DatePick] += rr.DataValue / decimal.Parse(r.Value.baseLayerObject.AreaNum.ToString());

                                        break;
                                    case EnergyAnalyseQueryType.UnitPerson://人均
                                        tempConvert[rr.DatePick] += rr.DataValue / decimal.Parse(r.Value.baseLayerObject.PersonNum.ToString());
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Coal://
                                        tempConvert[rr.DatePick] += rr.CoalDataValue;
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Co2://
                                        tempConvert[rr.DatePick] += rr.Co2DataValue;
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Money://
                                        tempConvert[rr.DatePick] += rr.MoneyDataValue;
                                        break;
                                }

                            }
                        }
                    }
                }
                int order = 1;
                foreach (var item in tempConvert)
                {

                    var time = item.Key;
                    if (model.Unit == ChartUnit.unit_month)
                    {
                        time = Convert.ToDateTime(time).ToString("yyyy-MM");
                    }

                    decimal value = decimal.Round(item.Value, 2);
                    result.series[0].data.Add(value);
                    result.OrderLst.Add(new EnergyOrder()
                    {
                        Order = order,
                        Tm = time,
                        Obj = objName,
                        Val = value,
                        EneType = result.series[0].name
                        // EneType =itemCodeList.Count > 1 ? "总能耗" : itemCodeList[0].ItemCodeName

                    });
                    order++;
                }
                if (query.QueryType == EnergyAnalyseQueryType.MonthCompare)
                {
                    int tempcurrentdays = (query.EndTime - query.StartTime).Days;
                    //int index = (28 - query.StartTime.Day) < 0 ? 0 : (28 - query.StartTime.Day);

                    if (model.Unit == ChartUnit.unit_day)
                    {
                        if (tempcurrentdays > templastmonthdays)
                        {//当前时间范围大于上月环比范围
                            int index = System.DateTime.DaysInMonth(query.StartTime.AddMonths(-1).Year, query.StartTime.AddMonths(-1).Month) - query.StartTime.Day;
                            if (index < 0)
                            {
                                index = 0;
                            }
                            for (int i = templastmonthdays; i < tempcurrentdays; i++)
                            {
                                result.series[0].data.Insert(index, result.series[0].data[index]);
                            }

                        }
                        else
                        {
                            if (tempcurrentdays < templastmonthdays)
                            {
                                int index = System.DateTime.DaysInMonth(query.StartTime.AddMonths(-1).Year, query.StartTime.AddMonths(-1).Month) - query.StartTime.Day;
                                for (int i = tempcurrentdays; i < templastmonthdays; i++)
                                {
                                    result.series[0].data.RemoveAt(index);
                                    index--;
                                }
                            }
                        }

                        //for (int i = 0; i < ((query.EndTime - query.StartTime).Days - tempdaycount); i++)
                        //{
                        //    result.series[0].data.Insert(index, result.series[0].data[index]);

                        //}

                    }
                }

                return result;
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }
Beispiel #21
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;
        }
Beispiel #22
0
 public BaseResult GetQuerySingleItemCodeEneryTotal(NTS.WEB.DataContact.BasicQuery query)
 {
     var ObjectList = new BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and LayerObjectID={0}", query.ObjectNum), " order by LayerObjectID");
     // var ItemList = new BLL.Itemcode().GetItemcodeList(" and ParentID=-1", " order by ItemcodeID");
     //List<string> ItemCodeStr = (from item in ItemList select item.ItemCodeNumber).ToList<string>();
     BaseQueryModel model = new BaseQueryModel();
     model.IsDevice = 0;
     model.ObjectList = (from p in ObjectList select p.LayerObjectID).ToList<int>();
     model.ItemCode = query.ItemCode;
     model.Unit = BaseTool.GetChartUnit(query.Unit);
     model.Starttime = query.StartTime;
     model.Endtime = query.EndTime;
     var ResList = reportBll.GetBaseEneryDataList(model);
     return ResList;
 }
Beispiel #23
0
        public Dictionary<string, EnergyValueCost> GetSingleItemCodeValue(QueryCost query, List<Model.Itemcode> itemCodeList)
        {
            var model = new BaseQueryModel();
            model.IsDevice = 0;
            model.areaType = query.ObjType;
            model.ObjectList = new List<int>() { query.ObjectId };
            model.Unit = BaseTool.GetChartUnit((int)query.Particle - 1);

            if (model.Unit == ChartUnit.unit_month)
            {
                model.Starttime = Convert.ToDateTime(query.StartTime.ToString("yyyy-MM-1"));
                model.Endtime = Convert.ToDateTime(query.EndTime.ToString("yyyy-MM-1"));
            }
            else
            {
                model.Starttime = query.StartTime;
                model.Endtime = query.EndTime;
            }

            Dictionary<string, EnergyValueCost> tempConvert = new Dictionary<string, EnergyValueCost>();
            Dictionary<string, EnergyValueCost> tempConvert4Day = new Dictionary<string, EnergyValueCost>();
            switch (model.Unit)
            {
                case ChartUnit.unit_month:
                    for (DateTime i = model.Starttime; i <= model.Endtime.AddMonths(-1); i = i.AddMonths(1))
                    {
                        tempConvert.Add(i.ToString("yyyy-MM-01"), new EnergyValueCost { EnergyCost = 0, EnergyValue = 0 });
                    }
                    for (DateTime i = DateTime.Parse(query.EndTime.ToString("yyyy-MM-01")); i <= query.EndTime; i = i.AddDays(1))
                    {
                        tempConvert4Day.Add(i.ToString(("yyyy-MM-dd")), new EnergyValueCost { EnergyCost = 0, EnergyValue = 0 });
                    }
                    model.Endtime = query.EndTime.AddMonths(-1);
                    break;
                case ChartUnit.unit_hour:
                    for (DateTime i = model.Starttime; i < model.Endtime.AddDays(1); i = i.AddHours(1))
                    {
                        tempConvert.Add(i.ToString("yyyy-MM-dd HH:00:00"), new EnergyValueCost { EnergyCost = 0, EnergyValue = 0 });
                    }
                    break;
                case ChartUnit.unit_day:
                    for (DateTime i = model.Starttime; i <= model.Endtime; i = i.AddDays(1))
                    {
                        tempConvert.Add(i.ToString(("yyyy-MM-dd")), new EnergyValueCost { EnergyCost = 0, EnergyValue = 0 });
                    }
                    break;
            }
            foreach (var item in itemCodeList)
            {
                decimal price = _accssCommon.GetFeePrice(item.ItemCodeNumber);
                model.ItemCode = item.ItemCodeNumber;
                GenerateEnergyValue(model, tempConvert, price);
                if (tempConvert4Day.Count > 0)
                {
                    model.Starttime = DateTime.Parse(query.EndTime.ToString("yyyy-MM-01"));
                    model.Endtime = query.EndTime;
                    model.Unit = ChartUnit.unit_day;
                    GenerateEnergyValue(model, tempConvert4Day, price);
                    EnergyValueCost temp = new EnergyValueCost()
                                               {
                                                    EnergyCost=tempConvert4Day.Sum(i => i.Value.EnergyCost),
                                                    EnergyValue = tempConvert4Day.Sum(i => i.Value.EnergyValue),

                                               };

                    tempConvert.Add(query.EndTime.ToString("yyyy-MM-01"), temp);
                }

            }

            return tempConvert;
        }
Beispiel #24
0
        public NTS.WEB.ResultView.ShopOrderResult GetShopOrder(NTS.WEB.DataContact.QueryOrder query)
        {
            string keyCatch = string.Empty;
            foreach (var q in query.ObjectNum)
            {
                keyCatch += q.ToString() + "_";
            }
            keyCatch += query.ItemCode + query.OrderWay + query.StartTime + query.EndTime + query.Particle;
            if (CacheHelper.GetCache(keyCatch) != null)
            {
                return PaddingList((ShopOrderResult)CacheHelper.GetCache(keyCatch), query);
            }

            #region 定义区
            ShopOrderResult shopOrderResult = new ShopOrderResult();
            shopOrderResult.OrderList = new List<BaseOrder>();
            shopOrderResult.page = new Padding();
            #endregion

            var ItemList = new List<Model.Itemcode>();
            var shopOrder = new IndexShopOrder
            {
                TotalEneryOrderList = new List<EneryOrder>(),
                AreaEneryOrderList = new List<EneryOrder>()
            };
            var shopOrderLast = new IndexShopOrder
            {
                TotalEneryOrderList = new List<EneryOrder>(),
                AreaEneryOrderList = new List<EneryOrder>()
            };
            // var deepth = int.Parse(ConfigurationManager.AppSettings["ShopLevel"]);
            if (query.ItemCode == "00000")
            {
                ItemList = new BLL.Itemcode().GetItemcodeList(" and ParentID=0", " order by ItemcodeID");
            }
            else
            {
                ItemList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID");
            }
            List<string> ItemCodeStr = (from item in ItemList select item.ItemCodeNumber).ToList<string>();
            var model = new BaseQueryModel();
            model.IsDevice = 0;
            model.ObjectList = query.ObjectNum;
            Dictionary<string, decimal> tempConvert = new Dictionary<string, decimal>();
            Dictionary<string, decimal> tempAreaConvert = new Dictionary<string, decimal>();
            // decimal[] tempConvert = new decimal[objectList.Count];
            //  decimal[] tempAreaConvert = new decimal[objectList.Count];
            foreach (var item in ItemCodeStr)
            {
                model.ItemCode = item;
                model.Unit = GetUnit(query.StartTime, query.EndTime);
                if (model.Unit == ChartUnit.unit_month)
                {
                    model.Starttime = Convert.ToDateTime(query.StartTime.ToString("yyyy-MM-1"));
                    model.Endtime = Convert.ToDateTime(query.EndTime.ToString("yyyy-MM-1"));
                }
                else
                {
                    model.Starttime = query.StartTime;
                    model.Endtime = query.EndTime;
                }
                var resList = reportBll.GetBaseEneryDataList(model);
                const int order = 1;
                foreach (var r in resList.BaseLayerObjectResults)
                {
                    if (tempConvert.ContainsKey(r.Value.baseLayerObject.LayerObjectName))
                    {
                        if (query.ItemCode == "00000")
                        {

                            tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                            tempAreaConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString()) /
                                decimal.Parse(r.Value.baseLayerObject.AreaNum.ToString());
                        }
                        else
                        {
                            tempConvert[r.Value.baseLayerObject.LayerObjectName] += r.Value.Total;
                            tempAreaConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                r.Value.Total /
                                decimal.Parse(r.Value.baseLayerObject.AreaNum.ToString());
                        }
                    }
                    else
                    {
                        if (query.ItemCode == "00000")
                        {
                            tempConvert.Add(r.Value.baseLayerObject.LayerObjectName,
                                            decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString()));
                            tempAreaConvert.Add(r.Value.baseLayerObject.LayerObjectName,
                                                decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString()) /
                                                decimal.Parse(r.Value.baseLayerObject.AreaNum.ToString()));
                        }
                        else
                        {
                            tempConvert.Add(r.Value.baseLayerObject.LayerObjectName,
                                            r.Value.Total);
                            tempAreaConvert.Add(r.Value.baseLayerObject.LayerObjectName,
                                                r.Value.Total /
                                                decimal.Parse(r.Value.baseLayerObject.AreaNum.ToString()));
                        }
                    }

                    shopOrder.TotalEneryOrderList.Add(new EneryOrder()
                    {
                        BuildingName = r.Value.baseLayerObject.LayerObjectName,
                        EneryValue = double.Parse(tempConvert[r.Value.baseLayerObject.LayerObjectName].ToString("f2")),
                        OrderNum = order
                    });

                    shopOrder.AreaEneryOrderList.Add(new EneryOrder()
                    {
                        BuildingName = r.Value.baseLayerObject.LayerObjectName,
                        EneryValue = double.Parse(tempAreaConvert[r.Value.baseLayerObject.LayerObjectName].ToString("f2")),
                        OrderNum = order
                    });
                }
            }

            var res1 = from p in shopOrder.TotalEneryOrderList group p by p.BuildingName into g select new { g.Key, BuildingName = g.Max(p => p.BuildingName), OrderNum = g.Max(p => p.OrderNum), EneryValue = g.Max(p => p.EneryValue) };
            var res2 = from p in shopOrder.AreaEneryOrderList group p by p.BuildingName into g select new { g.Key, BuildingName = g.Max(p => p.BuildingName), OrderNum = g.Max(p => p.OrderNum), EneryValue = g.Max(p => p.EneryValue) };

            foreach (var c in res1)
            {
                shopOrderLast.TotalEneryOrderList.Add(new EneryOrder { BuildingName = c.BuildingName, EneryValue = c.EneryValue, OrderNum = c.OrderNum });
            }

            foreach (var c in res2)
            {
                shopOrderLast.AreaEneryOrderList.Add(new EneryOrder { BuildingName = c.BuildingName, EneryValue = c.EneryValue, OrderNum = c.OrderNum });
            }
            int record = shopOrderLast.TotalEneryOrderList.Count;
            shopOrderResult.page = new Padding()
            {
                Current = query.PageCurrent,
                Total = (record % query.PageSize == 0) ? record / query.PageSize : record / query.PageSize + 1
            };
            int orders = 1;
            if (query.Particle == "total")
            {
                foreach (var r in shopOrderLast.TotalEneryOrderList)
                {
                    shopOrderResult.OrderList.Add(new BaseOrder()
                        {
                            Energy = decimal.Parse(r.EneryValue.ToString("f2")),
                            Id = orders,
                            Title = r.BuildingName,
                            Units = query.ItemCode == "00000" ? "T" : ItemList[0].Unit
                        });
                    orders++;
                }
            }
            else
            {
                foreach (var r in shopOrderLast.AreaEneryOrderList)
                {
                    shopOrderResult.OrderList.Add(new BaseOrder()
                    {
                        Energy = decimal.Parse(r.EneryValue.ToString("f2")),
                        Id = r.OrderNum,
                        Title = r.BuildingName,
                        Units = query.ItemCode == "00000" ? "T" : ItemList[0].Unit
                    });
                }
            }

            if (CacheHelper.GetCache(keyCatch) == null)
            {
                CacheHelper.SetCache(keyCatch, shopOrderResult);
            }
            return PaddingList(shopOrderResult, query);
        }
Beispiel #25
0
 private void GenerateEnergyValue(BaseQueryModel model, Dictionary<string, EnergyValueCost> tempConvert, decimal price)
 {
     BaseResult resList = _reportBll.GetBaseEneryDataList(model, model.areaType == AreaType.Liquid ? true : false);
     foreach (var r in resList.BaseLayerObjectResults)
     {
         foreach (var rr in r.Value.Datas)
         {
             if (tempConvert.ContainsKey(rr.DatePick))
             {
                 if (model.ItemCode == "00000")
                 {
                     tempConvert[rr.DatePick].EnergyValue += rr.CoalDataValue;
                     tempConvert[rr.DatePick].EnergyCost += rr.CoalDataValue * price;
                 }
                 else
                 {
                     tempConvert[rr.DatePick].EnergyValue += rr.DataValue;
                     tempConvert[rr.DatePick].EnergyCost += rr.DataValue * price;
                 }
             }
         }
     }
 }
Beispiel #26
0
        public ResultOrder GetShopOrderNew(NTS.WEB.DataContact.QueryOrderObjects query)
        {
            try
            {
                string keyCatch = string.Empty;
                foreach (var q in query.AreaIdLst)
                {
                    keyCatch += q.ToString() + "_";
                }
                keyCatch += query.ItemCode + query.StartTime + query.EndTime + query.QueryType + query.ObjType;
                if (CacheHelper.GetCache(keyCatch) != null)
                {
                    return (ResultOrder)CacheHelper.GetCache(keyCatch);
                }

                VerifyPersonOrAreaExist(query);

                #region 返回对象定义
                ResultOrder resultOrder = new ResultOrder();
                resultOrder.lineHighChart = new LineHighChart()
                {
                    series =
                        new List<Series>()
                };
                resultOrder.lineHighChart.series.Add(new Series() { data = new List<EneryHighChart>() });
                resultOrder.pieHighChart = new PieHighChart()
                {
                    series =
                        new List<Series>()
                };
                resultOrder.pieHighChart.series.Add(new Series() { data = new List<EneryHighChart>() });

                resultOrder.OrderLst = new List<EnergyOrder>();
                #endregion

                List<Model.Itemcode> itemCodeList = new List<Model.Itemcode>();
                if (query.ItemCode == "00000")
                {//总能耗
                    itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ParentID=0 ", " order by ItemcodeID");
                    resultOrder.Unit = "T";//标准煤单位
                }
                else
                {
                    itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID");
                    if (itemCodeList.Count > 0)
                    {
                        resultOrder.Unit = itemCodeList[0].Unit;//单个分类分项单位
                    }
                }
                switch(query.QueryType)
                {
                    case EnergyAnalyseQueryType.Convert2Co2:
                    case EnergyAnalyseQueryType.Convert2Coal:
                         resultOrder.Unit = "T";//标准煤单位
                        break;
                    case EnergyAnalyseQueryType.Convert2Money:
                        resultOrder.Unit = "元";//标准煤单位
                        break;
                }
                Dictionary<string, decimal> tempConvert = new Dictionary<string, decimal>();
                Dictionary<string, int> tempObjectConvert = new Dictionary<string, int>();
                var model = new BaseQueryModel();
                model.IsDevice = 0;
                model.ObjectList = query.AreaIdLst;
                //model.Unit = GetUnit(query.StartTime, query.EndTime);
                model.Unit = BaseTool.GetChartUnit(query.Particle);

                if (model.Unit == ChartUnit.unit_month)
                {
                    model.Starttime = Convert.ToDateTime(query.StartTime.ToString("yyyy-MM-1"));
                    model.Endtime = Convert.ToDateTime(query.EndTime.ToString("yyyy-MM-1"));
                }
                else
                {
                    model.Starttime = query.StartTime;
                    model.Endtime = query.EndTime;
                }
                foreach (var item in itemCodeList)
                {
                    model.ItemCode = item.ItemCodeNumber;
                    BaseResult resList = reportBll.GetBaseEneryDataList(model, query.ObjType == AreaType.Liquid ? true : false);
                    if (resList == null)
                    {
                        continue;
                    }
                    foreach (var r in resList.BaseLayerObjectResults)
                    {
                        if (!tempConvert.ContainsKey(r.Value.baseLayerObject.LayerObjectName))
                        {
                            tempConvert.Add(r.Value.baseLayerObject.LayerObjectName, 0);
                        }
                        if (!tempObjectConvert.ContainsKey(r.Value.baseLayerObject.LayerObjectName))
                        {
                            tempObjectConvert.Add(r.Value.baseLayerObject.LayerObjectName, r.Value.baseLayerObject.LayerObjectID);
                        }
                        if (tempConvert.ContainsKey(r.Value.baseLayerObject.LayerObjectName))
                        {
                            if (query.ItemCode == "00000")
                            {//选择总能耗后把其他分类分项的能耗转化成标准煤
                                switch (query.QueryType)
                                {
                                    case EnergyAnalyseQueryType.Default: //默认总能耗
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                  decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());//
                                        break;
                                    case EnergyAnalyseQueryType.UnitArea://单位面积能耗
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                    decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString()) /
                                    decimal.Parse(r.Value.baseLayerObject.AreaNum.ToString());
                                        break;
                                    case EnergyAnalyseQueryType.UnitPerson://人均能耗
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                 decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString()) /
                                 decimal.Parse(r.Value.baseLayerObject.PersonNum.ToString());
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Coal://标准煤
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                            decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Co2://二氧化碳
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                            decimal.Parse(r.Value.ConvertDataValueList["ITEMCO2"].ToString());
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Money://人民币
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                            decimal.Parse(r.Value.ConvertDataValueList["ITEMMONEY"].ToString());
                                        break;
                                    default:
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());//
                                        break;
                                }
                            }
                            else
                            {
                                switch (query.QueryType)
                                {
                                    case EnergyAnalyseQueryType.Default: //默认总能耗
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] += r.Value.Total;
                                        break;
                                    case EnergyAnalyseQueryType.UnitArea://单位面积能耗
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                     r.Value.Total /
                                     decimal.Parse(r.Value.baseLayerObject.AreaNum.ToString());
                                        break;
                                    case EnergyAnalyseQueryType.UnitPerson://人均能耗
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                     r.Value.Total /
                                     decimal.Parse(r.Value.baseLayerObject.PersonNum.ToString());
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Coal://标准煤
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                            decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Co2://二氧化碳
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                            decimal.Parse(r.Value.ConvertDataValueList["ITEMCO2"].ToString());
                                        break;
                                    case EnergyAnalyseQueryType.Convert2Money://人民币
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] +=
                                            decimal.Parse(r.Value.ConvertDataValueList["ITEMMONEY"].ToString());
                                        break;
                                    default:
                                        tempConvert[r.Value.baseLayerObject.LayerObjectName] += r.Value.Total;
                                        break;
                                }

                            }
                        }

                    }
                }
                var tempAsc = from tt in tempConvert orderby tt.Value ascending select tt;//LineChart按照能耗值从低到高排序

                foreach (var tempConvertItem in tempAsc)
                {
                    resultOrder.lineHighChart.series[0].data.Add(new EneryHighChart()
                    {
                        name = tempConvertItem.Key,
                        id = tempObjectConvert[tempConvertItem.Key].ToString(),
                        y = decimal.Parse(tempConvertItem.Value.ToString("f2"))

                    });
                }

                var tempDesc = from tt in tempConvert orderby tt.Value descending select tt;//PieChart按照能耗值从高到低排序
                int temppieindex = 1;
                decimal temppiecount = 0;
                foreach (var tempConvertItem in tempDesc)
                {
                    if (temppieindex < 6)
                    {
                        resultOrder.pieHighChart.series[0].data.Add(new EneryHighChart()
                        {
                            name = tempConvertItem.Key,
                            y = decimal.Parse(tempConvertItem.Value.ToString("f2"))
                        });
                    }
                    else
                    {
                        temppiecount += decimal.Parse(tempConvertItem.Value.ToString("f2"));

                    }
                    temppieindex++;
                }
                if (temppieindex > 6)
                {
                    resultOrder.pieHighChart.series[0].data.Add(new EneryHighChart()
                    {
                        name = "其他",
                        y = temppiecount

                    });
                }

                int order = 1;
                foreach (var tt in resultOrder.lineHighChart.series[0].data)
                {
                    resultOrder.OrderLst.Add(new EnergyOrder()
                                                 {
                                                     Order = order,
                                                     Tm = model.Unit == ChartUnit.unit_hour ? query.StartTime.ToString("yyyy-MM-dd") : query.StartTime.ToString("yyyy-MM-dd") + "~" + query.EndTime.ToString("yyyy-MM-dd"),
                                                     Obj = tt.name,
                                                     //ObjID=tempObjectConvert[tt.name],
                                                     Val = tt.y,
                                                     EneType = itemCodeList.Count > 1 ? "总能耗" : itemCodeList[0].ItemCodeName

                                                 });
                    order++;
                }

                if (CacheHelper.GetCache(keyCatch) == null)
                {
                    CacheHelper.SetCache(keyCatch, resultOrder, 30);
                }
                return resultOrder;
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }
Beispiel #27
0
 public BaseResult GetBaseEneryDataList(BaseQueryModel model, bool IsLiquid)
 {
     return BigDataComm.GetBaseEneryDataList(model,IsLiquid);
 }
Beispiel #28
0
        public IndexLimit GetIndexLimit(DateTime startTime, DateTime endTime)
        {
            var eneryDataList = new Dictionary<string, decimal>();
            var indexLimit = new IndexLimit()
                {
                    ElectricityHigh = 0,
                    ElectricityHighTime = "-",
                    ElectricityLow = 0,
                    ElectricityLowTime = "-"
                };
            var model = new BaseQueryModel();
            var objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and LayerObjectParentID={0}", 0), " order by LayerObjectID");
            model.IsDevice = 0;
            model.ObjectList = (from p in objectList select p.LayerObjectID).ToList<int>();
            model.ItemCode = "01000";
            model.Unit = ChartUnit.unit_hour;
            model.Starttime = startTime;
            model.Endtime = endTime;
            var resList = reportBll.GetBaseEneryDataList(model);
            foreach (var o in objectList)
            {
                decimal countValue = 0;
                foreach (var d in resList.BaseLayerObjectResults[o.LayerObjectID.ToString()].Datas)
                {
                    // countValue += d.DataValue;
                    if (!eneryDataList.ContainsKey(d.DatePick))
                    {
                        eneryDataList.Add(d.DatePick, d.DataValue);
                    }
                    else
                    {
                        eneryDataList[d.DatePick] += d.DataValue;
                    }
                }
            }

            var limitTemp = eneryDataList.Select(e => new TempList() { DatePick = e.Key, DataValue = e.Value }).ToList();
            limitTemp = (from l in limitTemp orderby l.DataValue select l).ToList();
            if (limitTemp.Count > 0)
            {
                indexLimit.ElectricityLow = limitTemp[0].DataValue;
                indexLimit.ElectricityLowTime = Convert.ToDateTime(limitTemp[0].DatePick).ToString("HH:mm");
                indexLimit.ElectricityHigh = limitTemp[limitTemp.Count - 1].DataValue;
                indexLimit.ElectricityHighTime = Convert.ToDateTime(limitTemp[limitTemp.Count - 1].DatePick).ToString("HH:mm");
            }
            return indexLimit;
        }
Beispiel #29
0
 public BaseResult GetBaseEneryDataListNew(BaseQueryModel model)
 {
     return EnergyContrastCommon.GetBaseEneryDataListNew(model);
 }
Beispiel #30
0
        public ResultEnergyAnalysePie GetEnergyAnalysePie(QueryAnalyse query)
        {
            try
            {

                VerifyPersonOrAreaExist(query);

                ResultEnergyAnalysePie result = new ResultEnergyAnalysePie()
                {
                    LayerPie = new PieHighChart() { series = new List<Series>() },
                    ItemCodePie = new PieHighChart() { series = new List<Series>() }
                };
                result.LayerPie.series.Add(new Series() { data = new List<EneryHighChart>() });
                result.ItemCodePie.series.Add(new Series() { data = new List<EneryHighChart>() });
                query.QueryType = EnergyAnalyseQueryType.Default;

                List<Model.Itemcode> itemCodeList = new List<Model.Itemcode>();
                if (query.ItemCode == "00000")
                {//总能耗
                    itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ParentID=0 ", " order by ItemcodeID");
                    result.Unit = "T";//标准煤单位
                }
                else
                {

                    itemCodeList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID");
                    if (itemCodeList.Count > 0)
                    {
                        result.Unit = itemCodeList[0].Unit;//单个分类分项单位

                        var itemchildCodeList = new BLL.Itemcode().GetItemcodeList(string.Format(" and ParentID={0} ", itemCodeList[0].ItemcodeID), " order by ItemcodeID");

                        if (itemchildCodeList.Count > 0)
                        {
                            itemCodeList = itemchildCodeList;
                        }
                    }
                }
                switch (query.QueryType)
                {
                    case EnergyAnalyseQueryType.Convert2Co2:
                    case EnergyAnalyseQueryType.Convert2Coal:
                        result.Unit = "T";//标准煤单位
                        break;
                    case EnergyAnalyseQueryType.Convert2Money:
                        result.Unit = "元";//标准煤单位
                        break;
                }
                var model = new BaseQueryModel();
                model.IsDevice = query.IsDevice;
                model.ObjectList = new List<int>() { query.ObjectId };
                model.IsDevice = 0;//只获取区域的
                if (model.IsDevice == 0)
                {//区域
                    //model.ObjectList = (from p in LayerObjectList select p.LayerObjectID).ToList<int>();
                    model.ObjectList = query.ObjectChildren;
                    if (model.ObjectList.Count == 0)
                    {//如果选择的区域对象下没有子集则取当前对象能耗,否则取各子集能耗
                        model.ObjectList = new List<int>() { query.ObjectId };
                    }
                }
                else
                {//设备只取当前对象能耗

                    //var device = new BLL.BaseLayerObject().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
                    //if (device.Count > 0)
                    //{
                    //    model.ObjectList = (from p in device select p.DeviceID).ToList<int>();
                    //}
                }

                //model.Unit = GetUnit(query.StartTime, query.EndTime);
                model.Unit = BaseTool.GetChartUnit(query.particle);
                if (model.Unit == ChartUnit.unit_month)
                {
                    model.Starttime = Convert.ToDateTime(query.StartTime.ToString("yyyy-MM-1"));
                    model.Endtime = Convert.ToDateTime(query.EndTime.ToString("yyyy-MM-1"));
                }
                else
                {
                    model.Starttime = query.StartTime;
                    model.Endtime = query.EndTime;
                }

                Dictionary<string, decimal> tempLayerConvert = new Dictionary<string, decimal>();
                Dictionary<string, decimal> tempItemcodeConvert = new Dictionary<string, decimal>();
                if (query.ObjectChildren.Count == 0)
                {//当前选项没有子节点,则layer能耗和分类分项能耗就取当前选中节点的能耗值

                    foreach (var item in itemCodeList)
                    {
                        tempItemcodeConvert.Add(item.ItemCodeName, 0);

                        model.ItemCode = item.ItemCodeNumber;
                        BaseResult resList = _reportBll.GetBaseEneryDataList(model, query.ObjType == AreaType.Liquid ? true : false);
                        foreach (var r in resList.BaseLayerObjectResults)
                        {
                            var key = "";
                            if (model.IsDevice == 0)
                            {
                                key = r.Value.baseLayerObject.LayerObjectName;
                            }
                            else
                            {
                                key = r.Value.device.DeviceName;
                            }
                            if (!tempLayerConvert.ContainsKey(key))
                            {
                                tempLayerConvert.Add(key, 0);
                            }
                            if (query.ItemCode == "00000")
                            {//选择总能耗后把其他分类分项的能耗转化成标准煤
                                switch (query.QueryType)
                                {
                                    case EnergyAnalyseQueryType.Default: //默认总能耗
                                        tempLayerConvert[key] +=
                                  decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());//
                                        tempItemcodeConvert[item.ItemCodeName] += decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                                        break;
                                    default:
                                        tempLayerConvert[key] +=
                                decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                                        tempItemcodeConvert[item.ItemCodeName] += decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                                        break;
                                }
                            }
                            else
                            {
                                switch (query.QueryType)
                                {
                                    case EnergyAnalyseQueryType.Default: //默认总能耗
                                        tempLayerConvert[key] += r.Value.Total;
                                        tempItemcodeConvert[item.ItemCodeName] += r.Value.Total;
                                        break;
                                    default:
                                        tempLayerConvert[key] += r.Value.Total;
                                        tempItemcodeConvert[item.ItemCodeName] += r.Value.Total;
                                        break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    model.ObjectList = query.ObjectChildren;//先获取layer子节点能耗值
                    foreach (var item in itemCodeList)
                    {

                        model.ItemCode = item.ItemCodeNumber;
                        BaseResult resList = _reportBll.GetBaseEneryDataList(model, query.ObjType == AreaType.Liquid ? true : false);
                        foreach (var r in resList.BaseLayerObjectResults)
                        {
                            var key = "";
                            if (model.IsDevice == 0)
                            {
                                key = r.Value.baseLayerObject.LayerObjectName;
                            }
                            else
                            {
                                key = r.Value.device.DeviceName;
                            }
                            if (!tempLayerConvert.ContainsKey(key))
                            {
                                tempLayerConvert.Add(key, 0);
                            }
                            if (query.ItemCode == "00000")
                            {//选择总能耗后把其他分类分项的能耗转化成标准煤
                                switch (query.QueryType)
                                {
                                    case EnergyAnalyseQueryType.Default: //默认总能耗
                                        tempLayerConvert[key] +=
                                  decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());//

                                        break;
                                    default:
                                        tempLayerConvert[key] +=
                                decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());

                                        break;
                                }
                            }
                            else
                            {
                                switch (query.QueryType)
                                {
                                    case EnergyAnalyseQueryType.Default: //默认总能耗
                                        tempLayerConvert[key] += r.Value.Total;

                                        break;
                                    default:
                                        tempLayerConvert[key] += r.Value.Total;

                                        break;
                                }

                            }

                        }

                    }

                    model.ObjectList = new List<int>() { query.ObjectId };//获取分类分项能耗值
                    foreach (var item in itemCodeList)
                    {
                        tempItemcodeConvert.Add(item.ItemCodeName, 0);
                        model.ItemCode = item.ItemCodeNumber;
                        BaseResult resList = _reportBll.GetBaseEneryDataList(model, query.ObjType == AreaType.Liquid ? true : false);

                        foreach (var r in resList.BaseLayerObjectResults)
                        {
                            if (query.ItemCode == "00000")
                            {//选择总能耗后把其他分类分项的能耗转化成标准煤
                                tempItemcodeConvert[item.ItemCodeName] += decimal.Parse(r.Value.ConvertDataValueList["ITEMCOAL"].ToString());
                            }
                            else
                            {
                                tempItemcodeConvert[item.ItemCodeName] += r.Value.Total;
                            }
                        }

                    }
                }
                var tempDesc = from tt in tempLayerConvert orderby tt.Value descending select tt;//PieChart按照能耗值从高到低排序
                int tempindex = 1;
                decimal tempcount = 0;
                foreach (var item in tempDesc)
                {
                    decimal value = decimal.Round(item.Value, 2);
                    if (tempindex < 11)
                    {
                        result.LayerPie.series[0].data.Add(new EneryHighChart()
                        {
                            name = item.Key,
                            y = value
                        });
                    }
                    else
                    {
                        tempcount += value;
                    }

                    tempindex++;
                }
                if (tempindex > 11)
                {
                    result.LayerPie.series[0].data.Add(new EneryHighChart()
                    {
                        name = "其他",
                        y = tempcount
                    });
                }
                tempDesc = from tt in tempItemcodeConvert orderby tt.Value descending select tt;//PieChart按照能耗值从高到低排序
                tempindex = 1;
                tempcount = 0;
                foreach (var item in tempDesc)
                {
                    decimal value = decimal.Round(item.Value, 2);
                    if (tempindex < 11)
                    {
                        result.ItemCodePie.series[0].data.Add(new EneryHighChart()
                        {
                            name = item.Key,
                            y = value
                        });
                    }
                    else
                    {
                        tempcount += value;
                    }
                    tempindex++;
                }
                if (tempindex > 10)
                {
                    result.ItemCodePie.series[0].data.Add(new EneryHighChart()
                    {
                        name = "其他",
                        y = tempcount
                    });
                }
                return result;
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }