示例#1
0
        /// <summary>
        /// 获取统计方式的说明信息
        /// </summary>
        /// <param name="way">统计方式</param>
        /// <returns></returns>
        private KeyValuePair <string, string> GetStatisticalWayInfo(StatisticalWay way)
        {
            KeyValuePair <string, string> result = new KeyValuePair <string, string>();

            switch (way)
            {
            case StatisticalWay.Total:
                result = new KeyValuePair <string, string>("总量合计", "∑(设备累计能耗×设备变比)");
                break;

            case StatisticalWay.PerCapita:
                result = new KeyValuePair <string, string>("人均", "∑((设备累计能耗×设备变比)÷机构或建筑的总人数)");
                break;

            case StatisticalWay.PerUnitArea:
                result = new KeyValuePair <string, string>("单位面积", "∑((设备累计能耗×设备变比)÷建筑或机构关联建筑的总面积)");
                break;

            default:
                goto case StatisticalWay.Total;
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// 统计能耗
        /// </summary>
        /// <param name="transfer">统计对象</param>
        /// <param name="timeUnit">时间单位</param>
        /// <param name="start">起始时间</param>
        /// <param name="finish">完成时间</param>
        /// <param name="parameterTypeId">统计参数</param>
        /// <param name="way">统计方式</param>
        /// <returns></returns>
        public async Task <List <StatisticalData> > Statistics(IList <StatisticalTransfer> transfer, TimeUnits timeUnit, DateTime start, DateTime finish, List <int> parameterTypeId, StatisticalWay way)
        {
            var modeInfo      = this.GetStatisticalWayInfo(way);
            var parameterType = SystemInfo.AllDictStatus.Where(x => parameterTypeId.Contains(x.Id));

            // 根据统计方式生成统计函数
            Func <StatisticalTransfer, TimeUnits, DateTime, DateTime, int, Task <List <EnergyData> > > StatisticalFunc = null;

            switch (way)
            {
            case StatisticalWay.Total:
                StatisticalFunc = this.SumFunc;
                break;

            case StatisticalWay.Avg:
                StatisticalFunc = this.AvgFunc;
                break;

            case StatisticalWay.PerCapita:
            case StatisticalWay.PerUnitArea:
                StatisticalFunc = this.PerFunc;
                break;

            default:
                goto case StatisticalWay.Total;
            }

            // 循环统计对象集合生成统计数据
            var result = new List <StatisticalData>();

            foreach (var item in transfer)
            {
                foreach (var pt in parameterType)
                {
                    var transferResult = await StatisticalFunc(item, timeUnit, start, finish, pt.Id);

                    if (transferResult != null && transferResult.Count > 0)
                    {
                        result.Add(new StatisticalData
                        {
                            StatisticalId           = item.StatisticalId,
                            StatisticalParentId     = item.StatisticalParentId,
                            StatisticalTreeId       = item.StatisticalTreeId,
                            StatisticalName         = item.StatisticalName,
                            StatisticalWay          = item.StatisticalWay,
                            EnergyCategoryId        = item.EnergyCategoryId,
                            StandardCoalCoefficient = DictionaryCache.Get()[item.EnergyCategoryId].EquValue,
                            EnergyCategoryName      = item.EnergyCategoryName,
                            FormulaParam1           = item.FormulaParam1,
                            WayName           = modeInfo.Key,
                            Formula           = modeInfo.Value,
                            ParameterTypeId   = pt.Id,
                            ParameterTypeName = pt.ChineseName,
                            Unit     = pt.EquText,
                            TimeUnit = timeUnit,
                            Result   = transferResult
                        });
                    }
                }
            }

            return(result);
        }