/// <summary> /// 简单加工数据 /// </summary> /// <param name="powerHash"></param> /// <param name="mic"></param> /// <param name="tmpMDataArr"></param> /// <param name="isCount">是否统计发电量</param> private void HandleData(Hashtable powerHash, string[] mic, string[] tmpMDataArr, bool isCount) { DeviceChartService.GetInstance().FirstHandleChartData(mic, powerHash); double hj = 0;//发电量合计 double tmpvalue = 0; for (int i = 0; i < mic.Length; i++) { object value = powerHash[mic[i]]; if (value != null) { tmpvalue = double.Parse(value.ToString()); hj += tmpvalue; tmpMDataArr[i + 2] = Math.Round(tmpvalue + 0.0001, 3).ToString();//从2下表开始,因为前两位是空和设备名称 } } //如果是发电量将合计发给最后一个数据元素 if (isCount) { tmpMDataArr[tmpMDataArr.Length - 1] = Math.Round(hj + 0.0001, 3).ToString() + " kWh"; } }
/// <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); } }