示例#1
0
        public static IList <MeterGroupData> ToViewList(this IQueryable <MeterGroup> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        {
            //GroupBLL groupBLL = new GroupBLL();
            MeterBLL    meterBLL    = new MeterBLL();
            BuildingBLL buildingBLL = new BuildingBLL();

            if (nodes == null)
            {
                return(null);
            }
            var nodeList = nodes.ToList();
            var results  = nodeList.Select(node => new MeterGroupData()
            {
                Id         = node.Id,
                GroupId    = node.GroupId,
                MeterId    = node.MeterId,
                BuildingId = node.BuildingId,
                Enable     = node.Enable,
                //Group = (suffix & CategoryDictionary.Group) == CategoryDictionary.Group ? (node.Group == null ? groupBLL.Find(node.GroupId).ToViewData() : node.Group.ToViewData()) : null,
                Meter    = (suffix & CategoryDictionary.Meter) == CategoryDictionary.Meter ? (node.Group == null ? meterBLL.Find(node.MeterId).ToViewData() : node.Meter.ToViewData()) : null,
                Building = (suffix & CategoryDictionary.Building) == CategoryDictionary.Building ? (node.Building == null ? buildingBLL.Find(node.BuildingId).ToViewData() : node.Building.ToViewData()) : null,
            }).ToList();

            return(results);
        }
示例#2
0
        public static IList <RatedParameterDetailData> ToViewList(this IQueryable <RatedParameterDetail> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        {
            BrandBLL brandBLL = new BrandBLL();
            MeterBLL meterBLL = new MeterBLL();
            UserBLL  userBLL  = new UserBLL();

            if (nodes == null)
            {
                return(null);
            }
            var nodeList = nodes.ToList();
            var results  = nodeList.Select(node => new RatedParameterDetailData()
            {
                Id = node.Id,
                RatedParameterId = node.RatedParameterId,
                BrandId          = node.BrandId,
                MeterId          = node.MeterId,
                SettingTime      = node.SettingTime,
                IsSuccess        = node.IsSuccess,
                OperatorId       = node.OperatorId,
                OperatorName     = node.OperatorName,
                Brand            = (suffix & CategoryDictionary.Brand) == CategoryDictionary.Brand ? (node.Brand == null ? brandBLL.Find(node.BrandId).ToViewData() : node.Brand.ToViewData()) : null,
                Meter            = (suffix & CategoryDictionary.Meter) == CategoryDictionary.Meter ? (node.Meter == null ? meterBLL.Find(node.MeterId).ToViewData() : node.Meter.ToViewData()) : null,
                Operator         = (suffix & CategoryDictionary.User) == CategoryDictionary.User ? node.OperatorId == null?null:(node.Operator == null ? userBLL.Find(node.OperatorId).ToViewData() : node.Operator.ToViewData()) : null,
            }).ToList();

            return(results);
        }
示例#3
0
        public static RatedParameterDetailData ToViewData(this RatedParameterDetail node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            BrandBLL brandBLL = new BrandBLL();
            MeterBLL meterBLL = new MeterBLL();
            UserBLL  userBLL  = new UserBLL();

            if (node == null)
            {
                return(null);
            }
            return(new RatedParameterDetailData()
            {
                Id = node.Id,
                RatedParameterId = node.RatedParameterId,
                BrandId = node.BrandId,
                MeterId = node.MeterId,
                SettingTime = node.SettingTime,
                IsSuccess = node.IsSuccess,
                OperatorId = node.OperatorId,
                OperatorName = node.OperatorName,
                Brand = (suffix & CategoryDictionary.Brand) == CategoryDictionary.Brand ? (node.Brand == null ? brandBLL.Find(node.BrandId).ToViewData() : node.Brand.ToViewData()) : null,
                Meter = (suffix & CategoryDictionary.Meter) == CategoryDictionary.Meter ? (node.Meter == null ? meterBLL.Find(node.MeterId).ToViewData() : node.Meter.ToViewData()) : null,
                Operator = (suffix & CategoryDictionary.User) == CategoryDictionary.User ? node.OperatorId == null ? null : (node.Operator == null ? userBLL.Find(node.OperatorId).ToViewData() : node.Operator.ToViewData()) : null,
            });
        }
示例#4
0
 public BalanceDetailBLL(EmpContext context = null)
     : base(context)
 {
     dictionaryBLL       = new DictionaryBLL(this.db);
     buildingBLL         = new BuildingBLL(this.db);
     organizationBLL     = new OrganizationBLL(this.db);
     monitoringConfigBLL = new MonitoringConfigBLL(this.db);
     meterBLL            = new MeterBLL(this.db);
     userBLL             = new UserBLL(this.db);
 }
示例#5
0
 public HistoryBillBLL(EmpContext context = null)
     : base(context)
 {
     dictionaryBLL   = new DictionaryBLL(this.db);
     buildingBLL     = new BuildingBLL(this.db);
     organizationBLL = new OrganizationBLL(this.db);
     //monitoringConfigBLL = new MonitoringConfigBLL(this.db);
     meterBLL   = new MeterBLL(this.db);
     userBLL    = new UserBLL(this.db);
     messageBLL = new MessageBLL(this.db);
 }
示例#6
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);
        }
示例#7
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);
        }
示例#8
0
        public static MetersActionData ToViewData(this MetersAction node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            if (node.Meter == null)
            {
                MeterBLL meterBLL = new MeterBLL();
                node.Meter = meterBLL.Find(node.MeterId);
            }
            return(new MetersActionData()
            {
                Id = node.Id,
                MeterId = node.MeterId,
                IsOk = node.IsOk,
                IsPowerOffByMoney = node.IsPowerOffByMoney,
                IsPowerOffByTime = node.IsPowerOffByTime,
                ActionId = node.ActionId,
                AddTime = node.AddTime,
                ActionTime = node.ActionTime,
                AnswerTIme = node.AnswerTIme,
                AnswerValue = node.AnswerValue,
                SendTimes = node.SendTimes,
                Priority = node.Priority,
                GroupNum = node.GroupNum,
                ParentId = node.ParentId,
                Description = node.Description,
                SettingValue = node.SettingValue,
                MeterName = node.Meter == null ? null : node.Meter.Name,  //Meter对象为空时报错(新增对象后,返回MetersAction对象时会出现,故加上判断Meter对象是否为空)
                MeterAddress = node.Meter == null ? null : node.Meter.Address,
                MeterMacAddress = node.Meter == null ? null : node.Meter.MacAddress,
                CommandStatus = node.Meter == null ? null : node.CommandStatus,
                InBuildingName = (node.Meter == null) ? null : (node.Meter.Building == null ? null : node.Meter.Building.Name),
                MeterTypeName = (node.Meter == null  ? null : node.Meter.TypeDict.ChineseName),
                CommandStatusName = (node.CommandStatusDic != null ? node.CommandStatusDic.ChineseName : null),
                //ActionName = (node.Action==null?null:node.Action.ChineseName)

                ActionName = (node.ActionId != DictionaryCache.ActionBalanceChange.Id ? DictionaryCache.Get()[node.ActionId].ChineseName : (node.SettingValue.StartsWith("-") ? "能耗消费(或扣费)" + node.SettingValue + "元" : "购电" + node.SettingValue + "元,")) + (node.Meter.Building != null ? node.Meter.Building.Name : ""),
            });
        }
示例#9
0
        public static MeterGroupData ToViewData(this MeterGroup node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            //GroupBLL groupBLL = new GroupBLL();
            MeterBLL    meterBLL    = new MeterBLL();
            BuildingBLL buildingBLL = new BuildingBLL();

            if (node == null)
            {
                return(null);
            }
            return(new MeterGroupData()
            {
                Id = node.Id,
                GroupId = node.GroupId,
                MeterId = node.MeterId,
                BuildingId = node.BuildingId,
                Enable = node.Enable,
                //Group = (suffix & CategoryDictionary.Group) == CategoryDictionary.Group ? (node.Group == null ? groupBLL.Find(node.GroupId).ToViewData() : node.Group.ToViewData()) : null,
                Meter = (suffix & CategoryDictionary.Meter) == CategoryDictionary.Meter ? (node.Meter == null ? meterBLL.Find(node.MeterId).ToViewData() : node.Meter.ToViewData()) : null,
                Building = (suffix & CategoryDictionary.Building) == CategoryDictionary.Building ? (node.Building == null ? buildingBLL.Find(node.BuildingId).ToViewData() : node.Building.ToViewData()) : null,
            });
        }
示例#10
0
 public ParametersController()
 {
     meterBLL = new MeterBLL(paramBLL.db, this.User.Identity.Name);
     brandBLL = new BrandBLL(paramBLL.db);
 }
示例#11
0
 public BrandsController()
 {
     meterBLL = new MeterBLL(brandBLL.db, this.User.Identity.Name);
     paramBLL = new ParameterBLL(brandBLL.db);
     dictBLL  = new DictionaryBLL(brandBLL.db);
 }