/// <summary> /// 设备的年月统计图表 /// </summary> /// <param name="device"></param> /// <param name="rate"></param> /// <param name="chartname"></param> /// <param name="startYearMM"></param> /// <param name="endYearMM"></param> /// <param name="chartType"></param> /// <param name="unit"></param> /// <returns></returns> public ChartData YearMMChartByDevice(Device device, float rate, string chartname, string startYearMM, string endYearMM, string chartType, string unit) { if (device == null) { return(new ChartData()); } string name = LanguageUtil.getDesc("CHART_TITLE_YEAR_ENERGY"); int startYear = int.Parse(startYearMM.Substring(0, 4)); int endYear = int.Parse(endYearMM.Substring(0, 4)); Hashtable yearMonthEnergy = DeviceYearMonthDataService.GetInstance().GetDeviceBetweenYearData(device, startYear, endYear); string[] ic = base.getXseriesFromYYYYMM(startYearMM, endYearMM).ToArray(); string[] xAxis = formatXaxis(ic, ChartTimeType.YearMonth); string yname = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).name; KeyValuePair <string, float?[]> data = new KeyValuePair <string, float?[]>(); if (yearMonthEnergy.Count > 0) { data = GenerateChartData(yname, ic, yearMonthEnergy, rate); } return(ReportBuilder.createJsonChartXY(name, xAxis, data, "", unit, chartType, fromApp)); }
public static DeviceYearMonthDataService GetInstance() { if (_instance == null) { _instance = new DeviceYearMonthDataService(); } return(_instance); }
public static DeviceYearMonthDataService GetInstance() { if (_instance == null) { _instance = new DeviceYearMonthDataService(); } return _instance; }
/// <summary> /// 作者:鄢睿 /// 功能:取得设备多个年度的年月发电量比较数据 /// 创建时间:2011年02月25日 /// </summary> /// <param name="device"></param> /// <param name="years"></param> /// <param name="mt"></param> /// <param name="unit"></param> /// <param name="chartType"></param> /// <returns></returns> public ChartData DeviceYearCompare(Device device, IList <int> years, string name, MonitorType mt, string unit, string chartType, float rate) { ICollection <ICollection> keys = new List <ICollection>(); StringBuilder sb = new StringBuilder(); // //foreach (int year in years) //{ // 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 }; IList <string> units = new List <string>(); IList <string> ynames = new List <string>(); string[] ic = null; bool hasData = false; //取得多个年度的发电月数据 int i = 0; foreach (int year in years) { units.Add(unit); ynames.Add(""); Hashtable dataHash = null; string curName = year.ToString(); dataHash = DeviceYearMonthDataService.GetInstance().GetDeviceBetweenYearData(device, year, year); ic = base.getMMX(year.ToString()); //如果有多个设备进行编辑,没有数据的时候也显示 //if (dataHash.Count > 0) //{ KeyValuePair <string, float?[]> data = GenerateChartData(year.ToString(), ic, dataHash, rate); datas.Add(data); //} //如果有数据则将有数据标识为true if (dataHash.Count > 0) { hasData = true; } i++; } if (!hasData) {//如果所有设备都没数据才清空数据,即图表中显示无数据提示 datas.Clear(); } ic = base.getMMX(""); string[] xAxis = formatXaxis(ic, ChartTimeType.Month); return(ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames.ToArray(), chartTypes, units.ToArray(), fromApp)); }
public double GetEnergy(int did, string startyyyyMMdd, string endyyyyMMdd) { //20111130 20111130 double returnValue = 0; DateTime startTime = DateTime.Parse(startyyyyMMdd); DateTime endTime = DateTime.Parse(endyyyyMMdd); IList <DeviceYearMonthData> dymds = new List <DeviceYearMonthData>(); int yyyy = startTime.Year; while (yyyy <= endTime.Year)//计算开始到结束时间的所在年发电量 { dymds.Add(DeviceYearMonthDataService.GetInstance().GetDeviceYearMonthData(did, yyyy)); yyyy++; } //计算开始到结束时间内的所有发电量 foreach (DeviceYearMonthData dymd in dymds) { if (dymd.year.Equals(startTime.Year) && startTime.AddMonths(1) < endTime) { returnValue += dymd.count(startTime.Month + 1, 12); } else if (dymd.year.Equals(endTime.Year) && endTime.AddMonths(-1) > startTime) { returnValue += dymd.count(1, endTime.Month - 1); } else if (startTime.Year.Equals(endTime.Year) == false) { returnValue += dymd.count(); } } DeviceMonthDayData dmdd = null; //计算边缘月的发电量 if (!(startTime.Year.Equals(endTime.Year) && startTime.Month.Equals(endTime.Month))) { dmdd = DeviceMonthDayDataService.GetInstance().GetDeviceMonthDayData(startTime.Year, did, startTime.Month); returnValue += dmdd.count(startTime.Day, 31); dmdd = DeviceMonthDayDataService.GetInstance().GetDeviceMonthDayData(startTime.Year, did, endTime.Month); returnValue += dmdd.count(1, endTime.Day); } else { dmdd = DeviceMonthDayDataService.GetInstance().GetDeviceMonthDayData(startTime.Year, did, endTime.Month); returnValue += dmdd.count(startTime.Day, endTime.Day); } return(returnValue); }
/// <summary> /// 取得电站的某月的性能 /// </summary> /// <param name="plant"></param> /// <param name="year"></param> /// <param name="month"></param> /// <param name="monthEnergy"></param> /// <returns>已经转化为百分率了</returns> public double getMonthPr(Plant plant, int year, int month, double monthEnergy) { Device device = plant.getDetectorWithRenderSunshine(); if (device == null) { return(0); } DeviceYearMonthData deviceYearmonth = DeviceYearMonthDataService.GetInstance().GetDeviceYearMonthData(device.id, year); float monthsunlingt = deviceYearmonth.getMonthData(month); if (monthsunlingt == 0) { return(0); } float dp = plant.design_power == 0 ? 1 : plant.design_power; return(monthEnergy / monthsunlingt * 1000 * dp); }
/// <summary> /// 电站年月pr性能 /// </summary> /// <param name="plantList"></param> /// <param name="chartName"></param> /// <param name="startYearMM"></param> /// <param name="endYearMM"></param> /// <param name="chartType"></param> /// <returns></returns> public ChartData yearMonthRPChartBypList(IList <Plant> plantList, string chartName, string startYearMM, string endYearMM, 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); //产生坐标 int startYear = int.Parse(startYearMM.Substring(0, 4)); int endYear = int.Parse(endYearMM.Substring(0, 4)); string[] ic = base.getXseriesFromYYYYMM(startYearMM, endYearMM).ToArray(); string[] xAxis = formatXaxis(ic, ChartTimeType.YearMonth); float rate = 1.0F; string newseriekey; //取得多个采集器的实际发电量 Hashtable yearMonthEnergy = CollectorYearMonthDataService.GetInstance().GetUnitBetweenYearData(unitList, startYear, endYear); units.Add(mt.unit); units.Add(mt.unit); IList <KeyValuePair <string, float?[]> > datas = new List <KeyValuePair <string, float?[]> >(); KeyValuePair <string, float?[]> data = new KeyValuePair <string, float?[]>(); if (yearMonthEnergy.Count > 0) { newseriekey = LanguageUtil.getDesc("ACTUALENERGY"); data = GenerateChartData(newseriekey, ic, yearMonthEnergy, rate); //string comobj = "";//plantList.Count > 1 ? "" : plantList[0].name; datas.Add(data); //取得日照增量强度,并依次计算理论发电量 //取得有增量日照迁强度的环境监测仪设备 IList <Device> devices = getDevicesByPlantsWithSunshine(plantList); //计算理论发电量换算率 IList <float> rates = this.getDeviceRatesByPlantsWithSunshine(plantList); yearMonthEnergy = DeviceYearMonthDataService.GetInstance().GetDeviceBetweenYearData(devices, startYear, endYear, rates); newseriekey = LanguageUtil.getDesc("THEORYENERGY"); data = GenerateChartData(newseriekey, ic, yearMonthEnergy, 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="startYearMM"></param> /// <param name="endYearMM"></param> /// <returns></returns> public ChartData compareYearMMMultiDeviceMultiMonitor(string chartName, IList <DeviceStuct> devices, string startYearMM, string endYearMM, int computeType) { string reportData = string.Empty; //chartName = chartName + " from " + startYearMM + "to" + endYearMM; IList <KeyValuePair <string, float?[]> > datas = new List <KeyValuePair <string, float?[]> >(); string[] chartTypes = new string[devices.Count]; string[] units = new string[devices.Count]; string[] ic = base.getXseriesFromYYYYMM(startYearMM, endYearMM).ToArray(); string[] xAxis = formatXaxis(ic, ChartTimeType.YearMonth); 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; units[i] = deviceStuct.unit; ynames[i] = ""; Hashtable dataHash = null; int startYear = int.Parse(startYearMM.Substring(0, 4)); int endYear = int.Parse(endYearMM.Substring(0, 4)); string curName = ""; if (deviceStuct.deviceType == ChartDeviceType.PLANT || deviceStuct.deviceType == ChartDeviceType.UNIT) { //电站 IList <PlantUnit> plantUnits = getUnitsBydeviceIDs(deviceId, deviceStuct.deviceType); curName = deviceStuct.name; dataHash = CollectorYearMonthDataService.GetInstance().GetUnitBetweenYearData(plantUnits, startYear, endYear); } else { //设备 Device device = DeviceService.GetInstance().get(int.Parse(deviceId)); curName = deviceStuct.name; dataHash = DeviceYearMonthDataService.GetInstance().GetDeviceBetweenYearData(device, startYear, endYear); } //如果有多个设备进行编辑,没有数据的时候也显示 //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 && hasData) { 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="reportType">报表类型</param> /// <param name="datetime"></param> /// <returns></returns> private Hashtable getPlantDeviceData(Plant plant, int reportType, IList <int> itemCodes, string startTime, string endTime) { Hashtable dataHash = new Hashtable(); switch (reportType) { case DataReportType.TODAY_REPORT_CODE: //日报表 IList <string[]> deviceDataList = null; foreach (int dataItemCode in itemCodes) { int intervalMins = 60; deviceDataList = new List <string[]>(); if (startTime.Length < 8) { continue; } ; //首先取得头部标题,即横坐标 string[] ic = DeviceChartService.GetInstance().getXseriesFromYYYYMMDDHH(startTime, endTime, intervalMins).ToArray(); string[] xAxis = DeviceChartService.GetInstance().formatXaxis(ic, ChartTimeType.Hour); string[] newxAxis = new string[xAxis.Length + 3]; xAxis.CopyTo(newxAxis, 2); //最前面添加一个空元素 newxAxis[0] = LanguageUtil.getDesc("REPORT_COUNT_ITEM"); newxAxis[1] = LanguageUtil.getDesc("REPORT_COUNT_DEVICE"); newxAxis[newxAxis.Length - 1] = LanguageUtil.getDesc("REPORT_COUNT_TODAYSUN"); deviceDataList.Add(newxAxis); int monitorCode = dataItemCode; //按照设备数据项和设备测点代码定义规则一致,这里的数据code就是测点code string[] tmpDataArr = new string[newxAxis.Length]; //取得电站所有设备 foreach (Device device in plant.displayDevices()) { if (device.deviceTypeCode != DeviceData.INVERTER_CODE) { continue; //只统计逆变器的 } tmpDataArr = new string[newxAxis.Length]; tmpDataArr[1] = device.fullName; //取得原始数据 Hashtable powerHash = DeviceDayDataService.GetInstance().GetDaydataList(device, startTime, endTime, intervalMins, monitorCode); if (powerHash.Count > 0) { //加工数据 bool isCount = false; if (dataItemCode == MonitorType.MIC_INVERTER_TODAYENERGY) { isCount = true; } HandleData(powerHash, ic, tmpDataArr, isCount); } deviceDataList.Add(tmpDataArr); } dataHash.Add(dataItemCode, deviceDataList); } return(dataHash); case DataReportType.WEEK_REPORT_CODE: //周报表 //取得设备发电量列表数据 deviceDataList = new List <string[]>(); //首先取得头部标题,即横坐标 string[] wic = DeviceChartService.GetInstance().getXseriesFromYYYYMMDD(startTime, endTime).ToArray(); string[] wxAxis = DeviceChartService.GetInstance().formatXaxis(wic, ChartTimeType.Week); string[] newWxAxis = new string[wxAxis.Length + 3]; wxAxis.CopyTo(newWxAxis, 2); //最前面添加一个空元素 newWxAxis[0] = LanguageUtil.getDesc("REPORT_COUNT_ITEM"); newWxAxis[1] = LanguageUtil.getDesc("REPORT_COUNT_DEVICE"); newWxAxis[newWxAxis.Length - 1] = LanguageUtil.getDesc("REPORT_COUNT_TODAYSUN"); deviceDataList.Add(newWxAxis); string[] tmpWDataArr = new string[newWxAxis.Length]; //取得电站所有设备 foreach (Device device in plant.displayDevices()) { if (device.deviceTypeCode != DeviceData.INVERTER_CODE) { continue; //只统计逆变器的 } tmpWDataArr = new string[newWxAxis.Length]; tmpWDataArr[1] = device.fullName; //取得原始数据 Hashtable powerHash = DeviceMonthDayDataService.GetInstance().DeviceYearMMDDList(device, startTime, endTime); if (powerHash.Count > 0) { //加工数据 HandleData(powerHash, wic, tmpWDataArr, true); } deviceDataList.Add(tmpWDataArr); } dataHash.Add(DataItem.WEEK_DEVICE_ENERGY, deviceDataList); return(dataHash); case DataReportType.MONTH_REPORT_CODE: //月报表 //取得设备发电量列表数据 deviceDataList = new List <string[]>(); //首先取得头部标题,即横坐标 string[] mic = DeviceChartService.GetInstance().getXseriesFromYYYYMMDD(startTime, endTime).ToArray(); string[] mxAxis = DeviceChartService.GetInstance().formatXaxis(mic, ChartTimeType.MonthDay); string[] newMxAxis = new string[mxAxis.Length + 3]; mxAxis.CopyTo(newMxAxis, 2); //最前面添加一个空元素 newMxAxis[0] = LanguageUtil.getDesc("REPORT_COUNT_ITEM"); newMxAxis[1] = LanguageUtil.getDesc("REPORT_COUNT_DEVICE"); newMxAxis[newMxAxis.Length - 1] = LanguageUtil.getDesc("REPORT_COUNT_TODAYSUN"); deviceDataList.Add(newMxAxis); string[] tmpMDataArr = new string[newMxAxis.Length]; //取得电站所有设备 foreach (Device device in plant.displayDevices()) { if (device.deviceTypeCode != DeviceData.INVERTER_CODE) { continue; //只统计逆变器的 } tmpMDataArr = new string[newMxAxis.Length]; tmpMDataArr[1] = device.fullName; //取得原始数据 Hashtable powerHash = DeviceMonthDayDataService.GetInstance().DeviceYearMMDDList(device, startTime, endTime); if (powerHash.Count > 0) { //加工数据 HandleData(powerHash, mic, tmpMDataArr, true); } deviceDataList.Add(tmpMDataArr); } dataHash.Add(DataItem.MONTH_DEVICE_ENERGY, deviceDataList); return(dataHash); case DataReportType.YEAR_REPORT_CODE: //年报表 //取得设备发电量列表数据 deviceDataList = new List <string[]>(); //首先取得头部标题,即横坐标 string[] yic = DeviceChartService.GetInstance().getXseriesFromYYYYMM(startTime, endTime).ToArray(); string[] yxAxis = DeviceChartService.GetInstance().formatXaxis(yic, ChartTimeType.YearMonth); string[] newYxAxis = new string[yxAxis.Length + 3]; yxAxis.CopyTo(newYxAxis, 2); //最前面添加一个空元素 newYxAxis[0] = LanguageUtil.getDesc("REPORT_COUNT_ITEM"); newYxAxis[1] = LanguageUtil.getDesc("REPORT_COUNT_DEVICE"); newYxAxis[newYxAxis.Length - 1] = LanguageUtil.getDesc("REPORT_COUNT_TODAYSUN"); deviceDataList.Add(newYxAxis); string[] tmpYDataArr = new string[newYxAxis.Length]; //取得电站所有设备 foreach (Device device in plant.displayDevices()) { if (device.deviceTypeCode != DeviceData.INVERTER_CODE) { continue; //只统计逆变器的 } tmpYDataArr = new string[newYxAxis.Length]; tmpYDataArr[1] = device.fullName; //取得原始数据 Hashtable powerHash = DeviceYearMonthDataService.GetInstance().GetDeviceBetweenYearData(device, int.Parse(startTime.Substring(0, 4)), int.Parse(endTime.Substring(0, 4))); if (powerHash.Count > 0) { //加工数据 HandleData(powerHash, yic, tmpYDataArr, true); } deviceDataList.Add(tmpYDataArr); } dataHash.Add(DataItem.YEAR_DEVICE_ENERGY, deviceDataList); return(dataHash); case DataReportType.TOTAL_REPORT_CODE: //总量报表 //取得设备发电量列表数据 deviceDataList = new List <string[]>(); //首先取得头部标题,即横坐标 IList <string> icList = new List <string>(); for (int mm = int.Parse(startTime); mm <= int.Parse(endTime); mm++) { icList.Add(mm.ToString()); } string[] tic = icList.ToArray(); string[] txAxis = DeviceChartService.GetInstance().formatXaxis(tic, ChartTimeType.Year); string[] newTxAxis = new string[txAxis.Length + 3]; txAxis.CopyTo(newTxAxis, 2); //最前面添加一个空元素 newTxAxis[0] = LanguageUtil.getDesc("REPORT_COUNT_ITEM"); newTxAxis[1] = LanguageUtil.getDesc("REPORT_COUNT_DEVICE"); newTxAxis[newTxAxis.Length - 1] = LanguageUtil.getDesc("REPORT_COUNT_TODAYSUN"); deviceDataList.Add(newTxAxis); string[] tmpTDataArr = new string[newTxAxis.Length]; //取得电站所有设备 foreach (Device device in plant.displayDevices()) { if (device.deviceTypeCode != DeviceData.INVERTER_CODE) { continue; //只统计逆变器的 } tmpTDataArr = new string[newTxAxis.Length]; tmpTDataArr[1] = device.fullName; //取得原始数据 Hashtable powerHash = DeviceYearDataService.GetInstance().GetTotalDatasByDevice(device); if (powerHash.Count > 0) { //加工数据 HandleData(powerHash, tic, tmpTDataArr, true); } deviceDataList.Add(tmpTDataArr); } dataHash.Add(DataItem.TOTAL_DEVICE_ENERGY, deviceDataList); return(dataHash); default: return(dataHash); } }