public IndexWindowResult GetIndexWindowResult(QueryIndexWindow query) { var pAction = new ExecuteProcess(); try { var result = new NTS.WEB.BLL.IndexEnery().GetItemCodeListByObjectID(query); if (result == null) { pAction.Success = false; pAction.ExceptionMsg = "暂无数据信息"; return new IndexWindowResult() { ActionInfo = pAction }; } pAction.Success = true; result.ActionInfo = pAction; return result; } catch (Exception e) { pAction.Success = false; pAction.ExceptionMsg = e.Message; return new IndexWindowResult() { ActionInfo = pAction }; } }
public ResultView.IndexWindowResult GetItemCodeListByObjectID(QueryIndexWindow query) { Dictionary<string, BaseResult> Res = new Dictionary<string, BaseResult>(); IndexWindowResult Results = new IndexWindowResult(); string[] ItemCodeStr = { "01000", "02000", "03000", "04000" };//daixy 该处需要修改 DateTime[] Dates = { query.StatisticsDate, query.StatisticsDate.AddDays(-1) }; List<Model.BaseLayerObject> queryObjectList = new BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and LayerObjectID={0}", query.BuildingNumber), " order by LayerObjectID"); var queryObject = new Model.BaseLayerObject(); if (queryObjectList.Count > 0) { queryObject = queryObjectList[0]; } else { return null; } BaseQueryModel model1 = new BaseQueryModel(); try { BaseQueryModel model = new BaseQueryModel(); model.IsDevice = 0; model.ObjectList = new List<int>() { query.BuildingNumber }; foreach (var i in ItemCodeStr) { foreach (var d in Dates) { model.ItemCode = i; model.Unit = ChartUnit.unit_day; model.Starttime = d; model.Endtime = d; model1 = new BaseQueryModel(); model1.ItemCode = i; model1.Unit = ChartUnit.unit_day; model1.Starttime = d; model1.Endtime = d; Res.Add(i + "_" + d, reportBll.GetBaseEneryDataList(model)); } } if (Res.Count > 0) { Results.Electricity = Res[ItemCodeStr[0] + "_" + Dates[0]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()].Total; Results.Water = Res[ItemCodeStr[1] + "_" + Dates[0]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()].Total; Results.Gas = Res[ItemCodeStr[2] + "_" + Dates[0]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()].Total; Results.Warm = Res[ItemCodeStr[3] + "_" + Dates[0]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()].Total; if ( Res[ItemCodeStr[0] + "_" + Dates[1]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()] .Total == 0) { Results.ComparedElectricity = "-"; } else { Results.ComparedElectricity = decimal.Round( 100 * (Results.Electricity - Res[ItemCodeStr[0] + "_" + Dates[1]].BaseLayerObjectResults[ queryObject.LayerObjectID.ToString()].Total) / Res[ItemCodeStr[0] + "_" + Dates[1]].BaseLayerObjectResults[ queryObject.LayerObjectID.ToString()].Total, 2).ToString() + "%"; } if (Res[ItemCodeStr[1] + "_" + Dates[1]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()] .Total == 0) { Results.ComparedWater = "-"; } else { Results.ComparedWater = decimal.Round( 100 * (Results.Water - Res[ItemCodeStr[1] + "_" + Dates[1]].BaseLayerObjectResults[ queryObject.LayerObjectID.ToString()].Total) / Res[ItemCodeStr[1] + "_" + Dates[1]].BaseLayerObjectResults[ queryObject.LayerObjectID.ToString()].Total, 2).ToString() + "%"; } if (Res[ItemCodeStr[2] + "_" + Dates[1]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()] .Total == 0) { Results.ComparedGas = "-"; } else { Results.ComparedGas = decimal.Round( 100 * (Results.Gas - Res[ItemCodeStr[2] + "_" + Dates[1]].BaseLayerObjectResults[ queryObject.LayerObjectID.ToString()].Total) / Res[ItemCodeStr[2] + "_" + Dates[1]].BaseLayerObjectResults[ queryObject.LayerObjectID.ToString()].Total, 2).ToString() + "%"; } if (Res[ItemCodeStr[3] + "_" + Dates[1]].BaseLayerObjectResults[queryObject.LayerObjectID.ToString()] .Total == 0) { Results.ComparedWarm = "-"; } else { Results.ComparedWarm = decimal.Round( 100 * (Results.Warm - Res[ItemCodeStr[3] + "_" + Dates[1]].BaseLayerObjectResults[ queryObject.LayerObjectID.ToString()].Total) / Res[ItemCodeStr[3] + "_" + Dates[1]].BaseLayerObjectResults[ queryObject.LayerObjectID.ToString()].Total, 2).ToString() + "%"; } return Results; } } catch (Exception ex) { return null; } return null; }