Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //EneryOrderList list = new EneryOrderList();
            //list.TotalEneryOrderList = new List<EneryOrder>();
            //list.TotalEneryOrderList.Add(new EneryOrder() { OrderNum = 1, BuildingName = "新城科技园1号楼", EneryValue = 1230.22 });
            //list.TotalEneryOrderList.Add(
            //    new EneryOrder() { OrderNum = 2, BuildingName = "新城科技园2号楼", EneryValue = 2230.22 }
            //    );
            //list.TotalEneryOrderList.Add(
            //    new EneryOrder() { OrderNum = 3, BuildingName = "新城科技园3号楼", EneryValue = 3230.22 }
            //    );
            //list.AreaEneryOrderList = new List<EneryOrder>();
            //list.AreaEneryOrderList.Add(new EneryOrder() { OrderNum = 1, BuildingName = "新城科技园6号楼", EneryValue = 130.22 });
            //list.AreaEneryOrderList.Add(
            //    new EneryOrder() { OrderNum = 2, BuildingName = "新城科技园7号楼", EneryValue = 230.22 }
            //    );
            //list.AreaEneryOrderList.Add(
            //    new EneryOrder() { OrderNum = 3, BuildingName = "新城科技园8号楼", EneryValue = 330.22 }
            //    );

            NTS.WEB.DataContact.QueryOrder query = new QueryOrder();
            query.ItemCode = "00000";
            query.EndTime = DateTime.Parse("2013-11-30");
            query.ObjectNum = new List<int>() {889,1};
            query.OrderWay = "asc";
            query.PageCurrent = 1;
            query.PageSize = 10;
            query.Particle = "all";
            query.StartTime = DateTime.Parse("2013-10-1");
            Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(query));
        }
Esempio n. 2
0
        private ShopOrderResult PaddingList(ShopOrderResult shopOrderResult, NTS.WEB.DataContact.QueryOrder query)
        {
            var padding = new ShopOrderResult();

            padding.OrderList = new List <BaseOrder>();
            int min = query.PageSize * (query.PageCurrent - 1);
            int max = min + query.PageSize;

            if (query.OrderWay != "asc")
            {
                var orderRes =
                    from p in shopOrderResult.OrderList
                    orderby p.Energy descending
                    select p;
                shopOrderResult.OrderList = orderRes.ToList();
            }
            else
            {
                var orderRes =
                    from p in shopOrderResult.OrderList
                    orderby p.Energy ascending
                    select p;
                shopOrderResult.OrderList = orderRes.ToList();
            }
            for (int sr = 0; sr < shopOrderResult.OrderList.Count; sr++)
            {
                if (sr >= min && sr < max)
                {
                    shopOrderResult.OrderList[sr].Id = sr + 1;
                    padding.OrderList.Add(shopOrderResult.OrderList[sr]);
                }
            }
            padding.page         = shopOrderResult.page;
            padding.page.Current = query.PageCurrent;
            return(padding);
        }
Esempio n. 3
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));
        }