Пример #1
0
 public static DeviceDayDataService GetInstance()
 {
     if (_instance == null)
     {
         _instance = new DeviceDayDataService();
     }
     return(_instance);
 }
Пример #2
0
 public static DeviceDayDataService GetInstance()
 {
     if (_instance == null)
     {
         _instance = new DeviceDayDataService();
     }
     return _instance;
 }
Пример #3
0
        /// <summary>
        /// 设备单个测点的日图表
        /// </summary>
        /// <param name="device"></param>
        /// <param name="chartName"></param>
        /// <param name="startYYYYMMDDHH"></param>
        /// <param name="endYYYYMMDDHH"></param>
        /// <param name="chartType"></param>
        /// <param name="unit"></param>
        /// <param name="monitorCode"></param>
        /// <returns></returns>
        public ChartData DayChart(Device device, string chartName, string startYYYYMMDDHH, string endYYYYMMDDHH, string chartType, string unit, int monitorCode, int intervalMins)
        {
            //将整天的数据截断头尾
            string[] ic = base.getXseriesFromYYYYMMDDHH(startYYYYMMDDHH, endYYYYMMDDHH, intervalMins).ToArray();

            ///结果需要按时间先后排序
            Hashtable powerHash = DeviceDayDataService.GetInstance().GetDaydataList(ic, device, startYYYYMMDDHH, endYYYYMMDDHH, intervalMins, monitorCode);

            string[]    xAxis       = formatXaxis(ic, this.fromApp ? ChartTimeType.Hour : ChartTimeType.Day);
            MonitorType monitorType = MonitorType.getMonitorTypeByCode(monitorCode);

            KeyValuePair <string, float?[]> data = new KeyValuePair <string, float?[]>();

            if (powerHash.Count > 0)
            {
                //先屏蔽了,因为两天跨度的中间部分平滑有问题,但不是对原来是否有影响测试后才知道
                //this.FirstHandleChartData(ic, powerHash);
                data = GenerateChartData(monitorType.name, ic, powerHash, 1.0F);
            }

            return(ReportBuilder.createJsonChartXY(chartName, xAxis, data, "", unit, chartType, fromApp));
        }
Пример #4
0
        /// <summary>
        /// 比较多个设备多测点的天时数据
        /// </summary>
        /// <param name="chartName"></param>
        /// <param name="devices"></param>
        /// <param name="startYearMMDDHH"></param>
        /// <param name="endYearMMDDHH"></param>
        /// <param name="intervalMins"></param>
        /// <param name="rate">值的换算率</param>
        /// <param name="computeType">计算类型</param>
        /// <returns></returns>
        public ChartData compareDayHHMultiDeviceMultiMonitor(string chartName, IList <DeviceStuct> devices, string startYearMMDDHH, string endYearMMDDHH, int minIntervalMins, int computeType)
        {
            string reportData = string.Empty;
            //chartName = chartName + " from " + startYearMMDDHH + " to " + endYearMMDDHH;
            IList <KeyValuePair <string, float?[]> > datas = new List <KeyValuePair <string, float?[]> >();

            string[] ic    = base.getXseriesFromYYYYMMDDHH(startYearMMDDHH, endYearMMDDHH, minIntervalMins).ToArray();
            string[] xAxis = formatXaxis(ic, this.fromApp ? ChartTimeType.Hour : ChartTimeType.Day);

            IList <string> chartTypes  = new List <string>();
            IList <string> units       = new List <string>();
            IList <string> ynames      = new List <string>();
            IList <string> compareObjs = new List <string>();
            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;
                Hashtable dataHash    = null;
                string    startYearMM = startYearMMDDHH.Substring(0, 6);
                string    endYearMM   = endYearMMDDHH.Substring(0, 6);
                string    curName     = deviceStuct.name;
                string[]  tmpIc       = base.getXseriesFromYYYYMMDDHH(startYearMMDDHH, endYearMMDDHH, deviceStuct.intervalMins).ToArray();
                if (deviceStuct.deviceType == ChartDeviceType.PLANT || deviceStuct.deviceType == ChartDeviceType.COLLECTOR)
                {
                    //电站
                    IList <PlantUnit> plantUnits;
                    if (deviceStuct.deviceType == ChartDeviceType.PLANT)
                    {
                        KeyValuePair <string, float?[]> alldata = new KeyValuePair <string, float?[]>();
                        string[] plantIDArr = deviceId.Split(',');
                        foreach (string plantID in plantIDArr)
                        {
                            if (string.IsNullOrEmpty(plantID))
                            {
                                continue;
                            }
                            Plant plant = PlantService.GetInstance().GetPlantInfoById(int.Parse(plantID));
                            ///结果需要按时间先后排序
                            IList <PlantUnit> ounits = monitorCode == MonitorType.PLANT_MONITORITEM_LINGT_CODE ? plant.sunUnits : plant.plantUnits;
                            dataHash = CollectorDayDataService.GetInstance().GetUnitDaydataList(tmpIc, ounits, startYearMMDDHH, endYearMMDDHH, deviceStuct.intervalMins, monitorCode);

                            //if (dataHash.Count > 0)
                            //{
                            chartTypes.Add(deviceStuct.chartType);
                            compareObjs.Add(deviceStuct.comareObj);
                            units.Add(deviceStuct.unit);
                            ynames.Add("");
                            //先屏蔽了,因为两天跨度的中间部分平滑有问题,但不是对原来是否有影响测试后才知道
                            //base.FirstHandleChartData(tmpIc, dataHash);

                            KeyValuePair <string, float?[]> data = base.GenerateChartData(curName, ic, dataHash, deviceStuct.rate);
                            if (alldata.Key == null)
                            {
                                alldata = data;
                            }
                            else
                            {
                                alldata = new KeyValuePair <string, float?[]>(alldata.Key, mergeHash(alldata.Value, data.Value));
                            }
                            //}
                            //如果有数据则将有数据标识为true
                            if (dataHash.Count > 0)
                            {
                                hasData = true;
                            }
                        }

                        //如果有多个设备进行编辑,没有数据的时候也显示
                        //if (alldata.Key != null) {
                        datas.Add(alldata);
                        //}
                    }
                    else
                    {
                        plantUnits = new List <PlantUnit>()
                        {
                            new PlantUnit()
                            {
                                collector = new Collector()
                                {
                                    id = int.Parse(deviceId)
                                }
                            }
                        };
                        dataHash = CollectorDayDataService.GetInstance().GetUnitDaydataList(tmpIc, plantUnits, startYearMMDDHH, endYearMMDDHH, deviceStuct.intervalMins, monitorCode);

                        //如果有多个设备进行编辑,没有数据的时候也显示
                        //if (dataHash.Count > 0)
                        //{
                        chartTypes.Add(deviceStuct.chartType);
                        compareObjs.Add(deviceStuct.comareObj);
                        units.Add(deviceStuct.unit);
                        ynames.Add("");
                        //先屏蔽了,因为两天跨度的中间部分平滑有问题,但不是对原来是否有影响测试后才知道
                        //base.FirstHandleChartData(tmpIc, dataHash);
                        KeyValuePair <string, float?[]> data = base.GenerateChartData(curName, ic, dataHash, deviceStuct.rate);
                        datas.Add(data);
                        //}
                        //如果有数据则将有数据标识为true
                        if (dataHash.Count > 0)
                        {
                            hasData = true;
                        }
                    }
                }
                else
                {
                    //设备
                    Device device = DeviceService.GetInstance().get(int.Parse(deviceId));
                    dataHash = DeviceDayDataService.GetInstance().GetDaydataList(tmpIc, device, startYearMMDDHH, endYearMMDDHH, deviceStuct.intervalMins, monitorCode);
                    //如果有多个设备进行编辑,没有数据的时候也显示
                    //if (dataHash.Count > 0 || devices.Count > 1)
                    //{
                    chartTypes.Add(deviceStuct.chartType);
                    compareObjs.Add(deviceStuct.comareObj);
                    units.Add(deviceStuct.unit);
                    ynames.Add("");
                    //先屏蔽了,因为两天跨度的中间部分平滑有问题,但不是对原来是否有影响测试后才知道
                    //base.FirstHandleChartData(tmpIc, dataHash);
                    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(ic, datas, computeType);
                KeyValuePair <string, float?[]> newdata = new KeyValuePair <string, float?[]>(LanguageUtil.getDesc("AVERAGE"), newDataArr);
                datas.Add(newdata);
                chartTypes.Add(chartTypes[0]);
                units.Add(units[0]);
                ynames.Add(LanguageUtil.getDesc("AVERAGE"));
                compareObjs.Add("");
                string[] colors = new string[units.Count + 1];
                colors[colors.Length - 1] = "#EE0000";
                return(ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames.ToArray(), chartTypes.ToArray(), units.ToArray(), compareObjs.ToArray(), colors, fromApp));
            }
            else
            {
                return(ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames.ToArray(), chartTypes.ToArray(), units.ToArray(), compareObjs.ToArray(), fromApp));
            }
        }
Пример #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);
            }
        }