Exemplo n.º 1
0
        /// <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));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 设备年度统计图表
        /// </summary>
        /// <param name="device"></param>
        /// <param name="rate"></param>
        /// <param name="chartname"></param>
        /// <param name="chartType"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public ChartData YearChartByDevice(Device device, float rate, string chartname, string chartType, string unit)
        {
            if (device == null)
            {
                return(new ChartData());
            }

            string chartName = LanguageUtil.getDesc("CHART_TITLE_TOTAL_ENERGY");

            ///所有子站累加
            Hashtable yearEnergy = DeviceYearDataService.GetInstance().GetTotalDatasByDevice(device);

            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);

            string yname = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).name;
            KeyValuePair <string, float?[]> data = new KeyValuePair <string, float?[]>();

            if (yearEnergy.Count > 0)
            {
                data = GenerateChartData(yname, newic, yearEnergy, rate);
            }

            return(ReportBuilder.createJsonChartXY(chartName, xAxis, data, "", unit, chartType, fromApp));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 取得电站的某年的性能
        /// </summary>
        /// <param name="plant"></param>
        /// <param name="year"></param>
        /// <param name="yearEnergy"></param>
        /// <returns>已经转化为百分率了</returns>
        public double getYearPr(Plant plant, int year, double yearEnergy)
        {
            Device device = plant.getDetectorWithRenderSunshine();

            if (device == null)
            {
                return(0);
            }
            DeviceYearData deviceYearmonth = DeviceYearDataService.GetInstance().GetDeviceYearData(device.id, year);
            float          monthsunlingt   = deviceYearmonth.dataValue;

            if (monthsunlingt == 0)
            {
                return(0);
            }
            float dp = plant.design_power == 0 ? 1 : plant.design_power;

            return(yearEnergy / monthsunlingt * 1000 * dp);
        }
Exemplo n.º 4
0
        /// <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));
        }
Exemplo n.º 5
0
        /// <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);
            }
        }