/// <summary> /// 部门列表 /// 初始加载:获取用户名查询建筑列表,第一栋建筑对应的分类,第一个分类对应的所有部门 /// </summary> /// <param name="userName">用户名</param> /// <returns>包含建筑列表,能源按钮列表,部门列表</returns> public DepartmentEnergyAverageViewModel GetViewModelByUserName(string userName) { DateTime today = DateTime.Now; List <BuildViewModel> builds = context.GetBuildsByUserName(userName); string buildId; if (builds.Count > 0) { buildId = builds.First().BuildID; } else { buildId = ""; } List <EnergyItemDict> energys = context.GetEnergyItemDictByBuild(buildId); string energyCode; if (energys.Count > 0) { energyCode = energys.First().EnergyItemCode; } else { energyCode = ""; } List <TreeViewInfo> treeViewInfos = context.GetTreeViewInfoList(buildId, energyCode); List <TreeViewModel> treeViewModel = Util.GetTreeViewModel(treeViewInfos); //DepartmentEnergyAverageViewModel viewModel = new DepartmentEnergyAverageViewModel(); //viewModel.Builds = builds; //viewModel.Energys = energys; //viewModel.TreeView = treeViewModel; DepartmentEnergyAverageViewModel viewModel = GetViewModel(buildId, energyCode, "MM", DateTime.Now.ToString("yyyy-MM-dd")); viewModel.Builds = builds; viewModel.Energys = energys; return(viewModel); }
/// <summary> /// 部门 月份 单位面积能耗 /// 初始加载:获取用户名查询建筑列表,第一栋建筑对应的分类,第一个分类对应的所有部门 /// </summary> /// <param name="userName">用户名</param> /// <returns>包含建筑列表,能源按钮列表,部门单位面积能耗</returns> public DepartmentAreaAvgRankViewModel GetViewModelByUserName(string userName) { DateTime today = DateTime.Now; List <BuildViewModel> builds = context.GetBuildsByUserName(userName); string buildId; if (builds.Count > 0) { buildId = builds.First().BuildID; } else { buildId = ""; } List <EnergyItemDict> energys = context.GetEnergyItemDictByBuild(buildId); string energyCode; if (energys.Count > 0) { energyCode = energys.First().EnergyItemCode; } else { energyCode = ""; } List <EnergyAverage> averageData = new List <EnergyAverage>(); averageData = context.GetDeptMonthEnergyAverageList(buildId, energyCode, DateTime.Now.ToString("yyyy-MM-01"), DateTime.Now.ToString("yyyy-MM-dd")); DepartmentAreaAvgRankViewModel viewModel = new DepartmentAreaAvgRankViewModel(); viewModel.Builds = builds; viewModel.Energys = energys; viewModel.AverageData = averageData; return(viewModel); }