/// <summary> /// 功能:取得多个电站多个年度的年月发电量和比较数据 /// </summary> /// <param name="plantList"></param> /// <param name="years"></param> /// <param name="mt"></param> /// <param name="unit"></param> /// <param name="chartType"></param> /// <param name="rate"></param> /// <returns></returns> public ChartData PlantMMCompare(IList <Plant> plantList, IList <string> yearmms, string name, MonitorType mt, string unit, string chartType, float rate) { IList <PlantUnit> plantUnits = this.getUnitsByPlantList(plantList); ICollection <ICollection> keys = new List <ICollection>(); StringBuilder sb = new StringBuilder(); //foreach (string year in yearmms) //{ // sb.Append("," + year); //} string chartName = name + " " + LanguageUtil.getDesc("CHART_TITLE_COMPARE"); IList <KeyValuePair <string, float?[]> > datas = new List <KeyValuePair <string, float?[]> >(); string[] chartTypes = new string[1] { chartType }; string[] units = new string[1] { unit }; string[] ynames = new string[1] { "" }; string[] ic = null; bool hasData = false; //取得多个年度的发电月数据 int i = 0; foreach (string yearMM in yearmms) { Hashtable dataHash = null; string curName = yearMM; dataHash = CollectorMonthDayDataService.GetInstance().GetUnitBetweenMonthData(plantUnits, yearMM, yearMM); string[] tmpic = base.getXseriesFromYYYYMMDD(yearMM + "01", yearMM + CalenderUtil.getMonthDays(yearMM).ToString("00")).ToArray(); if (ic == null || tmpic.Length > ic.Length) { ic = tmpic; } //如果有多个设备进行编辑,没有数据的时候也显示 //if (dataHash.Count > 0) //{ KeyValuePair <string, float?[]> data = GenerateChartData(curName, ic, dataHash, rate); datas.Add(data); //} //如果有数据则将有数据标识为true if (dataHash.Count > 0) { hasData = true; } i++; } if (!hasData) {//如果所有设备都没数据才清空数据,即图表中显示无数据提示 datas.Clear(); } string[] xAxis = formatXaxis(ic, ChartTimeType.MonthDay); return(ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames, chartTypes, units, fromApp)); }
/// <summary> /// 获取当前采集器下指定时间发电量 /// </summary> /// <param name="cid">采集器编号</param> /// <param name="startyyyyMMdd">开始时间</param> /// <param name="endyyyyMMdd">结束时间</param> /// <returns></returns> public double GetEnergy(int cid, string startyyyyMMdd, string endyyyyMMdd) { //20111130 20111130 double returnValue = 0; DateTime startTime = DateTime.Parse(startyyyyMMdd); DateTime endTime = DateTime.Parse(endyyyyMMdd); IList <CollectorYearMonthData> cymds = new List <CollectorYearMonthData>(); int yyyy = startTime.Year; while (yyyy <= endTime.Year)//计算开始到结束时间的所在年发电量 { cymds.Add(CollectorYearMonthDataService.GetInstance().GetCollectorYearMonthData(cid, yyyy)); yyyy++; } //计算开始到结束时间内的所有发电量 foreach (CollectorYearMonthData cymd in cymds) { if (cymd.year.Equals(startTime.Year) && startTime.AddMonths(1) < endTime) { returnValue += cymd.count(startTime.Month + 1, 12); } else if (cymd.year.Equals(endTime.Year) && endTime.AddMonths(-1) > startTime) { returnValue += cymd.count(1, endTime.Month - 1); } else if (startTime.Year.Equals(endTime.Year) == false) { returnValue += cymd.count(); } } CollectorMonthDayData cmdd = null; //计算边缘月的发电量 if (!(startTime.Year.Equals(endTime.Year) && startTime.Month.Equals(endTime.Month))) { cmdd = CollectorMonthDayDataService.GetInstance().GetCollectorMonthDayData(startTime.Year, cid, startTime.Month); returnValue += cmdd.count(startTime.Day, 31); cmdd = CollectorMonthDayDataService.GetInstance().GetCollectorMonthDayData(startTime.Year, cid, endTime.Month); returnValue += cmdd.count(1, endTime.Day); } else { cmdd = CollectorMonthDayDataService.GetInstance().GetCollectorMonthDayData(startTime.Year, cid, endTime.Month); returnValue += cmdd.count(startTime.Day, endTime.Day); } return(returnValue); }
/// <summary> /// 作者:鄢睿 /// 功能:通过电站列表获得跨天度图表数据 /// 创建时间:2011年02月25日 /// 修改:胡圣忠 /// </summary> /// <param name="plantList"></param> /// <param name="rate"></param> /// <param name="chartname"></param> /// <param name="startYearMM"></param> /// <param name="endYearMM"></param> /// <returns></returns> public ChartData MonthDDChartBypList(IList <Plant> plantList, float rate, string chartname, string newseriekey, string startYearMMDD, string endYearMMDD, string chartType, string unit) { if (plantList == null) { return(new ChartData()); } ///所有子站累加 IList <PlantUnit> units = this.getUnitsByPlantList(plantList); Hashtable monthDDEnergy = CollectorMonthDayDataService.GetInstance().GetUnitBetweenMonthData(units, startYearMMDD, endYearMMDD); string[] ic = base.getXseriesFromYYYYMMDD(startYearMMDD, endYearMMDD).ToArray(); string[] xAxis; string[] years = getYearMonths(startYearMMDD, endYearMMDD); if (years.Length > 1) { //chartname = "from " + years[0] + " to " + years[1] + " " + chartname; xAxis = formatXaxis(ic, ChartTimeType.YearMonthDay); } else { //chartname = years[0] + " " + chartname; xAxis = formatXaxis(ic, ChartTimeType.MonthDay); } MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE); KeyValuePair <string, float?[]> data = new KeyValuePair <string, float?[]>(); if (monthDDEnergy.Count > 0) { if (newseriekey == null) { data = GenerateChartData(mt.name, ic, monthDDEnergy, rate); } else { data = GenerateChartData(newseriekey, ic, monthDDEnergy, rate); } } string comobj = "";//plantList.Count > 1 ? "" : plantList[0].name; return(ReportBuilder.createJsonChartXY(chartname, xAxis, data, "", unit, chartType, comobj, fromApp)); }
/// <summary> /// 取得多个电站的pr性能图表数据 /// </summary> /// <param name="plantList"></param> /// <param name="chartname"></param> /// <param name="newseriekey"></param> /// <param name="startYearMMDD"></param> /// <param name="endYearMMDD"></param> /// <param name="chartType"></param> /// <param name="unit"></param> /// <returns></returns> public ChartData MonthDDRPChartBypList(IList <Plant> plantList, string chartName, string startYearMMDD, string endYearMMDD, string chartType) { if (plantList == null) { return(new ChartData()); } MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE); IList <string> chartTypes = new List <string>(); //图表类型 IList <string> units = new List <string>(); //单位 IList <string> ynames = new List <string>(); //y轴名称 //IList<string> compareObjs = null;//图例比较对象,因为是同一个电站,不追加 chartTypes.Add(chartType); chartTypes.Add(chartType); ynames.Add(mt.name); ynames.Add(mt.name); ///所有单元累加 IList <PlantUnit> unitList = this.getUnitsByPlantList(plantList); //产生坐标 string[] ic = base.getXseriesFromYYYYMMDD(startYearMMDD, endYearMMDD).ToArray(); string[] xAxis; string[] years = getYearMonths(startYearMMDD, endYearMMDD); if (years.Length > 1) { xAxis = formatXaxis(ic, ChartTimeType.YearMonthDay); } else { xAxis = formatXaxis(ic, ChartTimeType.MonthDay); } float rate = 1.0F; string newseriekey; //取得多个采集器的实际发电量 Hashtable monthDDEnergy = CollectorMonthDayDataService.GetInstance().GetUnitBetweenMonthData(unitList, startYearMMDD, endYearMMDD); units.Add(mt.unit); IList <KeyValuePair <string, float?[]> > datas = new List <KeyValuePair <string, float?[]> >(); KeyValuePair <string, float?[]> data = new KeyValuePair <string, float?[]>(); if (monthDDEnergy.Count > 0) { newseriekey = LanguageUtil.getDesc("ACTUALENERGY"); data = GenerateChartData(newseriekey, ic, monthDDEnergy, rate); units.Add(mt.unit); //string comobj = "";//plantList.Count > 1 ? "" : plantList[0].name; datas.Add(data); //取得日照增量强度,并依次计算理论发电量 //取得有增量日照迁强度的环境监测仪设备 IList <Device> devices = getDevicesByPlantsWithSunshine(plantList); //计算理论发电量换算率 IList <float> rates = this.getDeviceRatesByPlantsWithSunshine(plantList); monthDDEnergy = DeviceMonthDayDataService.GetInstance().unionYearMMDDList(devices, startYearMMDD, endYearMMDD, rates); newseriekey = LanguageUtil.getDesc("THEORYENERGY"); data = GenerateChartData(newseriekey, ic, monthDDEnergy, rate); datas.Add(data); float?[] newDataArr = computeByType(xAxis.ToArray(), datas, ComputeType.Ratio); KeyValuePair <string, float?[]> newdata = new KeyValuePair <string, float?[]>("PR", newDataArr); datas.Add(newdata); chartTypes.Add(ChartType.line); units.Add("%"); ynames.Add("PR"); } return(ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames.ToArray(), chartTypes.ToArray(), units.ToArray(), fromApp)); }
/// <summary> /// 比较多个设备多测点的月天数据 /// </summary> /// <param name="chartName"></param> /// <param name="devices"></param> /// <param name="startYearMMDD"></param> /// <param name="endYearMMDD"></param> /// <returns></returns> public ChartData compareMMDDMultiDeviceMultiMonitor(string chartName, IList <DeviceStuct> devices, string startYearMMDD, string endYearMMDD, int computeType) { string reportData = string.Empty; //chartName = chartName + " from " + startYearMMDD + "to" + endYearMMDD; IList <KeyValuePair <string, float?[]> > datas = new List <KeyValuePair <string, float?[]> >(); string[] ic = base.getXseriesFromYYYYMMDD(startYearMMDD, endYearMMDD).ToArray(); string[] xAxis = formatXaxis(ic, ChartTimeType.MonthDay); string[] chartTypes = new string[devices.Count]; string[] units = new string[devices.Count]; string[] ynames = new string[devices.Count]; string[] compareObjs = new string[devices.Count]; DeviceStuct deviceStuct = null; bool hasData = false; for (int i = 0; i < devices.Count; i++) { ///所有子站累加 deviceStuct = devices[i]; int monitorCode = deviceStuct.monitorType.code; string deviceId = deviceStuct.deviceId; chartTypes[i] = deviceStuct.chartType; compareObjs[i] = deviceStuct.comareObj; ynames[i] = ""; units[i] = deviceStuct.unit; Hashtable dataHash = null; string startYearMM = startYearMMDD.Substring(0, 6); string endYearMM = endYearMMDD.Substring(0, 6); string curName = ""; if (deviceStuct.deviceType == ChartDeviceType.PLANT || deviceStuct.deviceType == ChartDeviceType.UNIT) { //电站 IList <PlantUnit> plantUnits = getUnitsBydeviceIDs(deviceId, deviceStuct.deviceType); curName = deviceStuct.name; dataHash = CollectorMonthDayDataService.GetInstance().GetUnitBetweenMonthData(plantUnits, startYearMM, endYearMM); } else { //设备 Device device = DeviceService.GetInstance().get(int.Parse(deviceId)); curName = deviceStuct.name; dataHash = DeviceMonthDayDataService.GetInstance().DeviceYearMMDDList(device, startYearMMDD, endYearMMDD); } //如果有多个设备进行编辑,没有数据的时候也显示 //if (dataHash.Count > 0) //{ KeyValuePair <string, float?[]> data = base.GenerateChartData(curName, ic, dataHash, deviceStuct.rate); datas.Add(data); //} //如果有数据则将有数据标识为true if (dataHash.Count > 0) { hasData = true; } } //如果所有设备都没数据才清空数据,即图表中显示无数据提示 if (!hasData) { datas.Clear(); } //如果有计算类型,就要追究相应计算维度 if (computeType != ComputeType.None && datas.Count > 0) { float?[] newDataArr = computeByType(xAxis.ToArray(), datas, computeType); KeyValuePair <string, float?[]> newdata = new KeyValuePair <string, float?[]>(LanguageUtil.getDesc("AVERAGE"), newDataArr); datas.Add(newdata); string[] newChartTypes = new string[chartTypes.Length + 1]; string[] newUnits = new string[units.Length + 1]; string[] newYnames = new string[ynames.Length + 1]; string[] newCompareObjs = new string[compareObjs.Length + 1]; string[] colors = new string[units.Length + 1]; ynames.CopyTo(newYnames, 0); newYnames[newYnames.Length - 1] = LanguageUtil.getDesc("AVERAGE"); units.CopyTo(newUnits, 0); newUnits[newUnits.Length - 1] = units[0]; chartTypes.CopyTo(newChartTypes, 0); newChartTypes[newChartTypes.Length - 1] = chartTypes[0]; newCompareObjs.CopyTo(newCompareObjs, 0); newCompareObjs[newCompareObjs.Length - 1] = ""; colors[colors.Length - 1] = "#EE0000"; return(ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, newYnames, newChartTypes, newUnits, newCompareObjs, colors, fromApp)); } else { return(ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames, chartTypes, units, compareObjs, fromApp)); } //return ReportBuilder.createMultiJsonChartXY(chartName, xAxis.ToArray(), datas, ynames, chartTypes, units, compareObjs); }
/// <summary> /// 单个电站数据项数据 /// </summary> /// <param name="plant">电站</param> /// <param name="dataItemCode">数据项代码</param> /// <param name="startTime">开始时间,日报表只取开始时间,周报表的时间格式为:yyyyMMdd-yyyyMMdd</param> /// <param name="endTime"></param> /// <returns>数据项为key</returns> private Hashtable getPlantItemData(Plant plant, int reportType, string startTime, string endTime) { Hashtable datahash = new Hashtable(); float co2Rate = ItemConfigService.GetInstance().getCO2Config(); switch (reportType) { //--------日报表数据 start-------------- case DataReportType.TODAY_REPORT_CODE: //日报表 //日发电量 float energy = CollectorMonthDayDataService.GetInstance().getDayData(plant.plantUnits, startTime); //add发电量 datahash.Add(DataItem.TODAY_ENERGY, StringUtil.formatDouble(energy, "0.00") + " " + MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).unit); //add日最大功率 和发生时间 int year = int.Parse(startTime.Substring(0, 4)); int month = int.Parse(startTime.Substring(4, 2)); int day = int.Parse(startTime.Substring(6, 2)); DeviceDataCount ddc = DeviceDataCountService.GetInstance().GetPlantMax(plant.id, MonitorType.PLANT_MONITORITEM_POWER_CODE, year, month, day); string res = LanguageUtil.getDesc("NODATA"); if (ddc != null) { res = ddc.maxTime + "(" + ddc.maxValue + " " + MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_POWER_CODE).unit + ")"; } datahash.Add(DataItem.TODAY_MAX_POWER, res); //今日CO2减排 double co2reduce = Plant.computeCO2Reduce(co2Rate, energy); datahash.Add(DataItem.TODAY_AVOIDED_CO2, StringUtil.formatDouble(co2reduce) + " " + Plant.computeReduceUnit(co2Rate * energy)); //日收入 datahash.Add(DataItem.TODAY_REVENUE, plant.currencies + " " + Currencies.format(plant.currencies, energy * plant.revenueRate)); //累计总发电量 datahash.Add(DataItem.TODAY_TOTAL_ENERGY, plant.DisplayTotalEnergy + " " + plant.TotalEnergyUnit); //累计总收入 datahash.Add(DataItem.TODAY_TOTAL_REVENUE, plant.currencies + " " + plant.DisplayRevenue); //累计CO2减排 datahash.Add(DataItem.TODAY_TOTAL_AVOIDED_CO2, StringUtil.formatDouble(plant.Reductiong) + " " + plant.ReductiongUnit); //投资收益 datahash.Add(DataItem.TODAY_RATE, Math.Round(energy / plant.design_power, 2) + " kWh/kWp"); return(datahash); //--------周报表数据-------------- case DataReportType.WEEK_REPORT_CODE: //周发电量 Hashtable w_dataHash = CollectorMonthDayDataService.GetInstance().GetUnitBetweenMonthData(plant.plantUnits, startTime, endTime); float w_energy = 0; foreach (Object o in w_dataHash.Values) { w_energy += StringUtil.stringtoFloat(o.ToString()); } datahash.Add(DataItem.WEEK_ENERGY, StringUtil.formatDouble(w_energy, "0.00") + " " + MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).unit); //周CO2减排 double co2reduce1 = Plant.computeCO2Reduce(co2Rate, w_energy); datahash.Add(DataItem.WEEK_AVOIDED_CO2, co2reduce1 + " " + Plant.computeReduceUnit(co2Rate * w_energy)); //周收益 datahash.Add(DataItem.WEEK_REVENUE, plant.currencies + " " + Currencies.format(plant.currencies, w_energy * plant.revenueRate)); //累计总发电量 datahash.Add(DataItem.WEEK_TOTAL_ENERGY, plant.DisplayTotalEnergy + " " + plant.TotalEnergyUnit); //累计总收入 datahash.Add(DataItem.WEEK_TOTAL_REVENUE, plant.currencies + " " + plant.DisplayRevenue); //累计CO2减排 datahash.Add(DataItem.WEEK_TOTAL_AVOIDED_CO2, StringUtil.formatDouble(plant.Reductiong) + " " + plant.ReductiongUnit); //投资收益 datahash.Add(DataItem.WEEK_RATE, Math.Round(w_energy / plant.design_power, 2) + " kWh/kWp"); return(datahash); //--------月报表------------ case DataReportType.MONTH_REPORT_CODE: Hashtable m_dataHash = CollectorMonthDayDataService.GetInstance().GetUnitBetweenMonthData(plant.plantUnits, startTime, endTime); float m_energy = 0; foreach (Object o in m_dataHash.Values) { m_energy += StringUtil.stringtoFloat(o.ToString()); } datahash.Add(DataItem.MONTH_ENERGY, StringUtil.formatDouble(m_energy, "0.00") + " " + MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).unit); //月CO2减排 double co2reduce_m = Plant.computeCO2Reduce(co2Rate, m_energy); datahash.Add(DataItem.MONTH_AVOIDED_CO2, StringUtil.formatDouble(co2reduce_m) + " " + Plant.computeReduceUnit(co2Rate * m_energy)); //月收益 datahash.Add(DataItem.MONTH_REVENUE, plant.currencies + " " + Currencies.format(plant.currencies, m_energy * plant.revenueRate)); //累计总发电量 datahash.Add(DataItem.MONTH_TOTAL_ENERGY, plant.DisplayTotalEnergy + " " + plant.TotalEnergyUnit); //累计总收入 datahash.Add(DataItem.MONTH_TOTAL_REVENUE, plant.currencies + " " + plant.DisplayRevenue); //累计CO2减排 datahash.Add(DataItem.MONTH_TOTAL_AVOIDED_CO2, StringUtil.formatDouble(plant.Reductiong) + " " + plant.ReductiongUnit); //投资收益 datahash.Add(DataItem.MONTH_RATE, Math.Round(m_energy / plant.design_power, 2) + " kWh/kWp"); return(datahash); //------年报表----------------- case DataReportType.YEAR_REPORT_CODE: int startYear = int.Parse(startTime.Substring(0, 4)); int endYear = int.Parse(endTime.Substring(0, 4)); Hashtable y_dataHash = CollectorYearMonthDataService.GetInstance().GetUnitBetweenYearData(plant.plantUnits, startYear, endYear); float y_energy = 0; foreach (Object o in y_dataHash.Values) { y_energy += StringUtil.stringtoFloat(o.ToString()); } datahash.Add(DataItem.YEAR_ENERGY, StringUtil.formatDouble(y_energy, "0.00") + " " + MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).unit); //年CO2减排 double co2reduce_y = Plant.computeCO2Reduce(co2Rate, y_energy); datahash.Add(DataItem.YEAR_AVOIDED_CO2, StringUtil.formatDouble(co2reduce_y) + " " + Plant.computeReduceUnit(co2Rate * y_energy)); //年收益 datahash.Add(DataItem.YEAR_REVENUE, plant.currencies + " " + Currencies.format(plant.currencies, y_energy * plant.revenueRate)); //累计总发电量 datahash.Add(DataItem.YEAR_TOTAL_ENERGY, plant.DisplayTotalEnergy + " " + plant.TotalEnergyUnit); //累计总收入 datahash.Add(DataItem.YEAR_TOTAL_REVENUE, plant.currencies + " " + plant.DisplayRevenue); //累计CO2减排 datahash.Add(DataItem.YEAR_TOTAL_AVOIDED_CO2, StringUtil.formatDouble(plant.Reductiong) + " " + plant.ReductiongUnit); //投资收益 datahash.Add(DataItem.YEAR_RATE, Math.Round(y_energy / plant.design_power, 2) + " kWh/kWp"); return(datahash); //------总量报表----------------- case DataReportType.TOTAL_REPORT_CODE: //累计总发电量 datahash.Add(DataItem.TOTAL_ENERGY, plant.DisplayTotalEnergy + " " + plant.TotalEnergyUnit); //累计总收入 datahash.Add(DataItem.TOTAL_REVENUE, plant.currencies + " " + plant.DisplayRevenue); //累计CO2减排 datahash.Add(DataItem.TOTAL_AVOIDED_CO2, StringUtil.formatDouble(plant.Reductiong) + " " + plant.ReductiongUnit); //投资收益 datahash.Add(DataItem.TOTAL_RATE, Math.Round(plant.TotalEnergy / plant.design_power, 2) + " kWh/kWp"); return(datahash); default: return(datahash); } }
/// <summary> /// 单个用户数据项数据 /// </summary> /// <param name="plant">电站</param> /// <param name="dataItemCode">数据项代码</param> /// <param name="startTime">开始时间,日报表只取开始时间,周报表的时间格式为:yyyyMMdd-yyyyMMdd</param> /// <param name="endTime"></param> /// <returns>数据项为key</returns> private Hashtable getUserItemData(User user, int reportType, string startTime, string endTime) { Hashtable datahash = new Hashtable(); double co2Rate = ItemConfigService.GetInstance().getCO2Config(); switch (reportType) { //--------日报表数据 start-------------- case DataReportType.TODAY_REPORT_CODE: //日报表 //日发电量 float energy = CollectorMonthDayDataService.GetInstance().getDayData(user.plantUnits(), startTime); //add发电量 datahash.Add(DataItem.TODAY_ENERGY, StringUtil.formatFloat(energy) + " " + MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).unit); //今日CO2减排 double co2reduce = Plant.computeCO2Reduce(co2Rate, energy); datahash.Add(DataItem.TODAY_AVOIDED_CO2, StringUtil.formatDouble(co2reduce) + " " + Plant.computeReduceUnit(co2Rate * energy)); //日收入 datahash.Add(DataItem.TODAY_REVENUE, user.currencies + " " + Currencies.format(user.currencies, energy * user.revenueRate)); //累计总发电量 datahash.Add(DataItem.TODAY_TOTAL_ENERGY, user.DisplayTotalEnergy + " " + user.TotalEnergyUnit); //累计总收入 datahash.Add(DataItem.TODAY_TOTAL_REVENUE, user.currencies + " " + user.DisplayRevenue); //累计CO2减排 datahash.Add(DataItem.TODAY_TOTAL_AVOIDED_CO2, StringUtil.formatDouble(user.TotalReductiong) + " " + user.TotalReductiongUnit); return(datahash); //--------周报表数据-------------- case DataReportType.WEEK_REPORT_CODE: //周发电量 float w_energy = 0; double w_revenue = 0; foreach (Plant plant in user.plants) { Hashtable w_dataHash = CollectorMonthDayDataService.GetInstance().GetUnitBetweenMonthData(plant.plantUnits, startTime, endTime); float tmpenergy = 0; foreach (Object o in w_dataHash.Values) { tmpenergy += StringUtil.stringtoFloat(o.ToString()); } w_energy += tmpenergy; w_revenue += tmpenergy * plant.revenueRate; } datahash.Add(DataItem.WEEK_ENERGY, StringUtil.formatDouble(w_energy) + " " + MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).unit); //周CO2减排 double co2reduce1 = Plant.computeCO2Reduce(co2Rate, w_energy); datahash.Add(DataItem.WEEK_AVOIDED_CO2, StringUtil.formatDouble(co2reduce1) + " " + Plant.computeReduceUnit(co2Rate * w_energy)); //周收益 datahash.Add(DataItem.WEEK_REVENUE, user.currencies + " " + Currencies.format(user.currencies, w_revenue)); //累计总发电量 datahash.Add(DataItem.WEEK_TOTAL_ENERGY, user.DisplayTotalEnergy + " " + user.TotalEnergyUnit); //累计总收入 datahash.Add(DataItem.WEEK_TOTAL_REVENUE, user.currencies + " " + user.DisplayRevenue); //累计CO2减排 datahash.Add(DataItem.WEEK_TOTAL_AVOIDED_CO2, StringUtil.formatDouble(user.TotalReductiong) + " " + user.TotalReductiongUnit); return(datahash); //--------月报表------------ case DataReportType.MONTH_REPORT_CODE: float m_energy = 0; double m_revenue = 0; foreach (Plant plant in user.plants) { Hashtable m_dataHash = CollectorMonthDayDataService.GetInstance().GetUnitBetweenMonthData(plant.plantUnits, startTime, endTime); float tmpenergy = 0; foreach (Object o in m_dataHash.Values) { tmpenergy += StringUtil.stringtoFloat(o.ToString()); } m_energy += tmpenergy; m_revenue += tmpenergy * plant.revenueRate; } datahash.Add(DataItem.MONTH_ENERGY, StringUtil.formatDouble(m_energy) + " " + MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).unit); //月CO2减排 double co2reduce_m = Plant.computeCO2Reduce(co2Rate, m_energy); datahash.Add(DataItem.MONTH_AVOIDED_CO2, StringUtil.formatDouble(co2reduce_m) + " " + Plant.computeReduceUnit(co2Rate * m_energy)); //月收益 datahash.Add(DataItem.MONTH_REVENUE, user.currencies + " " + Currencies.format(user.currencies, m_revenue)); //累计总发电量 datahash.Add(DataItem.MONTH_TOTAL_ENERGY, user.DisplayTotalEnergy + " " + user.TotalEnergyUnit); //累计总收入 datahash.Add(DataItem.MONTH_TOTAL_REVENUE, user.currencies + " " + user.DisplayRevenue); //累计CO2减排 datahash.Add(DataItem.MONTH_TOTAL_AVOIDED_CO2, StringUtil.formatDouble(user.TotalReductiong) + " " + user.TotalReductiongUnit); return(datahash); //------年报表----------------- case DataReportType.YEAR_REPORT_CODE: int startYear = int.Parse(startTime.Substring(0, 4)); int endYear = int.Parse(endTime.Substring(0, 4)); float y_energy = 0; double y_revenue = 0; foreach (Plant plant in user.plants) { Hashtable y_dataHash = CollectorYearMonthDataService.GetInstance().GetUnitBetweenYearData(user.plantUnits(), startYear, endYear); float tmpenergy = 0; foreach (Object o in y_dataHash.Values) { tmpenergy += StringUtil.stringtoFloat(o.ToString()); } y_energy += tmpenergy; y_revenue += tmpenergy * plant.revenueRate; } datahash.Add(DataItem.YEAR_ENERGY, StringUtil.formatDouble(y_energy) + " " + MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).unit); //年CO2减排 double co2reduce_y = Plant.computeCO2Reduce(co2Rate, y_energy); datahash.Add(DataItem.YEAR_AVOIDED_CO2, StringUtil.formatDouble(co2reduce_y) + " " + Plant.computeReduceUnit(co2Rate * y_energy)); //年收益 datahash.Add(DataItem.YEAR_REVENUE, user.currencies + " " + Currencies.format(user.currencies, y_revenue)); //累计总发电量 datahash.Add(DataItem.YEAR_TOTAL_ENERGY, user.DisplayTotalEnergy + " " + user.TotalEnergyUnit); //累计总收入 datahash.Add(DataItem.YEAR_TOTAL_REVENUE, user.currencies + " " + user.DisplayRevenue); //累计CO2减排 datahash.Add(DataItem.YEAR_TOTAL_AVOIDED_CO2, StringUtil.formatDouble(user.TotalReductiong) + " " + user.TotalReductiongUnit); return(datahash); //------总量报表----------------- case DataReportType.TOTAL_REPORT_CODE: //累计总发电量 datahash.Add(DataItem.TOTAL_ENERGY, user.DisplayTotalEnergy + " " + user.TotalEnergyUnit); //累计总收入 datahash.Add(DataItem.TOTAL_REVENUE, user.currencies + " " + user.DisplayRevenue); //累计CO2减排 datahash.Add(DataItem.TOTAL_AVOIDED_CO2, StringUtil.formatDouble(user.TotalReductiong) + " " + user.TotalReductiongUnit); return(datahash); default: return(datahash); } }