private void VerifyPersonOrAreaExist(NTS.WEB.DataContact.QueryOrderObjects query) { switch (query.QueryType) { case EnergyAnalyseQueryType.UnitArea: case EnergyAnalyseQueryType.UnitPerson: string where = ""; List <Model.BaseLayerObject> LayerObjectList; foreach (var areaid in query.AreaIdLst) { where = string.Format(@"and layerobjectid={0} ", areaid); if (query.ObjType == AreaType.Liquid) { //取液态 LayerObjectList = new DAL.BaseLayerObject().GetBaseFuncLayerObjectList(where, string.Format(" order by LayerObjectID")); } else { LayerObjectList = new DAL.BaseLayerObject().GetBaseLayerObjectList(where, string.Format(" order by LayerObjectID")); } if (LayerObjectList.Count > 0) { switch (query.QueryType) { case EnergyAnalyseQueryType.UnitArea: if (!(LayerObjectList[0].AreaNum > 0)) { throw new Exception(string.Format("位置:【{0}】 单位面积尚未配置", LayerObjectList[0].LayerObjectName)); } break; case EnergyAnalyseQueryType.UnitPerson: if (!(LayerObjectList[0].PersonNum > 0)) { throw new Exception(string.Format("位置:【{0}】 人均尚未配置", LayerObjectList[0].LayerObjectName)); } break; } } } break; } }
/// <summary> /// 能耗集合 /// </summary> /// <param name="model">查询的对象封装</param> /// <returns></returns> public static BaseResult GetBaseEneryDataList(BaseQueryModel model) { BaseResult Res = new BaseResult(); Res.BaseLayerObjectResults = new Dictionary<string, BaseData>(); //Res.DeviceResults = new Dictionary<Model.Device, BaseData>(); bool IsDevice = model.IsDevice == 0 ? false : true; var datas = new DataTable(); if (model != null && model.ObjectList.Count > 0) { foreach (var objects in model.ObjectList) { decimal tempCount = 0; BaseDataModel bmodel = new BaseDataModel(); bmodel.Starttime = model.Starttime; if (model.Unit == ChartUnit.unit_hour) { bmodel.Endtime = (model.Starttime == model.Endtime) ? model.Starttime.AddDays(1).AddHours(-1) : model.Endtime; } else { bmodel.Endtime = model.Endtime; } bmodel.IsDevice = model.IsDevice; bmodel.ItemCode = model.ItemCode; bmodel.ObjectId = objects; bmodel.Unit = model.Unit; datas = GetBaseData(bmodel); BaseData bsDatas = new BaseData(); bsDatas.itemCode = new Model.Itemcode(); var ItemCodeList = new DAL.Itemcode().GetItemcodeList(string.Format(" and ItemCodeNumber='{0}'", model.ItemCode), string.Format(" order by ItemcodeID")); bsDatas.itemCode = ItemCodeList.Count > 0 ? ItemCodeList[0] : null; Model.BaseLayerObject ObjectInfo = new Model.BaseLayerObject(); Model.Device DeviceObjectInfo = new Model.Device(); if (!IsDevice) { var infoList = new DAL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and LayerObjectID={0}", objects), string.Format(" order by LayerObjectID")); ObjectInfo = infoList.Count > 0 ? infoList[0] : null; bsDatas.Datas = new List<DataItems>(); foreach (DataRow item in datas.Rows) { tempCount += decimal.Parse(item["CountValue"].ToString()); bsDatas.Datas.Add(new DataItems() { DatePick = item["Starttime"].ToString(), DataValue = decimal.Parse(item["CountValue"].ToString()), CoalDataValue = decimal.Parse(item["CountValue"].ToString()) * (decimal)bsDatas.itemCode.ItemCoal, Co2DataValue = decimal.Parse(item["CountValue"].ToString()) * (decimal)bsDatas.itemCode.ItemCO2, MoneyDataValue = decimal.Parse(item["CountValue"].ToString()) * (decimal)bsDatas.itemCode.ItemMoney, DataValueAndDept = item["CountValue"].ToString() + bsDatas.itemCode.Unit }); } bsDatas.baseLayerObject = ObjectInfo; } else { var infoList = new DAL.Device().GetDeviceList(string.Format(" and deviceid={0}", objects), string.Format(" order by DeviceID")); DeviceObjectInfo = infoList.Count > 0 ? infoList[0] : null; bsDatas.Datas = new List<DataItems>(); foreach (DataRow item in datas.Rows) { tempCount += decimal.Parse(item["CountValue"].ToString()); bsDatas.Datas.Add(new DataItems() { DatePick = item["Starttime"].ToString(), DataValue = decimal.Parse(item["CountValue"].ToString()), CoalDataValue = decimal.Parse(item["CountValue"].ToString()) *(decimal)bsDatas.itemCode.ItemCoal, Co2DataValue = decimal.Parse(item["CountValue"].ToString()) * (decimal)bsDatas.itemCode.ItemCO2, MoneyDataValue = decimal.Parse(item["CountValue"].ToString()) * (decimal)bsDatas.itemCode.ItemMoney, DataValueAndDept = item["CountValue"].ToString() + bsDatas.itemCode.Unit }); } bsDatas.device = DeviceObjectInfo; } bsDatas.Total = tempCount; bsDatas.ConvertDataValueList = new System.Collections.Hashtable(); bsDatas.ConvertDataValueList.Add("ITEMCOAL", decimal.Round(tempCount * (decimal)bsDatas.itemCode.ItemCoal, 4).ToString()); bsDatas.ConvertDataValueList.Add("ITEMCO2", decimal.Round(tempCount * (decimal)bsDatas.itemCode.ItemCO2, 4).ToString()); bsDatas.ConvertDataValueList.Add("ITEMMONEY", decimal.Round(tempCount * (decimal)bsDatas.itemCode.ItemMoney, 4).ToString()); Res.BaseLayerObjectResults.Add( !IsDevice ? ObjectInfo.LayerObjectID.ToString() : DeviceObjectInfo.DeviceID.ToString(), bsDatas); } return Res; } return null; }
/// <summary> /// 能耗集合 /// </summary> /// <param name="model">查询的对象封装</param> /// <returns></returns> public static BaseResult GetBaseEneryDataListNew(BaseQueryModel model) { BaseResult Res = new BaseResult(); Res.BaseLayerObjectResults = new Dictionary <string, BaseData>(); //Res.DeviceResults = new Dictionary<Model.Device, BaseData>(); bool IsDevice = model.IsDevice == 0 ? false : true; var datas = new DataTable(); if (model != null && model.ObjectList.Count > 0) { foreach (var objects in model.ObjectList) { double tempCount = 0; BaseDataModel bmodel = new BaseDataModel(); bmodel.Starttime = model.Starttime; if (model.Unit == ChartUnit.unit_hour) { bmodel.Endtime = (model.Starttime == model.Endtime) ? model.Starttime.AddDays(1).AddHours(-1) : model.Endtime; } else { bmodel.Endtime = model.Endtime; } bmodel.IsDevice = model.IsDevice; bmodel.ItemCode = model.ItemCode; bmodel.ObjectId = objects; bmodel.Unit = model.Unit; datas = GetBaseData(bmodel); BaseData bsDatas = new BaseData(); bsDatas.itemCode = new Model.Itemcode(); var ItemCodeList = new DAL.Itemcode().GetItemcodeList(string.Format(" and ItemCodeNumber='{0}'", model.ItemCode), string.Format(" order by ItemcodeID")); bsDatas.itemCode = ItemCodeList.Count > 0 ? ItemCodeList[0] : null; Model.BaseLayerObject ObjectInfo = new Model.BaseLayerObject(); Model.Device DeviceObjectInfo = new Model.Device(); if (!IsDevice) { List <Model.BaseLayerObject> infoList = new List <Model.BaseLayerObject>(); if (model.areaType == WEB.DataContact.AreaType.Area) { infoList = new DAL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and LayerObjectID={0}", objects), string.Format(" order by LayerObjectID")); } else { infoList = new DAL.BaseLayerObject().GetBaseFuncLayerObjectList(string.Format(" and LayerObjectID={0}", objects), string.Format(" order by LayerObjectID")); } ObjectInfo = infoList.Count > 0 ? infoList[0] : null; bsDatas.Datas = new List <DataItems>(); foreach (DataRow item in datas.Rows) { tempCount += double.Parse(item["CountValue"].ToString()); bsDatas.Datas.Add(new DataItems() { DatePick = item["Starttime"].ToString(), DataValue = decimal.Parse(item["CountValue"].ToString()), CoalDataValue = Convert.ToDecimal(double.Parse(item["CountValue"].ToString()) * bsDatas.itemCode.ItemCoal), Co2DataValue = Convert.ToDecimal(double.Parse(item["CountValue"].ToString()) * bsDatas.itemCode.ItemCO2), MoneyDataValue = Convert.ToDecimal(double.Parse(item["CountValue"].ToString()) * bsDatas.itemCode.ItemMoney), DataValueAndDept = item["CountValue"].ToString() + bsDatas.itemCode.Unit }); } bsDatas.baseLayerObject = ObjectInfo; } else { var infoList = new DAL.Device().GetDeviceList(string.Format(" and deviceid={0}", objects), string.Format(" order by DeviceID")); DeviceObjectInfo = infoList.Count > 0 ? infoList[0] : null; bsDatas.Datas = new List <DataItems>(); foreach (DataRow item in datas.Rows) { tempCount += double.Parse(item["CountValue"].ToString()); bsDatas.Datas.Add(new DataItems() { DatePick = item["Starttime"].ToString(), DataValue = Convert.ToDecimal(item["CountValue"].ToString()), CoalDataValue = Convert.ToDecimal(double.Parse(item["CountValue"].ToString()) * bsDatas.itemCode.ItemCoal), Co2DataValue = Convert.ToDecimal(double.Parse(item["CountValue"].ToString()) * bsDatas.itemCode.ItemCO2), MoneyDataValue = Convert.ToDecimal(double.Parse(item["CountValue"].ToString()) * bsDatas.itemCode.ItemMoney), DataValueAndDept = item["CountValue"].ToString() + bsDatas.itemCode.Unit }); } bsDatas.device = DeviceObjectInfo; } bsDatas.Total = Convert.ToDecimal(tempCount); bsDatas.ConvertDataValueList = new System.Collections.Hashtable(); bsDatas.ConvertDataValueList.Add("ITEMCOAL", Math.Round((tempCount * bsDatas.itemCode.ItemCoal), 4).ToString()); bsDatas.ConvertDataValueList.Add("ITEMCO2", Math.Round((tempCount * bsDatas.itemCode.ItemCO2), 4).ToString()); bsDatas.ConvertDataValueList.Add("ITEMMONEY", Math.Round((tempCount * bsDatas.itemCode.ItemCO2), 4).ToString()); Res.BaseLayerObjectResults.Add( !IsDevice ? ObjectInfo.LayerObjectID.ToString() : DeviceObjectInfo.DeviceID.ToString(), bsDatas); } return(Res); } return(null); }
private void VerifyPersonOrAreaExist(NTS.WEB.DataContact.QueryOrderObjects query) { switch (query.QueryType) { case EnergyAnalyseQueryType.UnitArea: case EnergyAnalyseQueryType.UnitPerson: string where = ""; List<Model.BaseLayerObject> LayerObjectList; foreach (var areaid in query.AreaIdLst) { where = string.Format(@"and layerobjectid={0} ", areaid); if (query.ObjType == AreaType.Liquid) {//取液态 LayerObjectList = new DAL.BaseLayerObject().GetBaseFuncLayerObjectList(where, string.Format(" order by LayerObjectID")); } else { LayerObjectList = new DAL.BaseLayerObject().GetBaseLayerObjectList(where, string.Format(" order by LayerObjectID")); } if (LayerObjectList.Count > 0) { switch (query.QueryType) { case EnergyAnalyseQueryType.UnitArea: if (!(LayerObjectList[0].AreaNum > 0)) { throw new Exception(string.Format("位置:【{0}】 单位面积尚未配置", LayerObjectList[0].LayerObjectName)); } break; case EnergyAnalyseQueryType.UnitPerson: if (!(LayerObjectList[0].PersonNum > 0)) { throw new Exception(string.Format("位置:【{0}】 人均尚未配置", LayerObjectList[0].LayerObjectName)); } break; } } } break; } }