Exemplo n.º 1
0
        public static async Task <bool> HasMonthly(List <int> targets, int energy, int paramter, TimeUnits unit, DateTime start, DateTime finish)
        {
            var node = new StatisticalNode(targets, energy, new List <int> {
                paramter
            }, unit, start, finish, StatisticalModes.Building, StatisticalWay.Total, null, null);

            var dicBLL    = new DictionaryBLL();
            var meterBLL  = new MeterBLL();
            var parameter = dicBLL.Get(node.ParameterTypeId).Select(d => d.Id).ToList();

            // 获取关联的一级统计设备
            IEnumerable <int> meters = (await meterBLL.GetStatisticalObj(node)).SelectMany(x => x.Meters).Select(x => x.Id);

            // 统计能耗结果
            return(meterBLL.Count(x => meters.Contains(x.Id) && x.MeterMonthlyResults.Any(m => m.StartTime >= start)) > 0);
        }
Exemplo n.º 2
0
        //public static IEnumerable<GisBuildingData> ToGisList(IQueryable<Building> nodes)
        //{
        //    var start_month = DateTime.Parse(DateTime.Today.ToString("yyyy-MM-01"));
        //    var start_year = DateTime.Parse(DateTime.Today.ToString("yyyy-01-01"));
        //    var ids = nodes.Select(x => x.Id).ToList();
        //    var cids = nodes.SelectMany(x => x.Children).Select(x => x.Id).ToList();
        //    var arr = ids.Concat(cids).Distinct().ToList();
        //    var list = nodes.ToList().Select(node => new GisBuildingData()
        //    {
        //        Id = node.Id,
        //        Name = node.Name,
        //        BuildingCategoryName = node.BuildingCategoryDict.ChineseName,
        //        //Year = node.BuildingInfo.Year,
        //        //UpFloor = node.BuildingInfo.UpFloor,
        //        ManagerCount = node.ManagerCount,
        //        CustomerCount = node.CustomerCount,
        //        TotalArea = node.TotalArea,
        //        LivingArea = node.LivingArea,
        //        WorkingArea = node.WorkingArea,
        //        ReceptionArea = node.ReceptionArea,
        //        Year = node.Year,
        //        UpFloor = node.UpFloor,
        //        //Electric = GetTotal(new List<int>() { node.Id }, 90001, 60019, TimeUnits.Monthly, start_month, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //        //Water = GetTotal(new List<int>() { node.Id }, 90031, 60023, TimeUnits.Monthly, start_month, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //        //ElectricYear = GetTotal(new List<int>() { node.Id }, 90001, 60019, TimeUnits.Yearly, start_year, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //        //WaterYear = GetTotal(new List<int>() { node.Id }, 90031, 60023, TimeUnits.Yearly, start_year, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //        Icon = "",
        //        Children = node.Children.Select(c => new GisBuildingData()
        //        {
        //            Id = c.Id,
        //            Name = c.Name,
        //            BuildingCategoryName = node.BuildingCategoryDict.ChineseName,
        //            ManagerCount = node.ManagerCount,
        //            CustomerCount = node.CustomerCount,
        //            TotalArea = node.TotalArea,
        //            LivingArea = node.LivingArea,
        //            WorkingArea = node.WorkingArea,
        //            ReceptionArea = node.ReceptionArea,
        //            Year = node.Year,
        //            UpFloor = node.UpFloor,
        //            //Electric = GetTotal(new List<int>() { node.Id }, 90001, 60019, TimeUnits.Monthly, start_month, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //            //Water = GetTotal(new List<int>() { node.Id }, 90031, 60023, TimeUnits.Monthly, start_month, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //            //ElectricYear = GetTotal(new List<int>() { node.Id }, 90001, 60019, TimeUnits.Yearly, start_year, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //            //WaterYear = GetTotal(new List<int>() { node.Id }, 90031, 60023, TimeUnits.Yearly, start_year, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //            Icon = ""
        //        }).ToList(),
        //        Meters = node.Meters.Select(m => m.ToGisData(1)).ToList()
        //    });
        //    var water_month = GetTotal(arr, 90031, 60023, TimeUnits.Monthly, start_month, DateTime.Now);
        //    var elec_month = GetTotal(arr, 90031, 60023, TimeUnits.Monthly, start_month, DateTime.Now);
        //    var water_year = GetTotal(arr, 90031, 60023, TimeUnits.Yearly, start_year, DateTime.Now);
        //    var elec_year = GetTotal(arr, 90031, 60023, TimeUnits.Yearly, start_year, DateTime.Now);
        //    foreach (var item in list)
        //    {
        //        var elec_m = elec_month.FirstOrDefault(x => x.StatisticalId == item.Id);
        //        if (elec_m != null) item.Electric = elec_m.Result.Sum(x => x.Value);
        //        var water_m = water_month.FirstOrDefault(x => x.StatisticalId == item.Id);
        //        if (water_m != null) item.Water = water_m.Result.Sum(x => x.Value);
        //        var elec_y = elec_year.FirstOrDefault(x => x.StatisticalId == item.Id);
        //        if (elec_y != null) item.ElectricYear = elec_y.Result.Sum(x => x.Value);
        //        var water_y = water_year.FirstOrDefault(x => x.StatisticalId == item.Id);
        //        if (water_y != null) item.WaterYear = water_y.Result.Sum(x => x.Value);
        //    }
        //    return list;
        //}

        public static async Task <IEnumerable <StatisticalData> > GetTotal(List <int> targets, int energy, int paramter, TimeUnits unit, DateTime start, DateTime finish)
        {
            var node = new StatisticalNode(targets, energy, new List <int> {
                paramter
            }, unit, start, finish, StatisticalModes.Building, StatisticalWay.Total, null, null);

            var dicBLL   = new DictionaryBLL();
            var meterBLL = new MeterBLL();
            var statBLL  = new MeterResultBLL();
            // 获取参数对象
            var parameter = dicBLL.Get(node.ParameterTypeId).Select(d => d.Id).ToList();

            // 获取关联的一级统计设备
            IList <StatisticalTransfer> meters = await meterBLL.GetStatisticalObj(node);

            // 统计能耗结果
            var result = await statBLL.Statistics(meters, node.TimeUnit.Value, node.StartTime.Value, node.FinishTime.Value, parameter, node.StatWay.Value);

            return(result);
        }