/// <summary> /// 作者:鄢睿 /// 功能:通过电站列表获得电站总量图表数据 /// 创建时间:2011年02月25日 /// 修改:胡圣忠 /// </summary> /// <param name="plantList">电站列表</param> /// <param name="rate">数据换算系数</param> /// <returns></returns> public ChartData YearChartBypList(IList <Plant> plantList, float rate, string chartname, string newserieKey, string chartType, string unit) { if (plantList == null) { return(new ChartData()); } //所有子站累加 Hashtable yearEnergy = CollectorYearDataService.GetInstance().GetYearDatasByUnits(this.getUnitsByPlantList(plantList)); string[] ic = sortCollection(yearEnergy.Keys); string[] newic = null; int len = 5; int skip = len - ic.Length; int left = (int)skip / 2; int right = 5 - ic.Length - left; if (ic.Length < len) { newic = new string[len]; len = 0; int startYear = ic.Length == 0 ? DateTime.Now.Year : int.Parse(ic[0]); int endYear = ic.Length == 0 ? DateTime.Now.Year : int.Parse(ic[ic.Length - 1]); while (left > 0) { newic[len++] = (startYear - (left--)).ToString(); } foreach (string s in ic) { newic[len++] = s; } for (int i = 1; i <= right; i++) { newic[len++] = (endYear + (i)).ToString(); } } else { newic = ic; } string[] xAxis = formatXaxis(newic, ChartTimeType.Year); MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE); KeyValuePair <string, float?[]> data = new KeyValuePair <string, float?[]>(); if (yearEnergy.Count > 0) { if (newserieKey == null) { data = GenerateChartData(mt.name, newic, yearEnergy, rate); } else { data = GenerateChartData(newserieKey, newic, yearEnergy, rate); } } string comobj = "";//plantList.Count > 1 ? "" : plantList[0].name; return(ReportBuilder.createJsonChartXY(chartname, xAxis, data, "", unit, chartType, comobj, fromApp)); }
/// <summary> /// 比较多个设备的年度数据 /// </summary> /// <param name="chartName"></param> /// <param name="devices"></param> /// <param name="years"></param> /// <returns></returns> public ChartData compareYearsMultiDeviceMultiMonitor(string chartName, IList <DeviceStuct> devices, IList <string> years) { string reportData = string.Empty; //chartName = chartName+" from "+years[0]+" to "+years[years.Count-1]; IList <KeyValuePair <string, float?[]> > datas = new List <KeyValuePair <string, float?[]> >(); 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 curName = ""; if (deviceStuct.deviceType == ChartDeviceType.PLANT || deviceStuct.deviceType == ChartDeviceType.UNIT) { //电站 IList <PlantUnit> plantUnits = getUnitsBydeviceIDs(deviceId, deviceStuct.deviceType); curName = deviceStuct.name; dataHash = CollectorYearDataService.GetInstance().GetYearDatasByUnits(plantUnits); } else { //设备 Device device = DeviceService.GetInstance().get(int.Parse(deviceId)); curName = deviceStuct.name; dataHash = DeviceYearDataService.GetInstance().GetTotalDatasByDevice(device); } //如果有多个设备进行编辑,没有数据的时候也显示 //if (dataHash.Count > 0) //{ KeyValuePair <string, float?[]> data = base.GenerateChartData(curName, years.ToArray(), dataHash, deviceStuct.rate); datas.Add(data); //} //如果有数据则将有数据标识为true if (dataHash.Count > 0) { hasData = true; } } //如果所有设备都没数据才清空数据,即图表中显示无数据提示 if (!hasData) { datas.Clear(); } string[] xAxis = years.ToArray <string>(); return(ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames, chartTypes, units, compareObjs, false)); }
public int GetPlantNoConfirmLogsCount(Plant plant) { string ids = string.Empty; foreach (PlantUnit unit in plant.plantUnits) { ids += string.Format("{0},", unit.collectorID); } ids = ids.Length > 0 ? ids.Substring(0, ids.Length - 1) : "-1"; IList <int> yearList = CollectorYearDataService.GetInstance().GetWorkYears(plant); int totalLogsCount = 0; foreach (int year in yearList) { totalLogsCount += _faultDao.GetPlantNoConfirmLogsCount(year.ToString(), ids); } return(totalLogsCount); }
/// <summary> /// 取得总体年度pr性能 /// </summary> /// <param name="plantList"></param> /// <param name="chartName"></param> /// <param name="chartType"></param> /// <returns></returns> public ChartData YearPRChartBypList(IList <Plant> plantList, string chartName, 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); //产生坐标 Hashtable yearEnergy = CollectorYearDataService.GetInstance().GetYearDatasByUnits(unitList); string[] ic = sortCollection(yearEnergy.Keys); string[] newic = null; int len = 5; int skip = len - ic.Length; int left = (int)skip / 2; int right = 5 - ic.Length - left; if (ic.Length < len) { newic = new string[len]; len = 0; int startYear = ic.Length == 0 ? DateTime.Now.Year : int.Parse(ic[0]); int endYear = ic.Length == 0 ? DateTime.Now.Year : int.Parse(ic[ic.Length - 1]); while (left > 0) { newic[len++] = (startYear - (left--)).ToString(); } foreach (string s in ic) { newic[len++] = s; } for (int i = 1; i <= right; i++) { newic[len++] = (endYear + (i)).ToString(); } } else { newic = ic; } string[] xAxis = formatXaxis(newic, ChartTimeType.Year); float rate = 1.0F; string newseriekey; //取得多个采集器的实际发电量 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 (yearEnergy.Count > 0) { newseriekey = LanguageUtil.getDesc("ACTUALENERGY"); data = GenerateChartData(newseriekey, newic, yearEnergy, rate); datas.Add(data); //取得日照增量强度,并依次计算理论发电量 //取得有增量日照迁强度的环境监测仪设备 IList <Device> devices = getDevicesByPlantsWithSunshine(plantList); //计算理论发电量换算率 IList <float> rates = this.getDeviceRatesByPlantsWithSunshine(plantList); yearEnergy = DeviceYearDataService.GetInstance().GetTotalDatasByDevices(devices); newseriekey = LanguageUtil.getDesc("THEORYENERGY"); data = GenerateChartData(newseriekey, newic, yearEnergy, 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)); }