コード例 #1
0
ファイル: QueryEnery.cs プロジェクト: NickQi/TianheDemo
        public ResultReal GetRealTime(NTS.WEB.DataContact.RealQuery query)
        {
            ResultReal result = new ResultReal();

            var objectList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
            var itemList   = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + objectList[0].ItemCodeID + "'", " order by ItemcodeID")[0];

            result.Info = new DeviceInfo();
            result.Data = new RealData();
            result.Info.Affiliations = objectList[0].Organization;
            result.Info.DevType      = objectList[0].DeviceType.ToString(CultureInfo.InvariantCulture);
            result.Info.Category     = (itemList.ItemCodeNumber == "01000" || itemList.ItemCodeNumber == "01A00" ||
                                        itemList.ItemCodeNumber == "01B00" || itemList.ItemCodeNumber == "01C00" ||
                                        itemList.ItemCodeNumber == "01D00")
                                     ? "电表"
                                     : itemList.ItemCodeName + "表";
            result.Info.Nature   = objectList[0].DEVMODE;
            result.Info.Number   = objectList[0].DeviceNumber;
            result.Info.Status   = objectList[0].Status;
            result.Info.Location = objectList[0].Location;
            result.Info.Rating   = objectList[0].Rating.ToString();
            if (query.IsDetail == 1)
            {
                for (int i = 1; i < 4; i++)
                {
                    BaseListModel model = new BaseListModel();
                    model.Page       = 1;
                    model.PageSize   = 10000;
                    model.ObjectId   = objectList[0].DeviceID;
                    model.CategoryId = i;
                    DataTable dt = new Real().GetRealTimeData(model);
                    if (dt.Rows.Count > 0)
                    {
                        if (i == 1)
                        {
                            result.Data.Pulse = new List <dataUnit>();
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                result.Data.Pulse.Add(new dataUnit()
                                {
                                    Id       = j + 1,
                                    DataName = dt.Rows[j]["DataPoint_Name"].ToString(),
                                    Unit     = itemList.Unit,
                                    Value    = decimal.Parse(dt.Rows[j]["Result"].ToString())
                                });
                            }
                        }
                        else if (i == 2)
                        {
                            result.Data.Analog = new List <dataUnit>();
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                result.Data.Analog.Add(new dataUnit()
                                {
                                    Id       = j + 1,
                                    DataName = dt.Rows[j]["DataPoint_Name"].ToString(),
                                    Unit     = itemList.Unit,
                                    Value    = decimal.Parse(dt.Rows[j]["Result"].ToString())
                                });
                            }
                        }
                        else
                        {
                            result.Data.Switch = new List <dataUnit>();
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                result.Data.Switch.Add(new dataUnit()
                                {
                                    Id       = j + 1,
                                    DataName = dt.Rows[j]["DataPoint_Name"].ToString(),
                                    Unit     = itemList.Unit,
                                    Value    = decimal.Parse(dt.Rows[j]["Result"].ToString())
                                });
                            }
                        }
                    }
                }
            }

            //result.Data.Analog = new List<dataUnit>();
            //result.Data.Analog.Add(new dataUnit() { Id = 1, DataName = "29189H92-00", Unit = "kwh", Value = 900.88m });
            //result.Data.Pulse = new List<dataUnit>();
            //result.Data.Pulse.Add(new dataUnit() { Id = 1, DataName = "29189H92-10", Unit = "kwh", Value = 400.88m });
            //result.Data.Switch = new List<dataUnit>();
            //result.Data.Switch.Add(new dataUnit() { Id = 1, DataName = "29189H92-20", Unit = "kwh", Value = 200.88m });
            return(result);
        }
コード例 #2
0
ファイル: Charts.cs プロジェクト: NickQi/TianheDemo
        public ResultRealLine DeviceRealChart(RealQuery query)
        {
            var pAction = new ExecuteProcess();
            try
            {
                var result = new ResultRealLine { series = new List<EneryAnalyseSeries>(), Unit = "kwh" };
                //ResultItemCode result = new ResultItemCode();
                //result.Dept = new List<string>();
                //result.Enery = new Dictionary<string, List<decimal>>();
                //result.ObjectName = new List<string>();
                // var result = new ResultIndexLineChart { DatePick = new List<string>(), DatePickEnery = new List<decimal>() };
                var eneryDataList = new Dictionary<string, decimal>();
                var model = new BaseQueryModel();
                var objectList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
                model.IsDevice = 1;
                model.ObjectList = (from p in objectList select p.DeviceID).ToList<int>();
                model.ItemCode = objectList[0].ItemCodeID;
                model.Unit = ChartUnit.unit_hour;
                if (query.QueryType == EnergyAnalyseQueryType.Default)
                {
                    model.Starttime = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd"));
                    model.Endtime = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd"));
                }
                else if (query.QueryType == EnergyAnalyseQueryType.MonthCompare)
                {
                    model.Starttime = Convert.ToDateTime(System.DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd"));
                    model.Endtime = Convert.ToDateTime(System.DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd"));
                }
                else if (query.QueryType == EnergyAnalyseQueryType.YearCompare)
                {
                    model.Starttime = Convert.ToDateTime(System.DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd"));
                    model.Endtime = Convert.ToDateTime(System.DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd"));
                }
                var itemList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + model.ItemCode + "'", " order by ItemcodeID")[0];
                result.Unit = itemList.Unit;//by added wxy
                var resList = _reportBll.GetBaseEneryDataList(model);
                foreach (var d in objectList.SelectMany(o => resList.BaseLayerObjectResults[o.DeviceID.ToString(CultureInfo.InvariantCulture)].Datas))
                {
                    if (!eneryDataList.ContainsKey(d.DatePick))
                    {
                        eneryDataList.Add(d.DatePick, d.DataValue);
                    }
                    else
                    {
                        eneryDataList[d.DatePick] += d.DataValue;
                    }
                }

                List<decimal> dat = new List<decimal>();
                foreach (var e in eneryDataList)
                {
                    dat.Add(e.Value);

                }
                EneryAnalyseSeries eas = new EneryAnalyseSeries();
                eas.data = dat;

                result.series.Add(eas);

                pAction.Success = true;
                result.ActionInfo = pAction;
                return result;

            }
            catch (Exception ex)
            {
                pAction.Success = false;
                pAction.ExceptionMsg = ex.Message;
                return new ResultRealLine() { ActionInfo = pAction };

            }
        }
コード例 #3
0
ファイル: Charts.cs プロジェクト: NickQi/TianheDemo
 public ResultItemCode RealChart(RealQuery query)
 {
     return new NTS.WEB.BLL.Charts().RealChart(query);
 }
コード例 #4
0
ファイル: Charts.cs プロジェクト: NickQi/TianheDemo
        public ResultItemCode RealChart(RealQuery query)
        {
            ResultItemCode result = new ResultItemCode();
            result.Dept = new List<string>();
            result.Enery = new Dictionary<string, List<decimal>>();
            result.ObjectName = new List<string>();
            // var result = new ResultIndexLineChart { DatePick = new List<string>(), DatePickEnery = new List<decimal>() };
            var eneryDataList = new Dictionary<string, decimal>();
            var model = new BaseQueryModel();
            var objectList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
            model.IsDevice = 1;
            model.ObjectList = (from p in objectList select p.DeviceID).ToList<int>();
            model.ItemCode = objectList[0].ItemCodeID;
            model.Unit = ChartUnit.unit_hour;
            model.Starttime = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd"));
            model.Endtime = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd"));
            var itemList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + model.ItemCode + "'", " order by ItemcodeID")[0];

            var resList = _reportBll.GetBaseEneryDataList(model);
            foreach (var d in objectList.SelectMany(o => resList.BaseLayerObjectResults[o.DeviceID.ToString(CultureInfo.InvariantCulture)].Datas))
            {
                if (!eneryDataList.ContainsKey(d.DatePick))
                {
                    eneryDataList.Add(d.DatePick, d.DataValue);
                }
                else
                {
                    eneryDataList[d.DatePick] += d.DataValue;
                }
            }
            result.Enery.Add(objectList[0].DeviceID.ToString(CultureInfo.InvariantCulture), eneryDataList.Values.ToList());
            foreach (var e in eneryDataList)
            {
                result.Dept.Add(itemList.Unit);
                result.ObjectName.Add(e.Key);

            }
            return result;
        }
コード例 #5
0
ファイル: Charts.cs プロジェクト: NickQi/TianheDemo
 public ResultRealLine DeviceRealChart(RealQuery query)
 {
     return new NTS.WEB.BLL.Charts().DeviceRealChart(query);
 }