コード例 #1
0
        public IHttpActionResult GetEquipmentReportListDataByHandl2(DeviceDataListModel2 model)
        {
            DeviceDataBLL      data      = new DeviceDataBLL();
            RetDeviceTableData tabledata = new RetDeviceTableData();
            ReturnItem <List <RetDeviceTableData> > retdata = new ReturnItem <List <RetDeviceTableData> >();
            DeviceDataModel datamodel = new DeviceDataModel()
            {
                EndTime             = model.EndTime,
                StartTime           = model.StartTime,
                GetTogetherType     = model.GetTogetherType,
                IntervalUnit        = model.IntervalUnit,
                StatisticalInterval = model.StatisticalInterval
            };

            Dictionary <string, string> itemIdToDeviceId = new Dictionary <string, string>(); //key为itemID,value为deviceId

            if (model.DeviceIDs != null || model.DeviceIDs.Count != 0)                        //获取参数中的所有设备对应的propertyLable属性
            {
                UserApi api     = new UserApi();
                var     userApi = api.GetUserInfoByToken();
                model.DeviceItemIDs = new List <string>();
                foreach (var id in model.DeviceIDs)
                {
                    var deviceid = Convert.ToInt32(id);
                    DeviceItemInfoModel parameter = new DeviceItemInfoModel();
                    parameter.OrgID    = userApi.Data.OrgID.ToString();
                    parameter.DeviceID = deviceid;

                    DeviceInfoBLL device  = new DeviceInfoBLL();
                    var           getitem = device.GetEquipmentItemsList(parameter);
                    if (getitem.Data != null)
                    {
                        var temp = getitem.Data;
                        foreach (var item in getitem.Data)
                        {
                            if (item.PropertyLabel == model.DeviceItemPropertyLabel)//如果是该PropertyLabel的,则放到参数里面
                            {
                                model.DeviceItemIDs.Add(item.ID);
                                itemIdToDeviceId.Add(item.ID, id);
                                break;
                            }
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
            }

            if (model.DeviceItemIDs != null && model.DeviceItemIDs.Count > 0)
            {
                var count = 0;
                List <RetDeviceTableList> listtabledata = new List <RetDeviceTableList>();
                List <string>             listtimedata  = new List <string>();
                List <List <object> >     listcordata   = new List <List <object> >();
                List <List <object> >     listanodata   = new List <List <object> >();
                List <List <object> >     listnordata   = new List <List <object> >();
                List <double>             listdatadata  = new List <double>();

                List <RetDeviceTableData> listdata = new List <RetDeviceTableData>();
                foreach (var item in model.DeviceItemIDs)
                {
                    RetDeviceTableData chartdata = new RetDeviceTableData();//图表数据
                    datamodel.DeviceItemID = item;
                    string id = "";
                    itemIdToDeviceId.TryGetValue(item, out id);
                    if (id == null || id == "")
                    {
                        retdata.Code = -1;
                        retdata.Msg  = "在Dictionary中获取deviceId失败";
                        retdata.Data = null;
                        return(InspurJson <List <RetDeviceTableData> >(retdata));
                    }
                    datamodel.DeviceID = id;
                    var get = data.GetEquipmentReportListDataByHandl(datamodel);
                    if (get != null && get.Data != null)
                    {
                        chartdata.AllCoordination  = get.Data.AllCoordination;
                        chartdata.AnomCoordination = get.Data.AnomCoordination;
                        chartdata.Data             = get.Data.Data;
                        chartdata.DeviceItemName   = get.Data.DeviceItemName;
                        chartdata.DeviceName       = get.Data.DeviceName;
                        chartdata.DeviceTableList  = get.Data.DeviceTableList;
                        chartdata.NormCoordination = get.Data.NormCoordination;
                        chartdata.Time             = get.Data.Time;
                        chartdata.Unit             = get.Data.Unit;
                        chartdata.type             = "2";
                        listdata.Add(chartdata);


                        if (get.Data.DeviceTableList != null)
                        {
                            foreach (var listitem in get.Data.DeviceTableList)
                            {
                                listtabledata.Add(listitem);
                            }
                        }
                        if (get.Data.Time != null)
                        {
                            foreach (var listtime in get.Data.Time)
                            {
                                listtimedata.Add(listtime);
                            }
                        }
                        if (get.Data.AllCoordination != null)
                        {
                            foreach (var cooitem in get.Data.AllCoordination)
                            {
                                listcordata.Add(cooitem);
                            }
                        }
                        if (get.Data.AnomCoordination != null)
                        {
                            foreach (var anoitem in get.Data.AnomCoordination)
                            {
                                listanodata.Add(anoitem);
                            }
                        }
                        if (get.Data.NormCoordination != null)
                        {
                            foreach (var noritem in get.Data.NormCoordination)
                            {
                                listnordata.Add(noritem);
                            }
                        }
                        if (get.Data.Data != null)
                        {
                            foreach (var dataitem in get.Data.Data)
                            {
                                listdatadata.Add(dataitem);
                            }
                        }
                        count       += get.Count;
                        retdata.Code = get.Code;
                        //retdata.Msg = get.Msg;
                        retdata.Msg = "wahahaaaaaaaaa";
                    }
                }
                tabledata.DeviceTableList  = listtabledata;
                tabledata.Time             = listtimedata;
                tabledata.AllCoordination  = listcordata;
                tabledata.AnomCoordination = listanodata;
                tabledata.NormCoordination = listnordata;
                tabledata.Data             = listdatadata;
                tabledata.type             = "1";

                listdata.Add(tabledata);//添加列表数据
                retdata.Data  = listdata;
                retdata.Count = count;
            }
            return(InspurJson <List <RetDeviceTableData> >(retdata));
        }
コード例 #2
0
        public IHttpActionResult GetEquipmentReportListDataByHandl(DeviceDataListModel model)
        {
            DeviceDataBLL      data      = new DeviceDataBLL();
            RetDeviceTableData tabledata = new RetDeviceTableData();
            ReturnItem <List <RetDeviceTableData> > retdata = new ReturnItem <List <RetDeviceTableData> >();
            DeviceDataModel datamodel = new DeviceDataModel()
            {
                DeviceID            = model.DeviceID,
                EndTime             = model.EndTime,
                StartTime           = model.StartTime,
                GetTogetherType     = model.GetTogetherType,
                IntervalUnit        = model.IntervalUnit,
                StatisticalInterval = model.StatisticalInterval
            };

            if (model.DeviceItemIDs == null || model.DeviceItemIDs.Count == 0)//当前台不选属性时,将该设备所有的属性展示
            {
                UserApi api      = new UserApi();
                var     userApi  = api.GetUserInfoByToken();
                var     deviceid = 0;
                if (model.DeviceID != null && model.DeviceID != "")
                {
                    deviceid = Convert.ToInt32(model.DeviceID);
                }
                DeviceItemInfoModel parameter = new DeviceItemInfoModel();
                parameter.OrgID    = userApi.Data.OrgID.ToString();
                parameter.DeviceID = deviceid;

                DeviceInfoBLL device  = new DeviceInfoBLL();
                var           getitem = device.GetEquipmentItemsList(parameter);
                if (getitem.Data != null)
                {
                    foreach (var item in getitem.Data)
                    {
                        model.DeviceItemIDs.Add(item.ID);//核心语句
                    }
                }
                else
                {
                    return(null);
                }
            }

            if (model.DeviceItemIDs != null && model.DeviceItemIDs.Count > 0)
            {
                var count = 0;
                List <RetDeviceTableList> listtabledata = new List <RetDeviceTableList>();
                List <string>             listtimedata  = new List <string>();
                List <List <object> >     listcordata   = new List <List <object> >();
                List <List <object> >     listanodata   = new List <List <object> >();
                List <List <object> >     listnordata   = new List <List <object> >();
                List <double>             listdatadata  = new List <double>();

                List <RetDeviceTableData> listdata = new List <RetDeviceTableData>();
                foreach (var item in model.DeviceItemIDs)
                {
                    RetDeviceTableData chartdata = new RetDeviceTableData();//图表数据
                    datamodel.DeviceItemID = item;
                    var get = data.GetEquipmentReportListDataByHandl(datamodel);
                    if (get != null && get.Data != null)
                    {
                        chartdata.AllCoordination  = get.Data.AllCoordination;
                        chartdata.AnomCoordination = get.Data.AnomCoordination;
                        chartdata.Data             = get.Data.Data;
                        chartdata.DeviceItemName   = get.Data.DeviceItemName;
                        chartdata.DeviceName       = get.Data.DeviceName;
                        chartdata.DeviceTableList  = get.Data.DeviceTableList;
                        chartdata.NormCoordination = get.Data.NormCoordination;
                        chartdata.Time             = get.Data.Time;
                        chartdata.Unit             = get.Data.Unit;
                        chartdata.type             = "2";
                        listdata.Add(chartdata);


                        if (get.Data.DeviceTableList != null)
                        {
                            foreach (var listitem in get.Data.DeviceTableList)
                            {
                                listtabledata.Add(listitem);
                            }
                        }
                        if (get.Data.Time != null)
                        {
                            foreach (var listtime in get.Data.Time)
                            {
                                listtimedata.Add(listtime);
                            }
                        }
                        if (get.Data.AllCoordination != null)
                        {
                            foreach (var cooitem in get.Data.AllCoordination)
                            {
                                listcordata.Add(cooitem);
                            }
                        }
                        if (get.Data.AnomCoordination != null)
                        {
                            foreach (var anoitem in get.Data.AnomCoordination)
                            {
                                listanodata.Add(anoitem);
                            }
                        }
                        if (get.Data.NormCoordination != null)
                        {
                            foreach (var noritem in get.Data.NormCoordination)
                            {
                                listnordata.Add(noritem);
                            }
                        }
                        if (get.Data.Data != null)
                        {
                            foreach (var dataitem in get.Data.Data)
                            {
                                listdatadata.Add(dataitem);
                            }
                        }
                        count       += get.Count;
                        retdata.Code = get.Code;
                        retdata.Msg  = get.Msg;
                    }
                }
                tabledata.DeviceTableList  = listtabledata;
                tabledata.Time             = listtimedata;
                tabledata.AllCoordination  = listcordata;
                tabledata.AnomCoordination = listanodata;
                tabledata.NormCoordination = listnordata;
                tabledata.Data             = listdatadata;
                tabledata.type             = "1";

                listdata.Add(tabledata);//添加列表数据
                retdata.Data  = listdata;
                retdata.Count = count;
            }
            //else
            //{
            //    datamodel.DeviceItemID = model.DeviceItemIDs[0];
            //    var get = data.GetEquipmentReportListDataByHandl(datamodel);
            //    retdata = get;
            //}
            return(InspurJson <List <RetDeviceTableData> >(retdata));
        }