示例#1
0
        /// <summary>
        /// 将同数量的两组数据,组织成坐标
        /// add by hbqian in 2013-03-23 for 生成电站功率和日照散列图
        /// </summary>
        /// <param name="chatName"></param>
        /// <param name="xData"></param>
        /// <param name="yData"></param>
        /// <returns></returns>
        public ChartData genNewScatter(MonitorType smt,MonitorType pmt,string chartName, string startYearMMDDHH, string endYearMMDDHH, int interval, Hashtable xData, Hashtable yData, string unit, string chartType)
        {
            string[] ic = this.getXseriesFromYYYYMMDDHH(startYearMMDDHH, endYearMMDDHH, interval).ToArray();
            IList<string> newIcList = new List<String>();
            IList<float?> newYList = new List<float?>();
            KeyValuePair<string, float?[]> xMergedata = this.GenerateChartData(smt.name, ic, xData, 1.0f);
            KeyValuePair<string, float?[]> yMergedata = this.GenerateChartData(pmt.name, ic, yData, 1.0f);
            //整理数据,去掉x轴为0或者空的点
            for (int i = 0; i < xMergedata.Value.Length; i++)
            {
                if(xMergedata.Value[i] != null && xMergedata.Value[i]>0){
                    newIcList.Add(xMergedata.Value[i].ToString());
                    newYList.Add(yMergedata.Value[i]);
                }
            }
            KeyValuePair<string, float?[]> newyMergedata = new KeyValuePair<string,float?[]>(yMergedata.Key, newYList.ToArray());
            IList<KeyValuePair<string, float?[]>> yDataList = new List<KeyValuePair<string, float?[]>>() { newyMergedata };

            string[] ynames = new string[] {smt.name, pmt.name};
            string[] units = new string[] {smt.unit, pmt.unit};
            string[] chartTypes = new string[] { "scatter", "scatter"};

            ChartData td = ReportBuilder.createMultiJsonChartXY(chartName, newIcList.ToArray(), yDataList, ynames, chartTypes, new string[] { pmt.unit, pmt.unit }, false);
            td.units = units;
            td.names = ynames;
            TempDataUtil.putChartData(td.serieNo, td);
            return td;
        }
示例#2
0
        /// <summary>
        /// 功能:取得多个电站多个年度的年月发电量和比较数据
        /// </summary>
        /// <param name="plantList"></param>
        /// <param name="years"></param>
        /// <param name="mt"></param>
        /// <param name="unit"></param>
        /// <param name="chartType"></param>
        /// <param name="rate"></param>
        /// <returns></returns>
        public ChartData PlantYearCompare(IList<Plant> plantList, IList<int> years, string name, MonitorType mt, string unit, string chartType, float rate)
        {
            IList<PlantUnit> plantUnits = this.getUnitsByPlantList(plantList);
            ICollection<ICollection> keys = new List<ICollection>();
            StringBuilder sb = new StringBuilder();
            //foreach (int year in years)
            //{
               // sb.Append("," + year);
               // }

            string chartName = name ;
            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;
            //取得多个年度的发电月数据
            int i = 0;
            bool hasData = false;
            foreach (int year in years)
            {
                units.Add(unit);
                ynames.Add("");
                Hashtable dataHash = null;
                string curName = year.ToString();
                dataHash = CollectorYearMonthDataService.GetInstance().GetUnitBetweenYearData(plantUnits, year, year);
                ic = base.getMMX(year.ToString());

                //如果有多个设备进行编辑,没有数据的时候也显示
                //if (dataHash.Count > 0)
                //{
                    //add by qhb in 20120928 for 补偿发电量
                    base.addPlantYearEnergy(dataHash, plantList);
                    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);
        }
示例#3
0
        /// <summary>
        /// 功能:取得多个电站多个年度的年月发电量和比较数据
        /// </summary>
        /// <param name="plantList"></param>
        /// <param name="years"></param>
        /// <param name="mt"></param>
        /// <param name="unit"></param>
        /// <param name="chartType"></param>
        /// <param name="rate"></param>
        /// <returns></returns>
        public ChartData PlantMMCompare(IList<Plant> plantList, IList<string> yearmms,string name, MonitorType mt, string unit, string chartType, float rate)
        {
            IList<PlantUnit> plantUnits = this.getUnitsByPlantList(plantList);
            ICollection<ICollection> keys = new List<ICollection>();
            StringBuilder sb = new StringBuilder();
            //foreach (string year in yearmms)
            //{
               // 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 };
            string[] units = new string[1] { unit };
            string[] ynames = new string[1] { "" };
            string[] ic = null;
            bool hasData = false;
            //取得多个年度的发电月数据
            int i = 0;
            foreach (string yearMM in yearmms)
            {
                Hashtable dataHash = null;
                string curName = yearMM;
                dataHash = CollectorMonthDayDataService.GetInstance().GetUnitBetweenMonthData(plantUnits, yearMM, yearMM);
                string[]  tmpic = base.getXseriesFromYYYYMMDD(yearMM + "01", yearMM + CalenderUtil.getMonthDays(yearMM).ToString("00")).ToArray();
                if (ic==null || tmpic.Length > ic.Length) ic = tmpic;
                //如果有多个设备进行编辑,没有数据的时候也显示
                //if (dataHash.Count > 0)
                //{
                    //add by qhb in 20120928 for 补偿发电量
                    base.addPlantDayEnergy(dataHash, plantList, yearMM, yearMM);
                    KeyValuePair<string, float?[]> data = GenerateChartData(curName, ic, dataHash, rate);
                    datas.Add(data);
                //}
                //如果有数据则将有数据标识为true
                if (dataHash.Count > 0)
                {
                    hasData = true;
                }
                i++;
            }
            if (!hasData)
            {//如果所有设备都没数据才清空数据,即图表中显示无数据提示
                datas.Clear();
            }
            string[] xAxis = formatXaxis(ic, ChartTimeType.MonthDay);
            return ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames, chartTypes, units, fromApp);
        }
        /// <summary>
        /// 加工处理某天某个设备多测点数据到表格输出方式
        /// </summary>
        /// <param name="device"></param>
        /// <param name="yyyyMMdd"></param>
        /// <returns>//key :时间点 value : 测点和值map (key:测点 value:测点值)</returns>
        public IDictionary<string, IDictionary<string, string>> handleDayData(IList<string> allmts, Device device, string yyyyMMdd)
        {
            //首先取出某个设备的所有测点的天数据
            string year = yyyyMMdd.Substring(0, 4);
            string month = yyyyMMdd.Substring(4, 2);
            int day = int.Parse(yyyyMMdd.Substring(6, 2));

            IList<DeviceDayData> deviceDayDatas = this.getDeviceDayDatas(device, year, month, day, day);
            //保存时间点对应的测点值map
            //key :时间点 value : 测点和值map (key:测点 value:测点值)
            IDictionary<string, IDictionary<string, string>> timemtMap = new Dictionary<string, IDictionary<string, string>>();
            //循环取出所有时间点,并把所有时间点放入map
            string timepoint = "";
            IDictionary<string, string> mtMap = null;
            MonitorType omt = null;
            string mtkey = "";
            foreach (DeviceDayData dayData in deviceDayDatas) {
                if (string.IsNullOrEmpty(dayData.dataContent)) continue;
                //存储所有测点
                omt = MonitorType.getMonitorTypeByCode(dayData.monitorCode);
                //add by qhb at 20120829 for 判断逆变器测点是否符合显示规则,参照设备实时数据那里规则

                //如果是逆变器那么先取额定功率
                float outtype = 0;
                IList<int> notdisplayInverterbyPower = new List<int>();
                IList<int> notdisplayInverterbyoutType = new List<int>();
                if (device.deviceTypeCode == DeviceData.INVERTER_CODE)
                {
                    outtype = device.getMonitorValue(MonitorType.MIC_INVERTER_OUTTYPE);
                    notdisplayInverterbyoutType = DeviceRunData.getnotDisplayMonitor(outtype);
                    float power = device.getMonitorValue(MonitorType.MIC_INVERTER_POWER);
                    notdisplayInverterbyPower = DeviceRunData.getnotDisplayMonitorByPower(power);
                }
                //排除不显示的测点
                if (DeviceRunData.notDisplayMonitor.Contains(omt.code) || notdisplayInverterbyoutType.Contains(omt.code) || notdisplayInverterbyPower.Contains(omt.code)) continue;

                //重新构造一个实例,以便用tempaffix多语言显示后缀是线程安全
                string tempaffix = omt.tempaffix;
                string unit = omt.unit;
                Boolean isUP = false;//是否进制千位

                //如果是逆变器要判断abc三项电压和电流的输出类型,将输出类型作为有后缀测点的后缀
                if (device.deviceTypeCode == DeviceData.INVERTER_CODE)
                {
                    if (DeviceRunData.affixMonitors.Contains(dayData.monitorCode) && !float.IsNaN(outtype) && (outtype == 0 || outtype == 2))
                        tempaffix = outtype.ToString();
                    //add by qhb in 20120921 for 2)逆变器带功率的单位显示kW,不要显示W  (注意大小写)
                    if (omt.code == MonitorType.MIC_INVERTER_TOTALDPOWER || omt.code == MonitorType.MIC_INVERTER_ADIRECTPOWER || omt.code == MonitorType.MIC_INVERTER_BDIRECTPOWER || omt.code == MonitorType.MIC_INVERTER_CDIRECTPOWER || omt.code == MonitorType.MIC_INVERTER_TOTALYGPOWER || omt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER)
                    {
                        unit = "kW";
                        isUP = true;
                    }
                    if (omt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER)
                    {
                        unit = "kvar";
                        isUP = true;
                    }
                }
                MonitorType mt = new MonitorType(omt.code, unit, omt.zerotoline, tempaffix);

                if(string.IsNullOrEmpty(mt.unit)){
                    mtkey = mt.name;
                }else{
                    mtkey = mt.name + "(" + mt.unit + ")";
                }

                string[] datas = dayData.dataContent.Split('#');
                string[] timedatas=null;
                bool isAllZero = true;
                bool isAllNovalid = true;
                foreach(string data in datas){
                    if (string.IsNullOrEmpty(data)) continue;
                    timedatas = data.Split(':');
                    timepoint = timedatas[0];
                    timepoint = string.Format("{0}:{1}:{2}", timepoint.Substring(0, 2), timepoint.Substring(2, 2), timepoint.Substring(4));
                    if (timemtMap.ContainsKey(timepoint))
                    {
                        mtMap = timemtMap[timepoint];
                    }
                    else {
                        mtMap = new Dictionary<string, string>();
                        timemtMap.Add(timepoint, mtMap);
                    }

                    String value = timedatas[1];
                    //如果值为-表示该值无效,不显示该测点,“-”,数据解析器会把发送的无效值固定设为“-”
                    if ("-".Equals(value))
                    {
                        value = "";
                    }
                    else
                    {
                        isAllNovalid = false;
                    }

                    //add by qhb for 单位进制
                    if (isUP)
                    {
                        try
                        {
                            value = Math.Round((StringUtil.stringtoDouble(value) / 1000), 2).ToString();
                        }
                        catch (Exception e)
                        {
                            //do nothing
                        }
                    }
                    //add by qhb in 20121029 for 1)功率因数为0和无功功率为0屏蔽不显示。
                    if (mt.code == MonitorType.MIC_INVERTER_TOTALPOWERFACTOR || mt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER)
                    {
                        try
                        {
                            if (StringUtil.stringtoDouble(value) == 0)
                                value="";
                            else
                            {
                                isAllZero = false;
                            }
                        }
                        catch { }
                    }
                    if ("0".Equals(value) && omt.zerotoline)
                    {
                        value = "-";
                    }

                    if (mtMap.ContainsKey(mtkey))
                    {
                        mtMap[mtkey] = value;
                    }
                    else {
                        mtMap.Add(mtkey, value);
                    }
                }
                //add by qhb in 20121029 for 1)功率因数为0和无功功率为0屏蔽不显示。
                if (isAllZero && (mt.code == MonitorType.MIC_INVERTER_TOTALPOWERFACTOR || mt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER))
                {
                    continue;
                }
                if (isAllNovalid)
                    continue;
                allmts.Add(mtkey);
            }
            return timemtMap;
        }
 /// <summary>
 /// 生成电站多年 月kWp发电量对比
 /// </summary>
 /// <param name="id"></param>
 /// <param name="chartType"></param>
 /// <returns></returns>
 private ActionResult PlantYearCompareChart(Plant plant, string chartType, string name, MonitorType mt, string unit, float rate)
 {
     string reportCode = string.Empty;
     if (plant != null)
     {
         IList<int> workYears = CollectorYearDataService.GetInstance().GetWorkYears(plant);
         if (workYears.Count <= 2) chartType = ChartType.column;
         if (workYears.Count == 0)
         {
             reportCode = "error:" + LanguageUtil.getDesc("PLANT_CHART_NOWORK_YEAR");
             return Content(reportCode);
         }
         ChartData chartData = CompareChartService.GetInstance().PlantYearCompare(new List<Plant>() { plant }, workYears, name, mt, unit, chartType, rate);
         reportCode = JsonUtil.convertToJson(chartData, typeof(ChartData));
     }
     else
     {
         return Content("error:" + Resources.SunResource.NODATA);
     }
     return Content(reportCode);
 }
示例#6
0
        /// <summary>
        /// 将实时数据串转换成键值对象
        /// </summary>
        /// <param name="deviceRunData">实时数据对象</param>
        /// <returns>值对列表</returns>
        public IList<IList<KeyValuePair<MonitorType, string>>> convertRunstrToList(bool isOorder,int deviceTypeCode)
        {
            IList<IList<KeyValuePair<MonitorType, string>>> resList = new List<IList<KeyValuePair<MonitorType, string>>>();
            IList<KeyValuePair<MonitorType, string>> resGroup1 = new List<KeyValuePair<MonitorType, string>>();
            IList<KeyValuePair<MonitorType, string>> resGroup2 = new List<KeyValuePair<MonitorType, string>>();
            IList<KeyValuePair<MonitorType, string>> resGroup3 = new List<KeyValuePair<MonitorType, string>>();
            IList<KeyValuePair<MonitorType, string>> resGroup4 = new List<KeyValuePair<MonitorType, string>>();
            IList<KeyValuePair<MonitorType, string>> resGroup5 = new List<KeyValuePair<MonitorType, string>>();

            string rundatastr = this.rundatastr;
            string[] rundatas = rundatastr.Split('#');

            //先取得传感器接入路数,以决定显示多少路汇流箱路数
            int displayHxlroute = 0;
            if (deviceTypeCode == DeviceData.HUILIUXIANG_CODE)
            {
                displayHxlroute = getHlxroute(rundatas);
            }

            //如果是逆变器那么先取额定功率
            float outtype = 0;
            IList<int> notdisplayInverterbyPower = new List<int>();
            IList<int> notdisplayInverterbyoutType = new List<int>();
            if (deviceTypeCode == DeviceData.INVERTER_CODE)
            {
                outtype = this.getMonitorValue(MonitorType.MIC_INVERTER_OUTTYPE);
                notdisplayInverterbyoutType = getnotDisplayMonitor(outtype);
                float power = this.getMonitorValue(MonitorType.MIC_INVERTER_POWER);
                notdisplayInverterbyPower = getnotDisplayMonitorByPower(power);
            }

            string[] datas = null;
            foreach (string data in rundatas)
            {
                datas = data.Split(':');
                int monitorCode = int.Parse(datas[0]);
                MonitorType omt = MonitorType.getMonitorTypeByCode(monitorCode);
                if (omt == null) continue;

                //如果该测点不属于此设备则也不显示,add by qhb in 20120913
                if (!MonitorType.getMonitorTypesByTypeCode(deviceTypeCode).Contains(omt)) continue;

                //重新构造一个实例,以便用tempaffix多语言显示后缀是线程安全
                string tempaffix = omt.tempaffix;
                string unit = omt.unit;
                Boolean isUP = false;//是否进制千位

                //如果是逆变器要判断abc三项电压和电流的输出类型,将输出类型作为有后缀测点的后缀
                if (deviceTypeCode == DeviceData.INVERTER_CODE)
                {
                    if (affixMonitors.Contains(monitorCode) && !float.IsNaN(outtype) && (outtype == 0 || outtype == 2))
                        tempaffix = outtype.ToString();
                    //add by qhb in 20120921 for 2)逆变器带功率的单位显示kW,不要显示W  (注意大小写)
                    if (omt.code == MonitorType.MIC_INVERTER_TOTALDPOWER || omt.code == MonitorType.MIC_INVERTER_ADIRECTPOWER || omt.code == MonitorType.MIC_INVERTER_BDIRECTPOWER || omt.code == MonitorType.MIC_INVERTER_CDIRECTPOWER || omt.code == MonitorType.MIC_INVERTER_TOTALYGPOWER || omt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER)
                    {
                        unit = "kW";
                        isUP = true;
                    }
                    if (omt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER)
                    {
                        unit = "kvar";
                        isUP = true;
                    }
                }

                MonitorType mt = new MonitorType(omt.code, unit, omt.zerotoline, tempaffix);

                //排除不显示的测点
                if (notDisplayMonitor.Contains(mt.code) || notdisplayInverterbyoutType.Contains(mt.code) || notdisplayInverterbyPower.Contains(mt.code)) continue;

                //如果是汇流箱非显示路数则跳过
                if (deviceTypeCode == DeviceData.HUILIUXIANG_CODE && ((monitorCode>=MonitorType.MIC_BUSBAR_17CURRENT &&monitorCode<=MonitorType.MIC_BUSBAR_32CURRENT)||(monitorCode>=MonitorType.MIC_BUSBAR_1CURRENT &&monitorCode<=MonitorType.MIC_BUSBAR_16CURRENT)) )
                {
                    if (displayHxlroute > 0)
                    {
                        if (monitorCode >= 366)
                        {
                            if (monitorCode - 365 + 16 > displayHxlroute) continue;
                        }
                        else {
                            if (monitorCode - 300 > displayHxlroute) continue;
                        }
                    }
                }

                string value = datas[1];
                //如果值为-表示该值无效,不显示该测点,“-”,数据解析器会把发送的无效值固定设为“-”
                if ("-".Equals(value)) continue;

                value = getStatusValue(monitorCode, value);
                if ("0".Equals(value) && MonitorType.getMonitorTypeByCode(monitorCode).zerotoline)
                {
                    value = "-";
                }

                //add by qhb for 单位进制
                if (isUP)
                {
                    try
                    {
                        value = Math.Round((StringUtil.stringtoDouble(value) / 1000), 2).ToString();
                    }
                    catch (Exception e)
                    {
                        //do nothing
                    }
                }

                //add by qhb in 20120917 for 1)功率因数为0和无功功率为0屏蔽不显示。
                if (omt.code == MonitorType.MIC_INVERTER_TOTALPOWERFACTOR || omt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER)
                {
                    try
                    {
                        if (StringUtil.stringtoDouble(value) == 0)
                            continue;
                    }
                    catch { }
                }

                if (isOorder)
                {
                    if (sortGroup["group1"].Contains(monitorCode))
                    {
                        resGroup1.Add(new KeyValuePair<MonitorType, string>(mt, value));
                    }
                    else if (sortGroup["group2"].Contains(monitorCode))
                    {
                        resGroup2.Add(new KeyValuePair<MonitorType, string>(mt, value));
                    }
                    else if (sortGroup["group3"].Contains(monitorCode))
                    {
                        resGroup3.Add(new KeyValuePair<MonitorType, string>(mt, value));
                    }
                    else if (sortGroup["group4"].Contains(monitorCode))
                    {
                        resGroup4.Add(new KeyValuePair<MonitorType, string>(mt, value));
                    }
                    else
                    {
                        resGroup5.Add(new KeyValuePair<MonitorType, string>(mt, value));
                    }
                }
                else
                {
                    resGroup5.Add(new KeyValuePair<MonitorType, string>(mt, value));
                }
            }
            if (resGroup1.Count > 0)
                resList.Add(resGroup1);
            if (resGroup2.Count > 0)
                resList.Add(resGroup2);
            if (resGroup3.Count > 0)
                resList.Add(resGroup3);
            if (resGroup4.Count > 0)
                resList.Add(resGroup4);
            if (resGroup5.Count > 0)
                resList.Add(resGroup5);
            return resList;
        }
示例#7
0
        /// <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);
        }